From 299b5262bf7d9b6ce01fd76592cfed50827c1bb5 Mon Sep 17 00:00:00 2001 From: elodiegermani1 Date: Tue, 15 Aug 2023 10:07:48 -0400 Subject: [PATCH] Start reproduction of pipeline 43FJ --- .../{team_43FJ_debug.py => team_43FJ.py} | 0 tests/pipelines/test_team_43FJ.py | 93 +++++++++++++++++++ 2 files changed, 93 insertions(+) rename narps_open/pipelines/{team_43FJ_debug.py => team_43FJ.py} (100%) create mode 100644 tests/pipelines/test_team_43FJ.py diff --git a/narps_open/pipelines/team_43FJ_debug.py b/narps_open/pipelines/team_43FJ.py similarity index 100% rename from narps_open/pipelines/team_43FJ_debug.py rename to narps_open/pipelines/team_43FJ.py diff --git a/tests/pipelines/test_team_43FJ.py b/tests/pipelines/test_team_43FJ.py new file mode 100644 index 00000000..f343777a --- /dev/null +++ b/tests/pipelines/test_team_43FJ.py @@ -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 +""" + +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