-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
2,513 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/python | ||
# coding: utf-8 | ||
|
||
""" Tests of the 'narps_open.pipelines.team_4TQ6' module. | ||
Launch this test with PyTest | ||
Usage: | ||
====== | ||
pytest -q test_team_4TQ6.py | ||
pytest -q test_team_4TQ6.py -k <selected_test> | ||
""" | ||
from os.path import join, exists, abspath | ||
from filecmp import cmp | ||
|
||
from pytest import helpers, mark | ||
from nipype import Workflow, Node, Function | ||
from nipype.interfaces.base import Bunch | ||
|
||
from narps_open.utils.configuration import Configuration | ||
from narps_open.pipelines.team_4TQ6 import PipelineTeam4TQ6 | ||
|
||
class TestPipelinesTeam4TQ6: | ||
""" A class that contains all the unit tests for the PipelineTeam4TQ6 class.""" | ||
|
||
@staticmethod | ||
@mark.unit_test | ||
def test_create(): | ||
""" Test the creation of a PipelineTeam4TQ6 object """ | ||
|
||
pipeline = PipelineTeam4TQ6() | ||
|
||
# 1 - check the parameters | ||
assert pipeline.fwhm == 6.0 | ||
assert pipeline.team_id == '4TQ6' | ||
|
||
# 2 - check workflows | ||
assert pipeline.get_preprocessing() is None | ||
assert isinstance(pipeline.get_run_level_analysis(), 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 PipelineTeam4TQ6 object """ | ||
|
||
pipeline = PipelineTeam4TQ6() | ||
|
||
# 1 - 1 subject outputs | ||
pipeline.subject_list = ['001'] | ||
helpers.test_pipeline_outputs(pipeline, [0, 4*1*2*4, 4*2*1 + 2*1, 6*2*2 + 3*2, 18]) | ||
|
||
# 2 - 4 subjects outputs | ||
pipeline.subject_list = ['001', '002', '003', '004'] | ||
helpers.test_pipeline_outputs(pipeline, [0, 4*4*2*4, 4*2*4 + 2*4, 6*2*2 + 3*2, 18]) | ||
|
||
@staticmethod | ||
@mark.unit_test | ||
def test_subject_information(): | ||
""" Test the get_subject_information method """ | ||
|
||
# Get test files | ||
test_file = join(Configuration()['directories']['test_data'], 'pipelines', 'events.tsv') | ||
|
||
# Prepare several scenarii | ||
info_missed = PipelineTeam4TQ6.get_subject_information(test_file) | ||
|
||
# Compare bunches to expected | ||
bunch = info_missed[0] | ||
assert isinstance(bunch, Bunch) | ||
assert bunch.conditions == ['trial', 'gain', 'loss'] | ||
helpers.compare_float_2d_arrays(bunch.onsets, [ | ||
[4.071, 11.834, 19.535, 27.535, 36.435], | ||
[4.071, 11.834, 19.535, 27.535, 36.435], | ||
[4.071, 11.834, 19.535, 27.535, 36.435] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.durations, [ | ||
[4.0, 4.0, 4.0, 4.0, 4.0], | ||
[4.0, 4.0, 4.0, 4.0, 4.0], | ||
[4.0, 4.0, 4.0, 4.0, 4.0] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.amplitudes, [ | ||
[1.0, 1.0, 1.0, 1.0, 1.0], | ||
[14.0, 34.0, 38.0, 10.0, 16.0], | ||
[6.0, 14.0, 19.0, 15.0, 17.0] | ||
]) | ||
|
||
@staticmethod | ||
@mark.pipeline_test | ||
def test_execution(): | ||
""" Test the execution of a PipelineTeam4TQ6 and compare results """ | ||
helpers.test_pipeline_evaluation('4TQ6') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/usr/bin/python | ||
# coding: utf-8 | ||
|
||
""" Tests of the 'narps_open.pipelines.team_O21U' module. | ||
Launch this test with PyTest | ||
Usage: | ||
====== | ||
pytest -q test_team_O21U.py | ||
pytest -q test_team_O21U.py -k <selected_test> | ||
""" | ||
from os.path import join, exists, abspath | ||
from filecmp import cmp | ||
|
||
from pytest import helpers, mark | ||
from nipype import Workflow, Node, Function | ||
from nipype.interfaces.base import Bunch | ||
|
||
from narps_open.utils.configuration import Configuration | ||
from narps_open.pipelines.team_O21U import PipelineTeamO21U | ||
|
||
class TestPipelinesTeamO21U: | ||
""" A class that contains all the unit tests for the PipelineTeamO21U class.""" | ||
|
||
@staticmethod | ||
@mark.unit_test | ||
def test_create(): | ||
""" Test the creation of a PipelineTeamO21U object """ | ||
|
||
pipeline = PipelineTeamO21U() | ||
|
||
# 1 - check the parameters | ||
assert pipeline.fwhm == 5.0 | ||
assert pipeline.team_id == 'O21U' | ||
|
||
# 2 - check workflows | ||
assert pipeline.get_preprocessing() is None | ||
assert isinstance(pipeline.get_run_level_analysis(), 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 PipelineTeamO21U object """ | ||
|
||
pipeline = PipelineTeamO21U() | ||
|
||
# 1 - 1 subject outputs | ||
pipeline.subject_list = ['001'] | ||
helpers.test_pipeline_outputs(pipeline, [0, 4*1*2*4, 4*2*1 + 2*1, 6*2*2 + 3*2, 18]) | ||
|
||
# 2 - 4 subjects outputs | ||
pipeline.subject_list = ['001', '002', '003', '004'] | ||
helpers.test_pipeline_outputs(pipeline, [0, 4*4*2*4, 4*2*4 + 2*4, 6*2*2 + 3*2, 18]) | ||
|
||
@staticmethod | ||
@mark.unit_test | ||
def test_subject_information(): | ||
""" Test the get_subject_information method """ | ||
|
||
# Get test files | ||
test_file = join(Configuration()['directories']['test_data'], 'pipelines', 'events.tsv') | ||
|
||
# Prepare several scenarii | ||
info_missed = PipelineTeamO21U.get_subject_information(test_file) | ||
|
||
# Compare bunches to expected | ||
bunch = info_missed[0] | ||
assert isinstance(bunch, Bunch) | ||
assert bunch.conditions == ['trial', 'gain', 'loss'] | ||
helpers.compare_float_2d_arrays(bunch.onsets, [ | ||
[4.071, 11.834, 19.535, 27.535, 36.435], | ||
[4.071, 11.834, 19.535, 27.535, 36.435], | ||
[4.071, 11.834, 19.535, 27.535, 36.435] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.durations, [ | ||
[4.0, 4.0, 4.0, 4.0, 4.0], | ||
[4.0, 4.0, 4.0, 4.0, 4.0], | ||
[4.0, 4.0, 4.0, 4.0, 4.0] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.amplitudes, [ | ||
[1.0, 1.0, 1.0, 1.0, 1.0], | ||
[14.0, 34.0, 38.0, 10.0, 16.0], | ||
[6.0, 14.0, 19.0, 15.0, 17.0] | ||
]) | ||
|
||
@staticmethod | ||
@mark.unit_test | ||
def test_confounds_file(temporary_data_dir): | ||
""" Test the get_confounds_file method """ | ||
|
||
# Get input and reference output file | ||
confounds_file = abspath(join( | ||
Configuration()['directories']['test_data'], 'pipelines', 'confounds.tsv')) | ||
reference_file = abspath(join( | ||
Configuration()['directories']['test_data'], | ||
'pipelines', 'team_O21U', 'confounds.tsv')) | ||
|
||
# Create new confounds file | ||
confounds_node = Node(Function( | ||
input_names = ['filepath', 'subject_id', 'run_id'], | ||
output_names = ['confounds_file'], | ||
function = PipelineTeamO21U.get_confounds_file), | ||
name = 'confounds_node') | ||
confounds_node.base_dir = temporary_data_dir | ||
confounds_node.inputs.filepath = confounds_file | ||
confounds_node.inputs.subject_id = 'sid' | ||
confounds_node.inputs.run_id = 'rid' | ||
confounds_node.run() | ||
|
||
# Check confounds file was created | ||
created_confounds_file = abspath(join( | ||
temporary_data_dir, confounds_node.name, 'confounds_file_sub-sid_run-rid.tsv')) | ||
assert exists(created_confounds_file) | ||
|
||
# Check contents | ||
assert cmp(reference_file, created_confounds_file) | ||
|
||
@staticmethod | ||
@mark.pipeline_test | ||
def test_execution(): | ||
""" Test the execution of a PipelineTeamO21U and compare results """ | ||
helpers.test_pipeline_evaluation('O21U') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/python | ||
# coding: utf-8 | ||
|
||
""" Tests of the 'narps_open.pipelines.team_O6R6' module. | ||
Launch this test with PyTest | ||
Usage: | ||
====== | ||
pytest -q test_team_O6R6.py | ||
pytest -q test_team_O6R6.py -k <selected_test> | ||
""" | ||
from os.path import join, exists, abspath | ||
from filecmp import cmp | ||
|
||
from pytest import helpers, mark | ||
from nipype import Workflow, Node, Function | ||
from nipype.interfaces.base import Bunch | ||
|
||
from narps_open.utils.configuration import Configuration | ||
from narps_open.pipelines.team_O6R6 import PipelineTeamO6R6 | ||
|
||
class TestPipelinesTeamO6R6: | ||
""" A class that contains all the unit tests for the PipelineTeamO6R6 class.""" | ||
|
||
@staticmethod | ||
@mark.unit_test | ||
def test_create(): | ||
""" Test the creation of a PipelineTeamO6R6 object """ | ||
|
||
pipeline = PipelineTeamO6R6() | ||
|
||
# 1 - check the parameters | ||
assert pipeline.team_id == 'O6R6' | ||
|
||
# 2 - check workflows | ||
assert pipeline.get_preprocessing() is None | ||
assert isinstance(pipeline.get_run_level_analysis(), 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 PipelineTeamO6R6 object """ | ||
|
||
pipeline = PipelineTeamO6R6() | ||
|
||
# 1 - 1 subject outputs | ||
pipeline.subject_list = ['001'] | ||
helpers.test_pipeline_outputs(pipeline, [0, 2*1*4*4, 2*4*1 + 2*1, 6*2*2 + 3*2, 18]) | ||
|
||
# 2 - 4 subjects outputs | ||
pipeline.subject_list = ['001', '002', '003', '004'] | ||
helpers.test_pipeline_outputs(pipeline, [0, 2*4*4*4, 2*4*4 + 2*4, 6*2*2 + 3*2, 18]) | ||
|
||
@staticmethod | ||
@mark.unit_test | ||
def test_subject_information(): | ||
""" Test the get_subject_information method """ | ||
|
||
# Get test files | ||
test_file = join(Configuration()['directories']['test_data'], 'pipelines', 'events.tsv') | ||
|
||
# Prepare several scenarii | ||
info_ei = PipelineTeamO6R6.get_subject_information(test_file, 'equalIndifference') | ||
info_er = PipelineTeamO6R6.get_subject_information(test_file, 'equalRange') | ||
|
||
# Compare bunches to expected | ||
bunch = info_ei[0] | ||
assert isinstance(bunch, Bunch) | ||
assert bunch.conditions == ['trial', 'gain_trial', 'loss_trial'] | ||
helpers.compare_float_2d_arrays(bunch.onsets, [ | ||
[4.071, 11.834, 27.535, 36.435], | ||
[4.071, 11.834], | ||
[27.535, 36.435] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.durations, [ | ||
[2.388, 2.289, 2.08, 2.288], | ||
[2.388, 2.289], | ||
[2.08, 2.288] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.amplitudes, [ | ||
[1.0, 1.0, 1.0, 1.0], | ||
[3.0, 13.0], | ||
[3.5, 4.5] | ||
]) | ||
|
||
# Compare bunches to expected | ||
bunch = info_er[0] | ||
assert isinstance(bunch, Bunch) | ||
assert bunch.conditions == ['trial', 'gain_trial', 'loss_trial'] | ||
helpers.compare_float_2d_arrays(bunch.onsets, [ | ||
[4.071, 11.834, 27.535, 36.435], | ||
[4.071, 11.834], | ||
[27.535, 36.435] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.durations, [ | ||
[2.388, 2.289, 2.08, 2.288], | ||
[2.388, 2.289], | ||
[2.08, 2.288] | ||
]) | ||
helpers.compare_float_2d_arrays(bunch.amplitudes, [ | ||
[1.0, 1.0, 1.0, 1.0], | ||
[10.0, 30.0], | ||
[11.0, 13.0] | ||
]) | ||
|
||
@staticmethod | ||
@mark.pipeline_test | ||
def test_execution(): | ||
""" Test the execution of a PipelineTeamO6R6 and compare results """ | ||
helpers.test_pipeline_evaluation('O6R6') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
0.0 0.0 0.0 0.0 0.0 -0.0 0.0 | ||
0.1352790093099999 -0.00996895 -0.0313444 -3.00931e-06 0.00132687 -0.000384193 -0.00016819 | ||
0.12437666391 -2.56954e-05 -0.00923735 0.0549667 0.000997278 -0.00019745 -0.000398988 |