Skip to content

Commit

Permalink
Start reproduction of pipeline 43FJ
Browse files Browse the repository at this point in the history
  • Loading branch information
elodiegermani1 committed Aug 15, 2023
1 parent 736d2ff commit 299b526
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
File renamed without changes.
93 changes: 93 additions & 0 deletions tests/pipelines/test_team_43FJ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/python
# coding: utf-8

""" Tests of the 'narps_open.pipelines.team_1KB2' module.
Launch this test with PyTest
Usage:
======
pytest -q test_team_2T6S.py
pytest -q test_team_2T6S.py -k <selected_test>
"""

from statistics import mean
from os import environ

from pytest import raises, helpers, mark
from nipype import Workflow

from narps_open.pipelines.team_1KB2 import PipelineTeam1KB2

class TestPipelinesTeam1KB2:
""" A class that contains all the unit tests for the PipelineTeam1KB2 class."""

@staticmethod
@mark.unit_test
def test_create(mocker): # Add mocker as argument
""" Test the creation of a PipelineTeam1KB2 object """
# Defines fake environment variable
mocker.patch.dict(environ, {'FSLDIR': '/fake/path/to/fsl'})

pipeline = PipelineTeam1KB2()

# 1 - check the parameters
assert pipeline.team_id == '1KB2'

# 2 - check workflows
assert isinstance(pipeline.get_preprocessing(), Workflow)
assert isinstance(pipeline.get_run_level_analysis(), Workflow)
assert isinstance(pipeline.registration(), Workflow)
assert isinstance(pipeline.get_subject_level_analysis(), Workflow)
group_level = pipeline.get_group_level_analysis()

assert len(group_level) == 3
for sub_workflow in group_level:
assert isinstance(sub_workflow, Workflow)

@staticmethod
@mark.unit_test
def test_outputs():
""" Test the expected outputs of a PipelineTeam1KB2 object """
pipeline = PipelineTeam1KB2()
# 1 - 1 suject outputs, 1 run
pipeline.subject_list = ['001']
pipeline.run_list = ['01']
pipeline.contrast_list = ['1','2']
assert len(pipeline.get_preprocessing_outputs()) == 6
#assert len(pipeline.get_run_level_outputs()) == 0
#assert len(pipeline.get_registration()) == 0
#assert len(pipeline.get_subject_level_outputs()) ==
#assert len(pipeline.get_group_level_outputs()) == 84

# 2 - 1 suject outputs, 4 runs
pipeline.subject_list = ['001']
pipeline.run_list = ['01', '02', '03', '04']
pipeline.contrast_list = ['1','2']
assert len(pipeline.get_preprocessing_outputs()) == 24
#assert len(pipeline.get_run_level_outputs()) == 0
#assert len(pipeline.get_registration()) == 0
#assert len(pipeline.get_subject_level_outputs()) == 36
#assert len(pipeline.get_group_level_outputs()) == 84

# 3 - 4 suject outputs, 4 runs
pipeline.subject_list = ['001', '002', '003', '004']
pipeline.run_list = ['01', '02', '03', '04']
pipeline.contrast_list = ['1','2']
assert len(pipeline.get_preprocessing_outputs()) == 96
#assert len(pipeline.get_run_level_outputs()) == 0
#assert len(pipeline.get_registration()) == 0
#assert len(pipeline.get_subject_level_outputs()) == 36
#assert len(pipeline.get_group_level_outputs()) == 84

@staticmethod
@mark.pipeline_test
def test_execution():
""" Test the execution of a PipelineTeam1KB2 and compare results """
results_4_subjects = helpers.test_pipeline(
'1KB2',
'/references/',
'/data/',
'/output/',
4)
assert mean(results_4_subjects) > .003

0 comments on commit 299b526

Please sign in to comment.