1616 DARTELNorm2MNI , FieldMap , Threshold
1717 )
1818from nipype .interfaces .spm .base import Info as SPMInfo
19- from nipype .interfaces .fsl import ExtractROI
2019from nipype .algorithms .modelgen import SpecifySPMModel
2120from niflow .nipype1 .workflows .fmri .spm import create_DARTEL_template
2221
2625from narps_open .core .common import (
2726 remove_parent_directory , list_intersection , elements_in_string , clean_list
2827 )
28+ from narps_open .core .image import get_image_timepoints
2929from narps_open .utils .configuration import Configuration
3030
3131class PipelineTeam98BT (Pipeline ):
@@ -264,10 +264,13 @@ def get_preprocessing_sub_workflow(self):
264264 preprocessing .connect (slice_timing , 'timecorrected_files' , motion_correction , 'in_files' )
265265
266266 # Intrasubject coregistration
267- extract_first = Node (ExtractROI (), name = 'extract_first' )
268- extract_first .inputs .t_min = 1
269- extract_first .inputs .t_size = 1
270- extract_first .inputs .output_type = 'NIFTI'
267+ extract_first = Node (Function (
268+ function = get_image_timepoints ,
269+ input_names = ['in_file' , 'start_time_point' , 'end_time_point' ],
270+ output_names = ['roi_file' ]
271+ ), name = 'extract_first' )
272+ extract_first .inputs .start_time_point = 1
273+ extract_first .inputs .end_time_point = 1
271274 preprocessing .connect (
272275 motion_correction , 'realigned_unwarped_files' , extract_first , 'in_file' )
273276
@@ -421,9 +424,9 @@ def get_parameters_file(
421424 from os import makedirs
422425 from os .path import join
423426 from nibabel import load
427+ from nibabel .processing import resample_from_to
424428 from numpy import mean
425- from pandas import read_table
426- from nilearn .image import iter_img , resample_to_img
429+ from pandas import read_csv
427430
428431 # Ignore all future warnings
429432 from warnings import simplefilter
@@ -432,22 +435,23 @@ def get_parameters_file(
432435 simplefilter (action = 'ignore' , category = RuntimeWarning )
433436
434437 # Load wc2 file and create a mask out of it
435- wc2 = load (wc2_file )
436- wc2_mask = wc2 .get_fdata () > 0.6
437- wc2_mask = wc2_mask .astype (int )
438+ wm_class_image = load (wc2_file )
439+ wm_mask_data = wm_class_image .get_fdata () > 0.6
440+ wm_mask_data = wm_mask_data .astype (int )
438441
439442 # Compute the mean signal in white matter, for each slice of the functional data
440443 mean_wm = []
441- for current_slice in iter_img (load (func_file )):
442- slice_data = resample_to_img (
443- current_slice , wc2 , interpolation = 'nearest' , clip = True ).get_fdata ()
444+ func_image = load (func_file )
445+ for index in range (func_image .header .get_data_shape ()[3 ]):
446+ resampled_func = resample_from_to (
447+ func_image .slicer [..., index ], wm_class_image , order = 0 , mode = 'nearest' )
448+
444449 # Append mean value of masked data
445- mean_wm .append (mean (slice_data * wc2_mask ))
450+ mean_wm .append (mean (resampled_func . get_fdata () * wm_mask_data ))
446451
447452 # Create new parameters file
448- data_frame = read_table (parameters_file , sep = ' ' , header = None )
453+ data_frame = read_csv (parameters_file , sep = '\t ' , dtype = str )
449454 data_frame ['Mean_WM' ] = mean_wm
450-
451455 new_parameters_file = join (working_dir , 'parameters_files' ,
452456 f'parameters_file_sub-{ subject_id } _run-{ run_id } .tsv' )
453457
0 commit comments