@@ -138,25 +138,49 @@ def get_preprocessing(self):
138138 median_value , ('out_stat' , get_intensity_normalization_scale ),
139139 normalize_intensity , 'op_string' )
140140
141- # TODO : temporal filtering ???
141+ # ImageMaths - Generate a mean functional image from the scaled data
142+ mean_func_2 = Node (ImageMaths (), name = 'mean_func_2' )
143+ mean_func_2 .inputs .op_string = '-Tmean'
144+ preprocessing .connect (normalize_intensity , 'out_file' , mean_func_2 , 'in_file' )
145+
146+ # Function get_high_pass_filter_command - Build command line for temporal highpass filter
147+ def get_high_pass_filter_command (in_file , repetition_time , high_pass_filter_cutoff ):
148+ """ Create command line for high pass filtering using image maths """
149+ return f'-bptf { high_pass_filter_cutoff / (2.0 * repetition_time )} -1 -add { in_file } '
150+
151+ high_pass_command = Node (Function (
152+ function = get_high_pass_filter_command ,
153+ input_names = ['in_file' , 'repetition_time' , 'high_pass_filter_cutoff' ],
154+ output_names = ['command' ]
155+ ), name = 'high_pass_command' )
156+ high_pass_command .inputs .high_pass_filter_cutoff = 100.0 #seconds
157+ high_pass_command .inputs .repetition_time = TaskInformation ()['RepetitionTime' ]
158+ preprocessing .connect (mean_func_2 , 'out_file' , high_pass_command , 'in_file' )
159+
160+ # ImageMaths - Perform temporal highpass filtering on the data
161+ high_pass_filter = Node (ImageMaths (), name = 'high_pass_filter' )
162+ high_pass_filter .inputs .suffix = '_tempfilt'
163+ preprocessing .connect (normalize_intensity , 'out_file' , high_pass_filter , 'in_file' )
164+ preprocessing .connect (high_pass_command , 'command' , high_pass_filter , 'op_string' )
142165
143166 # DataSink Node - store the wanted results in the wanted repository
144167 data_sink = Node (DataSink (), name = 'data_sink' )
145168 data_sink .inputs .base_directory = self .directories .output_dir
146169 preprocessing .connect (
147- normalize_intensity , 'out_file' , data_sink , 'preprocessing.@normalized_file ' )
170+ high_pass_filter , 'out_file' , data_sink , 'preprocessing.@filtered_file ' )
148171
149172 # Remove large files, if requested
150173 if Configuration ()['pipelines' ]['remove_unused_data' ]:
151174
152175 # Merge Node - Merge func file names to be removed after datasink node is performed
153- merge_removable_files = Node (Merge (5 ), name = 'merge_removable_files' )
176+ merge_removable_files = Node (Merge (6 ), name = 'merge_removable_files' )
154177 merge_removable_files .inputs .ravel_inputs = True
155178 preprocessing .connect (func_to_float , 'out_file' , merge_removable_files , 'in1' )
156179 preprocessing .connect (mask_func , 'out_file' , merge_removable_files , 'in2' )
157180 preprocessing .connect (mean_func , 'out_file' , merge_removable_files , 'in3' )
158181 preprocessing .connect (smooth_func , 'smoothed_file' , merge_removable_files , 'in4' )
159182 preprocessing .connect (normalize_intensity , 'out_file' , merge_removable_files , 'in5' )
183+ preprocessing .connect (high_pass_filter , 'out_file' , merge_removable_files , 'in6' )
160184
161185 # Function Nodes remove_files - Remove sizeable func files once they aren't needed
162186 remove_dirs = MapNode (Function (
@@ -181,7 +205,7 @@ def get_preprocessing_outputs(self):
181205 template = join (
182206 self .directories .output_dir , 'preprocessing' ,
183207 '_run_id_{run_id}_subject_id_{subject_id}' ,
184- 'sub-{subject_id}_task-MGT_run-{run_id}_bold_space-MNI152NLin2009cAsym_preproc_dtype_thresh_smooth_intnorm .nii.gz' )
208+ 'sub-{subject_id}_task-MGT_run-{run_id}_bold_space-MNI152NLin2009cAsym_preproc_dtype_thresh_smooth_intnorm_tempfilt .nii.gz' )
185209
186210 return [template .format (** dict (zip (parameters .keys (), parameter_values )))\
187211 for parameter_values in parameter_sets ]
@@ -286,7 +310,7 @@ def get_run_level_analysis(self):
286310 templates = {
287311 'func' : join (self .directories .output_dir ,
288312 'preprocessing' , '_run_id_{run_id}_subject_id_{subject_id}' ,
289- 'sub-{subject_id}_task-MGT_run-{run_id}_bold_space-MNI152NLin2009cAsym_preproc_dtype_thresh_smooth_intnorm .nii.gz' ),
313+ 'sub-{subject_id}_task-MGT_run-{run_id}_bold_space-MNI152NLin2009cAsym_preproc_dtype_thresh_smooth_intnorm_tempfilt .nii.gz' ),
290314 'mask' : join ('derivatives' , 'fmriprep' , 'sub-{subject_id}' , 'func' ,
291315 'sub-{subject_id}_task-MGT_run-{run_id}_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz' ),
292316 'events' : join ('sub-{subject_id}' , 'func' ,
0 commit comments