From eb7cca4ca1c70b674184ffc22d21e84a008bda70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Cl=C3=A9net?= Date: Wed, 29 May 2024 16:10:26 +0200 Subject: [PATCH] Simplifying select files [skip ci] --- narps_open/pipelines/team_0ED6.py | 48 ++++++++++++------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/narps_open/pipelines/team_0ED6.py b/narps_open/pipelines/team_0ED6.py index 18ba61b4..a379cb14 100644 --- a/narps_open/pipelines/team_0ED6.py +++ b/narps_open/pipelines/team_0ED6.py @@ -58,41 +58,29 @@ def get_preprocessing(self): base_dir = self.directories.working_dir, name = 'preprocessing') - # IDENTITY INTERFACE - To iterate on subjects - information_source_subjects = Node(IdentityInterface( - fields = ['subject_id']), - name = 'information_source_subjects') - information_source_subjects.iterables = [('subject_id', self.subject_list)] - - # IDENTITY INTERFACE - To iterate on runs - information_source_runs = Node(IdentityInterface( - fields = ['run_id']), - name = 'information_source_runs') - information_source_runs.iterables = [('run_id', self.run_list)] + # IDENTITY INTERFACE - To iterate on subjects and runs + information_source = Node(IdentityInterface( + fields = ['subject_id', 'run_id']), + name = 'information_source') + information_source.iterables = [ + ('subject_id', self.subject_list), + ('run_id', self.run_list) + ] - # SELECT FILES - Select subject_related files + # SELECT FILES - Select input files templates = { 'anat' : join('sub-{subject_id}', 'anat', 'sub-{subject_id}_T1w.nii.gz'), 'magnitude' : join('sub-{subject_id}', 'fmap', 'sub-{subject_id}_magnitude1.nii.gz'), 'phase' : join('sub-{subject_id}', 'fmap', 'sub-{subject_id}_phasediff.nii.gz'), - } - select_subject_files = Node(SelectFiles(templates), name = 'select_subject_files') - select_subject_files.inputs.base_directory = self.directories.dataset_dir - preprocessing.connect( - information_source_subjects, 'subject_id', select_subject_files, 'subject_id') - - # SELECT FILES - Select run related files - templates = { 'func' : join('sub-{subject_id}', 'func', 'sub-{subject_id}_task-MGT_run-{run_id}_bold.nii.gz'), 'sbref' : join('sub-{subject_id}', 'func', 'sub-{subject_id}_task-MGT_run-{run_id}_sbref.nii.gz') } - select_run_files = Node(SelectFiles(templates), name = 'select_run_files') - select_run_files.inputs.base_directory = self.directories.dataset_dir - preprocessing.connect(information_source_runs, 'run_id', select_run_files, 'run_id') - preprocessing.connect( - information_source_subjects, 'subject_id', select_run_files, 'subject_id') + select_files = Node(SelectFiles(templates), name = 'select_files') + select_files.inputs.base_directory = self.directories.dataset_dir + preprocessing.connect(information_source, 'subject_id', select_files, 'subject_id') + preprocessing.connect(information_source, 'run_id', select_files, 'run_id') # GUNZIP - gunzip files because SPM do not use .nii.gz files gunzip_anat = Node(Gunzip(), name = 'gunzip_anat') @@ -100,11 +88,11 @@ def get_preprocessing(self): gunzip_sbref = Node(Gunzip(), name = 'gunzip_sbref') gunzip_magnitude = Node(Gunzip(), name = 'gunzip_magnitude') gunzip_phase = Node(Gunzip(), name = 'gunzip_phase') - preprocessing.connect(select_subject_files, 'anat', gunzip_anat, 'in_file') - preprocessing.connect(select_run_files, 'func', gunzip_func, 'in_file') - preprocessing.connect(select_run_files, 'sbref', gunzip_sbref, 'in_file') - preprocessing.connect(select_subject_files, 'magnitude', gunzip_magnitude, 'in_file') - preprocessing.connect(select_subject_files, 'phase', gunzip_phase, 'in_file') + preprocessing.connect(select_files, 'anat', gunzip_anat, 'in_file') + preprocessing.connect(select_files, 'func', gunzip_func, 'in_file') + preprocessing.connect(select_files, 'sbref', gunzip_sbref, 'in_file') + preprocessing.connect(select_files, 'magnitude', gunzip_magnitude, 'in_file') + preprocessing.connect(select_files, 'phase', gunzip_phase, 'in_file') # FIELD MAP - Compute a voxel displacement map from magnitude and phase data fieldmap = Node(FieldMap(), name = 'fieldmap')