Skip to content

Commit

Permalink
Adding nuisance regressors in the group level analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
bclenet committed Jun 19, 2024
1 parent 40b226f commit 39b9b8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 8 additions & 8 deletions narps_open/pipelines/team_4SZ2.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ def get_group_level_regressors(subject_list: list, run_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 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]
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']]
Expand All @@ -242,10 +244,7 @@ def get_group_level_regressors(subject_list: list, run_list: list):
gender = [1 if i == 'F' else 0 for i in genders for _ in run_list]
)

# Create groups outputs
groups = [1 if i == 1 else 2 for i in equal_range_regressor]

return regressors, groups
return regressors

def get_group_level_analysis(self):
"""
Expand Down Expand Up @@ -351,12 +350,13 @@ def get_group_level_analysis(self):
group_level.connect(merge_masks, 'merged_file', mask_intersection, 'in_file')

# Get regressors for the group level analysis
regressors, groups = self.get_group_level_regressors(self.subject_list, self.run_list)
regressors = self.get_group_level_regressors(self.subject_list, self.run_list)

# MultipleRegressDesign Node - Specify model
# NB : no "groups" input is needed because equalRange and equalIndifference groups
# are already modeled in the design
specify_model = Node(MultipleRegressDesign(), name = 'specify_model')
specify_model.inputs.regressors = regressors
specify_model.inputs.groups = groups
specify_model.inputs.contrasts = self.group_level_contrasts

# FLAMEO Node - Estimate model
Expand Down
3 changes: 1 addition & 2 deletions tests/pipelines/test_team_4SZ2.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_subject_information():
def test_get_group_level_regressors():
""" Test the get_group_level_regressors method """

regressors, groups = PipelineTeam4SZ2.get_group_level_regressors(
regressors = PipelineTeam4SZ2.get_group_level_regressors(
['001', '002', '003', '004'],
['01', '02'])

Expand All @@ -98,7 +98,6 @@ def test_get_group_level_regressors():
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
Expand Down

0 comments on commit 39b9b8c

Please sign in to comment.