Skip to content

Commit

Permalink
Mask names
Browse files Browse the repository at this point in the history
  • Loading branch information
bclenet committed Feb 7, 2024
1 parent 2156ff0 commit 84a823e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 16 additions & 10 deletions narps_open/pipelines/team_51PW.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from narps_open.data.task import TaskInformation
from narps_open.data.participants import get_group
from narps_open.core.common import (
remove_file, list_intersection, elements_in_string, clean_list
list_intersection, elements_in_string, clean_list
)
from narps_open.core.interfaces import InterfaceFactory
from narps_open.utils.configuration import Configuration
Expand Down Expand Up @@ -148,7 +148,8 @@ def get_preprocessing(self):
# Add connections
preprocessing.connect([
(data_sink, remove_intensity_normalization, [('out_file', '_')]),
(intensity_normalization, remove_intensity_normalization, [('out_file', 'file_name')]),
(intensity_normalization, remove_intensity_normalization, [
('out_file', 'file_name')]),
(data_sink, remove_smooth, [('out_file', '_')]),
(smoothing, remove_smooth, [('smoothed_file', 'file_name')]),
])
Expand Down Expand Up @@ -308,7 +309,7 @@ def get_run_level_analysis(self):
# ExtractROI Node - Exclude the first 2 time points/scans for each run
exclude_time_points = Node(ExtractROI(), name = 'exclude_time_points')
exclude_time_points.inputs.t_min = 2
exclude_time_points.inputs.t_size = 451 # TODO nb_time_points - 2
exclude_time_points.inputs.t_size = 451 # number of time points - 2

# Function Node get_subject_information - Get subject information from event files
subject_information = Node(Function(
Expand Down Expand Up @@ -450,10 +451,9 @@ def get_subject_level_analysis(self):
'_run_id_*_subject_id_{subject_id}', 'results', 'cope{contrast_id}.nii.gz'),
'varcopes' : join(self.directories.output_dir, 'run_level_analysis',
'_run_id_*_subject_id_{subject_id}', 'results', 'varcope{contrast_id}.nii.gz'),
'masks' : join(self.directories.output_dir, 'preprocessing',
'_run_id_*_subject_id_{subject_id}',
'sub-{subject_id}_task-MGT_run-*_bold_brain_mask_flirt_wtsimt.nii.gz')
# 'sub-{subject_id}_task-MGT_run-{run_id}_bold_space-MNI152NLin2009cAsym_preproc_maths_smooth.nii.gz'
'masks' : join('derivatives', 'fmriprep', 'sub-{subject_id}', 'func',
'sub-{subject_id}_task-MGT_run-*_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz'
)
}
select_files = Node(SelectFiles(templates), name = 'select_files')
select_files.inputs.base_directory = self.directories.dataset_dir
Expand Down Expand Up @@ -534,10 +534,16 @@ def get_subject_level_outputs(self):
for parameter_values in parameter_sets]

# Handle mask file
parameters = {
'contrast_id' : self.contrast_list,
'subject_id' : self.subject_list
}
parameter_sets = product(*parameters.values())
template = join(self.directories.output_dir,
'subject_level_analysis', '_contrast_id_{contrast_id}_subject_id_{subject_id}',
'sub-{subject_id}_task-MGT_run-01_bold_space-MNI152NLin2009cAsym_preproc_brain_mask.nii.gz') # TODO check actual file name
return_list += [template.format(subject_id = s) for s in self.subject_list]
'sub-{subject_id}_task-MGT_run-01_bold_space-MNI152NLin2009cAsym_brainmask_maths.nii.gz')
return_list += [template.format(**dict(zip(parameters.keys(), parameter_values)))\
for parameter_values in parameter_sets]

return return_list

Expand Down Expand Up @@ -624,7 +630,7 @@ def get_group_level_analysis_sub_workflow(self, method):
'_contrast_id_{contrast_id}_subject_id_*', 'varcope1.nii.gz'),
'masks' : join(self.directories.output_dir, 'subject_level_analysis',
'_contrast_id_{contrast_id}_subject_id_*',
'sub-*_task-MGT_run-*_bold_brain_mask_flirt_wtsimt_maths.nii.gz')
'sub-*_task-MGT_run-01_bold_space-MNI152NLin2009cAsym_brainmask_maths.nii.gz')
}
select_files = Node(SelectFiles(templates), name = 'select_files')
select_files.inputs.base_directory = self.directories.dataset_dir
Expand Down
4 changes: 2 additions & 2 deletions tests/pipelines/test_team_51PW.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def test_outputs():
pipeline = PipelineTeam51PW()
# 1 - 1 subject outputs
pipeline.subject_list = ['001']
helpers.test_pipeline_outputs(pipeline, [1*4, 4 + 4*2*4, 4*2, 8*2*2 + 4*2, 18])
helpers.test_pipeline_outputs(pipeline, [1*4, 4*2*4, 4*2 + 1*2, 8*2*2 + 4*2, 18])

# 2 - 4 subjects outputs
pipeline.subject_list = ['001', '002', '003', '004']
helpers.test_pipeline_outputs(pipeline, [4*1*4, (4 + 4*2*4)*4, 4*2*4, 8*2*2 + 4*2, 18])
helpers.test_pipeline_outputs(pipeline, [4*1*4, 4*2*4*4, 4*2*4 + 1*2*4, 8*2*2 + 4*2, 18])

@staticmethod
@mark.unit_test
Expand Down

0 comments on commit 84a823e

Please sign in to comment.