diff --git a/narps_open/pipelines/team_4SZ2.py b/narps_open/pipelines/team_4SZ2.py index 05e4a753..738c449a 100644 --- a/narps_open/pipelines/team_4SZ2.py +++ b/narps_open/pipelines/team_4SZ2.py @@ -205,12 +205,13 @@ def get_subject_level_analysis(self): return None @staticmethod - def get_group_level_regressors(subject_list: list): + def get_group_level_regressors(subject_list: list, run_list: list): """ Create dictionary of regressors for two sample t-test group analysis. Parameters: - subject_list: ids of subject for which to do the analysis + - run_list: ids of runs for which to do the analysis Returns: - regressors, dict: containing named lists of regressors. @@ -222,8 +223,8 @@ def get_group_level_regressors(subject_list: list): # * 0 otherwise equal_range_group = get_group('equalRange') equal_indif_group = get_group('equalIndifference') - equal_range_regressor = [1 if s in equal_range_group else 0 for s in subject_list] - equal_indif_regressor = [1 if s in equal_indif_group else 0 for s in subject_list] + equal_range_regressor = [1 if s in equal_range_group else 0 for s in subject_list for _ in run_list] + equal_indif_regressor = [1 if s in equal_indif_group else 0 for s in subject_list for _ in run_list] # Get gender and age of participants participants_data = get_participants_information()[['participant_id', 'gender', 'age']] @@ -237,8 +238,8 @@ def get_group_level_regressors(subject_list: list): regressors = dict( equalIndifference = equal_indif_regressor, equalRange = equal_range_regressor, - age = [int(a) for a in ages], - gender = [1 if i == 'F' else 0 for i in genders] + age = [int(a) for a in ages for _ in run_list], + gender = [1 if i == 'F' else 0 for i in genders for _ in run_list] ) # Create groups outputs diff --git a/tests/pipelines/test_team_4SZ2.py b/tests/pipelines/test_team_4SZ2.py index 8b025db0..69a581be 100644 --- a/tests/pipelines/test_team_4SZ2.py +++ b/tests/pipelines/test_team_4SZ2.py @@ -88,17 +88,17 @@ def test_subject_information(): def test_get_group_level_regressors(): """ Test the get_group_level_regressors method """ - regressors, groups = PipelineTeam4SZ2.get_group_level_regressors(['001', '002', '003', '004']) + regressors, groups = PipelineTeam4SZ2.get_group_level_regressors( + ['001', '002', '003', '004'], + ['01', '02']) for k1, k2 in zip(regressors.keys(), ['equalIndifference', 'equalRange', 'age', 'gender']): assert k1 == k2 - assert regressors['equalIndifference'] == [1, 0, 1, 0] - assert regressors['equalRange'] == [0, 1, 0, 1] - print(regressors['age']) - print(regressors['gender']) - assert regressors['age'] == [24, 25, 27, 25] - assert regressors['gender'] == [0, 0, 1, 0] - assert groups == [2, 1, 2, 1] + assert regressors['equalIndifference'] == [1, 1, 0, 0, 1, 1, 0, 0] + assert regressors['equalRange'] == [0, 0, 1, 1, 0, 0, 1, 1] + assert regressors['age'] == [24, 24, 25, 25, 27, 27, 25, 25] + assert regressors['gender'] == [0, 0, 0, 0, 1, 1, 0, 0] + assert groups == [2, 2, 1, 1, 2, 2, 1, 1] @staticmethod @mark.pipeline_test