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 0dda6cc commit 4722eb0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 6 additions & 5 deletions narps_open/pipelines/team_4SZ2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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']]
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions tests/pipelines/test_team_4SZ2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4722eb0

Please sign in to comment.