def create_lemon_resting(subject, working_dir, data_dir, freesurfer_dir, out_dir, vol_to_remove, TR, epi_resolution, highpass, lowpass, echo_space, te_diff, pe_dir, standard_brain, standard_brain_resampled, standard_brain_mask, standard_brain_mask_resampled, fwhm_smoothing): # set fsl output type to nii.gz fsl.FSLCommand.set_default_output_type('NIFTI_GZ') # main workflow func_preproc = Workflow(name='lemon_resting') func_preproc.base_dir = working_dir func_preproc.config['execution'][ 'crashdump_dir'] = func_preproc.base_dir + "/crash_files" # select files templates = { 'func': 'func/EPI_t2.nii', 'fmap_phase': 'unwarp/B0_ph.nii', 'fmap_mag': 'unwarp/B0_mag.nii', 'anat_head': 'preprocessed/mod/anat/T1.nii.gz', #either with mod or without 'anat_brain': 'preprocessed/mod/anat/brain.nii.gz', #new version with brain_extraction from freesurfer #T1_brain_brain.nii.gz', 'brain_mask': 'preprocessed/mod/anat/T1_brain_mask.nii.gz', #T1_brain_brain_mask.nii.gz', 'ants_affine': 'preprocessed/mod/anat/transforms2mni/transform0GenericAffine.mat', 'ants_warp': 'preprocessed/mod/anat/transforms2mni/transform1Warp.nii.gz' } selectfiles = Node(nio.SelectFiles(templates, base_directory=data_dir), name="selectfiles") # node to remove first volumes remove_vol = Node(util.Function(input_names=['in_file', 't_min'], output_names=["out_file"], function=strip_rois_func), name='remove_vol') remove_vol.inputs.t_min = vol_to_remove # workflow for motion correction moco = create_moco_pipeline() # workflow for fieldmap correction and coregistration fmap_coreg = create_fmap_coreg_pipeline() fmap_coreg.inputs.inputnode.fs_subjects_dir = freesurfer_dir fmap_coreg.inputs.inputnode.fs_subject_id = subject fmap_coreg.inputs.inputnode.echo_space = echo_space fmap_coreg.inputs.inputnode.te_diff = te_diff fmap_coreg.inputs.inputnode.pe_dir = pe_dir # workflow for applying transformations to timeseries transform_ts = create_transform_pipeline() transform_ts.inputs.inputnode.resolution = epi_resolution #workflow to convert signal into percent signal change normalize = create_normalize_pipeline() normalize.inputs.inputnode.tr = TR #workflow to transform timeseries to MNI ants_registration = create_ants_registration_pipeline() ants_registration.inputs.inputnode.ref = standard_brain_resampled #workflow to smooth smoothing = create_smoothing_pipeline() smoothing.inputs.inputnode.fwhm = fwhm_smoothing #workflow to correct slice timing slicetiming = create_slice_timing_pipeline() #visualize registration results visualize = create_visualize_pipeline() visualize.inputs.inputnode.mni_template = standard_brain_resampled #sink to store files sink = Node(nio.DataSink( parameterization=False, base_directory=out_dir, substitutions=[ ('fmap_phase_fslprepared', 'fieldmap'), ('fieldmap_fslprepared_fieldmap_unmasked_vsm', 'shiftmap'), ('plot.rest_coregistered', 'outlier_plot'), ('filter_motion_comp_norm_compcor_art_dmotion', 'nuissance_matrix'), ('rest_realigned.nii.gz_abs.rms', 'rest_realigned_abs.rms'), ('rest_realigned.nii.gz.par', 'rest_realigned.par'), ('rest_realigned.nii.gz_rel.rms', 'rest_realigned_rel.rms'), ('rest_realigned.nii.gz_abs_disp', 'abs_displacement_plot'), ('rest_realigned.nii.gz_rel_disp', 'rel_displacment_plot'), ('art.rest_coregistered_outliers', 'outliers'), ('global_intensity.rest_coregistered', 'global_intensity'), ('norm.rest_coregistered', 'composite_norm'), ('stats.rest_coregistered', 'stats'), ('rest_denoised_bandpassed_norm.nii.gz', 'rest_preprocessed.nii.gz'), ('rest_denoised_bandpassed_norm_trans.nii.gz', 'rest_mni.nii.gz'), ('rest2anat_masked_st_norm_trans_smooth.nii', 'rest_mni_smoothed.nii') ]), name='sink') # connections func_preproc.connect([ #remove the first volumes (selectfiles, remove_vol, [('func', 'in_file')]), #align volumes and motion correction (remove_vol, moco, [('out_file', 'inputnode.epi')]), #prepare field map (selectfiles, fmap_coreg, [('fmap_phase', 'inputnode.phase'), ('fmap_mag', 'inputnode.mag'), ('anat_head', 'inputnode.anat_head'), ('anat_brain', 'inputnode.anat_brain')]), (moco, fmap_coreg, [('outputnode.epi_mean', 'inputnode.epi_mean')]), (remove_vol, transform_ts, [('out_file', 'inputnode.orig_ts')]), (selectfiles, transform_ts, [('anat_head', 'inputnode.anat_head')]), (selectfiles, transform_ts, [('brain_mask', 'inputnode.brain_mask')]), (moco, transform_ts, [('outputnode.mat_moco', 'inputnode.mat_moco')]), (fmap_coreg, transform_ts, [('outputnode.fmap_fullwarp', 'inputnode.fullwarp')]), ##add slice time correction after applying motion realignement + unwarping (transform_ts, slicetiming, [('outputnode.trans_ts_masked', 'inputnode.ts')]), (slicetiming, normalize, [('outputnode.ts_slicetcorrected', 'inputnode.epi_coreg')]), (normalize, ants_registration, [('outputnode.normalized_file', 'inputnode.denoised_ts')]), #registration to MNI space (selectfiles, ants_registration, [('ants_affine', 'inputnode.ants_affine')]), (selectfiles, ants_registration, [('ants_warp', 'inputnode.ants_warp') ]), (ants_registration, smoothing, [('outputnode.ants_reg_ts', 'inputnode.ts_transformed')]), (smoothing, visualize, [('outputnode.ts_smoothed', 'inputnode.ts_transformed')]), ##all the output ( moco, sink, [ #('outputnode.epi_moco', 'realign.@realigned_ts'), ('outputnode.par_moco', 'realign.@par'), ('outputnode.rms_moco', 'realign.@rms'), ('outputnode.mat_moco', 'realign.MAT.@mat'), ('outputnode.epi_mean', 'realign.@mean'), ('outputnode.rotplot', 'realign.plots.@rotplot'), ('outputnode.transplot', 'realign.plots.@transplot'), ('outputnode.dispplots', 'realign.plots.@dispplots'), ('outputnode.tsnr_file', 'realign.@tsnr') ]), ( fmap_coreg, sink, [ ('outputnode.fmap', 'coregister.transforms2anat.@fmap'), #('outputnode.unwarpfield_epi2fmap', 'coregister.@unwarpfield_epi2fmap'), ('outputnode.unwarped_mean_epi2fmap', 'coregister.@unwarped_mean_epi2fmap'), ('outputnode.epi2fmap', 'coregister.@epi2fmap'), #('outputnode.shiftmap', 'coregister.@shiftmap'), ('outputnode.fmap_fullwarp', 'coregister.transforms2anat.@fmap_fullwarp'), ('outputnode.epi2anat', 'coregister.@epi2anat'), ('outputnode.epi2anat_mat', 'coregister.transforms2anat.@epi2anat_mat'), ('outputnode.epi2anat_dat', 'coregister.transforms2anat.@epi2anat_dat'), ('outputnode.epi2anat_mincost', 'coregister.@epi2anat_mincost') ]), ( transform_ts, sink, [ #('outputnode.trans_ts', 'coregister.@full_transform_ts'), ('outputnode.trans_ts_mean', 'coregister.@full_transform_mean'), ('outputnode.resamp_brain', 'coregister.@resamp_brain') ]), (ants_registration, sink, [('outputnode.ants_reg_ts', 'ants.@antsnormalized')]), (smoothing, sink, [('outputnode.ts_smoothed', '@smoothed.FWHM6')]), ]) #func_preproc.write_graph(dotfilename='func_preproc.dot', graph2use='colored', format='pdf', simple_form=True) func_preproc.run()
def create_resting(): # main workflow func_preproc = Workflow(name='resting') inputnode = Node(util.IdentityInterface(fields=[ 'subject_id', 'out_dir', 'freesurfer_dir', 'func', 'rs_mag', 'rs_ph', 'anat_head', 'anat_brain', 'anat_brain_mask', 'wmseg', 'csfseg', 'vol_to_remove', 'TR', 'highpass_freq', 'epi_resolution', 'echo_space', 'te_diff', 'fwhm', 'pe_dir', 'composite_transform', 'standard_brain', 'standard_downsampled' ]), name='inputnode') #Use correct subject ID from long timepoint for bbregister def change_subject_id(subject): import re [subj, ses] = re.split("_", subject) new_subject_id = subject + '.long.' + subj return new_subject_id change_subject_id = Node(util.Function(input_names=["subject"], output_names=["new_subject_id"], function=change_subject_id), name="change_subject_id") outputnode = Node(util.IdentityInterface(fields=[ 'brain', 'brainmask', 'anat2std_transforms', 'std2anat_transforms', 'anat2std', 'anat_head', 'wmseg', 'csfseg', 'wmedge', 'subject_id' ]), name='outputnode') ##PREPROCESSING FOR AROMA (Steps 1 - 7) def merge_if_list(in_file): if type(in_file) == list: import numpy as np import nibabel as nb import os from nipype.utils.filemanip import split_filename nii1 = nb.load(in_file[0]) nii1d = nii1.get_data() nii2 = nb.load(in_file[1]) nii2d = nii2.get_data() x = np.concatenate((nii1d, nii2d), axis=3) new_nii = nb.Nifti1Image(x, nii1.get_affine(), nii1.get_header()) new_nii.set_data_dtype(np.float32) _, base, _ = split_filename(in_file[0]) nb.save(new_nii, base + "_merged.nii.gz") return os.path.abspath(base + "_merged.nii.gz") else: return in_file #if rsfmri is a list -> merge files, otherwise return single list. merge_rs = Node(util.Function(input_names=['in_file'], output_names=["out_file"], function=merge_if_list), name='merge_rs') # node to remove first volumes remove_vol = Node(util.Function(input_names=['in_file', 't_min'], output_names=["out_file"], function=strip_rois_func), name='remove_vol') # workflow for motion correction moco = create_moco_pipeline() # workflow for fieldmap correction and coregistration fmap_coreg = create_fmap_coreg_pipeline() # workflow for applying transformations to timeseries transform_ts = create_transform_pipeline() #mean intensity normalization meanintensnorm = Node(fsl.ImageMaths(op_string='-ing 10000'), name='meanintensnorm') smoothing = create_smoothing_pipeline() # connections func_preproc.connect([ (inputnode, merge_rs, [('func', 'in_file')]), (merge_rs, remove_vol, [('out_file', 'in_file')]), (inputnode, remove_vol, [('vol_to_remove', 't_min')]), (inputnode, moco, [('anat_brain_mask', 'inputnode.brainmask')]), (remove_vol, moco, [('out_file', 'inputnode.epi')]), (inputnode, change_subject_id, [('subject_id', 'subject')]), (change_subject_id, fmap_coreg, [('new_subject_id', 'inputnode.fs_subject_id')]), (inputnode, fmap_coreg, [('rs_mag', 'inputnode.mag'), ('rs_ph', 'inputnode.phase'), ('freesurfer_dir', 'inputnode.fs_subjects_dir'), ('echo_space', 'inputnode.echo_space'), ('te_diff', 'inputnode.te_diff'), ('pe_dir', 'inputnode.pe_dir'), ('anat_head', 'inputnode.anat_head'), ('anat_brain', 'inputnode.anat_brain')]), (moco, fmap_coreg, [('outputnode.epi_mean', 'inputnode.epi_mean')]), (remove_vol, transform_ts, [('out_file', 'inputnode.orig_ts')]), (inputnode, transform_ts, [('anat_head', 'inputnode.anat_head')]), (inputnode, transform_ts, [('anat_brain_mask', 'inputnode.brain_mask') ]), (inputnode, transform_ts, [('epi_resolution', 'inputnode.resolution') ]), (moco, transform_ts, [('outputnode.mat_moco', 'inputnode.mat_moco')]), (fmap_coreg, transform_ts, [('outputnode.fmap_fullwarp', 'inputnode.fullwarp')]), (transform_ts, meanintensnorm, [('outputnode.trans_ts', 'in_file')]), (meanintensnorm, smoothing, [('out_file', 'inputnode.ts_transformed') ]), (inputnode, smoothing, [('fwhm', 'inputnode.fwhm')]) ]) ##CALCULATE TRANSFORM from anatomical to standard space with FSL tools # Anat > Standard # register high-resolution to standard template with non-linear transform # flirt serves as preparation for fnirt) #reorient brain to standard (because Freesurfer space can cause problems) reorient2std = Node(fsl.Reorient2Std(), name="reorient2std") reorient2std_rs = Node(fsl.Reorient2Std(), name="reorient2std_rs") reorient2std_mask = Node(fsl.Reorient2Std(), name="reorient2std_mask") flirt_prep = Node(fsl.FLIRT(cost_func='mutualinfo', interp='trilinear'), name='flirt_prep') flirt_prep.inputs.interp = 'trilinear' flirt_prep.inputs.dof = 12 fnirt = Node(fsl.FNIRT(), name='fnirt') fnirt.inputs.field_file = True fnirt.inputs.fieldcoeff_file = True func_preproc.connect([ (inputnode, reorient2std, [('anat_brain', 'in_file')]), (reorient2std, flirt_prep, [('out_file', 'in_file')]), #(inputnode, flirt_prep, [('anat_brain', 'in_file')]), (inputnode, flirt_prep, [('standard_brain', 'reference')]), (flirt_prep, fnirt, [('out_matrix_file', 'affine_file')]), (reorient2std, fnirt, [('out_file', 'in_file')]), (inputnode, fnirt, [('standard_brain', 'ref_file')]), ]) def getcwd(subject_id): import os tmp = os.getcwd() tmp = tmp[:-6] tmp = tmp + 'ica_aroma/out' #%(subject_id) return tmp get_wd = Node(util.Function(input_names=['subject_id'], output_names=["d"], function=getcwd), name='get_wd') ica_aroma = Node(ICA_AROMA(), name="ica_aroma") ica_aroma.inputs.denoise_type = 'both' #ica_aroma.inputs.out_dir = os.getcwd() func_preproc.connect([ (moco, ica_aroma, [('outputnode.par_moco', 'motion_parameters')]), (smoothing, reorient2std_rs, [('outputnode.ts_smoothed', 'in_file')]), (reorient2std_rs, ica_aroma, [('out_file', 'in_file')]), (fnirt, ica_aroma, [('field_file', 'fnirt_warp_file')]), (transform_ts, reorient2std_mask, [('outputnode.comb_mask_resamp', 'in_file')]), (reorient2std_mask, ica_aroma, [('out_file', 'mask')]), (inputnode, get_wd, [('subject_id', 'subject_id')]), (get_wd, ica_aroma, [('d', 'out_dir')]) ]) ##POSTPROCESSING postprocess = create_denoise_pipeline() func_preproc.connect([ (reorient2std_mask, postprocess, [ ('out_file', 'inputnode.brain_mask') ]), #use the correctly oriented mask (ica_aroma, postprocess, [ ('nonaggr_denoised_file', 'inputnode.epi_coreg') ]), #use the nonaggr_denoised_file (inputnode, postprocess, [('TR', 'inputnode.tr')]), (inputnode, postprocess, [('highpass_freq', 'inputnode.highpass_freq') ]), (inputnode, postprocess, [('wmseg', 'inputnode.wmseg')]), (inputnode, postprocess, [('csfseg', 'inputnode.csfseg')]), ]) #outputnode outputnode = Node(util.IdentityInterface(fields=[ 'par', 'rms', 'mean_epi', 'tsnr', 'stddev_file', 'realigned_ts', 'fmap', 'unwarped_mean_epi2fmap', 'coregistered_epi2fmap', 'fmap_fullwarp', 'epi2anat', 'epi2anat_mat', 'epi2anat_dat', 'epi2anat_mincost', 'full_transform_ts', 'full_transform_mean', 'resamp_t1', 'comb_mask_resamp', 'dvars_file', 'out_flirt_prep', 'out_matrix_flirt_prep', 'out_warped', 'out_warp_field', 'aggr_denoised_file', 'nonaggr_denoised_file', 'out_dir', 'wmcsf_mask', 'combined_motion', 'comp_regressor', 'comp_F', 'comp_pF', 'out_betas', 'ts_fullspectrum', 'ts_filtered' ]), name='outputnode') # connections func_preproc.connect([ ( moco, outputnode, [ #('outputnode.epi_moco', 'realign.@realigned_ts'), ('outputnode.par_moco', 'par'), ('outputnode.rms_moco', 'rms'), ('outputnode.epi_moco', 'realigned_ts'), ('outputnode.epi_mean', 'mean_epi'), ('outputnode.tsnr_file', 'tsnr'), ('outputnode.stddev_file', 'stddev'), ]), (fmap_coreg, outputnode, [('outputnode.fmap', 'fmap'), ('outputnode.unwarped_mean_epi2fmap', 'unwarped_mean_epi2fmap'), ('outputnode.epi2fmap', 'coregistered_epi2fmap'), ('outputnode.fmap_fullwarp', 'fmap_fullwarp'), ('outputnode.epi2anat', 'epi2anat'), ('outputnode.epi2anat_mat', 'epi2anat_mat'), ('outputnode.epi2anat_dat', 'epi2anat_dat'), ('outputnode.epi2anat_mincost', 'epi2anat_mincost')]), (transform_ts, outputnode, [('outputnode.trans_ts', 'full_transform_ts'), ('outputnode.trans_ts_mean', 'full_transform_mean'), ('outputnode.resamp_t1', 'resamp_t1'), ('outputnode.comb_mask_resamp', 'comb_mask_resamp'), ('outputnode.out_dvars', 'dvars_file')]), (flirt_prep, outputnode, [('out_file', 'out_flirt_prep'), ('out_matrix_file', 'out_matrix_flirt_prep') ]), (fnirt, outputnode, [('warped_file', 'out_warped'), ('field_file', 'out_warp_field')]), (ica_aroma, outputnode, [('aggr_denoised_file', 'aggr_denoised_file'), ('nonaggr_denoised_file', 'nonaggr_denoised_file'), ('out_dir', 'out_dir')]), (postprocess, outputnode, [('outputnode.wmcsf_mask', 'wmcsf_mask'), ('outputnode.combined_motion', 'combined_motion'), ('outputnode.comp_regressor', 'comp_regressor'), ('outputnode.comp_F', 'comp_F'), ('outputnode.comp_pF', 'comp_pF'), ('outputnode.out_betas', 'out_betas'), ('outputnode.ts_fullspectrum', 'ts_fullspectrum'), ('outputnode.ts_filtered', 'ts_filtered')]) ]) return func_preproc
def create_lemon_resting(subject, working_dir, data_dir, freesurfer_dir, out_dir, vol_to_remove, TR, epi_resolution, highpass, lowpass, echo_space, te_diff, pe_dir, standard_brain, standard_brain_resampled, standard_brain_mask, standard_brain_mask_resampled, fwhm_smoothing): # set fsl output type to nii.gz fsl.FSLCommand.set_default_output_type('NIFTI_GZ') # main workflow func_preproc = Workflow(name='lemon_resting') func_preproc.base_dir = working_dir func_preproc.config['execution']['crashdump_dir'] = func_preproc.base_dir + "/crash_files" # select files templates = {'func': 'raw_data/{subject}/func/EPI_t2.nii', 'fmap_phase': 'raw_data/{subject}/unwarp/B0_ph.nii', 'fmap_mag': 'raw_data/{subject}/unwarp/B0_mag.nii', 'anat_head': 'preprocessed/{subject}/structural/T1.nii.gz', # either with mod or without 'anat_brain': 'preprocessed/{subject}/structural/brain.nii.gz', # new version with brain_extraction from freesurfer #T1_brain_brain.nii.gz', 'brain_mask': 'preprocessed/{subject}/structural/T1_brain_mask.nii.gz', # T1_brain_brain_mask.nii.gz', 'ants_affine': 'preprocessed/{subject}/structural/transforms2mni/transform0GenericAffine.mat', 'ants_warp': 'preprocessed/{subject}/structural/transforms2mni/transform1Warp.nii.gz' } selectfiles = Node(nio.SelectFiles(templates, base_directory=data_dir), name="selectfiles") selectfiles.inputs.subject = subject # node to remove first volumes remove_vol = Node(util.Function(input_names=['in_file', 't_min'], output_names=["out_file"], function=strip_rois_func), name='remove_vol') remove_vol.inputs.t_min = vol_to_remove # workflow for motion correction moco = create_moco_pipeline() # workflow for fieldmap correction and coregistration fmap_coreg = create_fmap_coreg_pipeline() fmap_coreg.inputs.inputnode.fs_subjects_dir = freesurfer_dir fmap_coreg.inputs.inputnode.fs_subject_id = subject fmap_coreg.inputs.inputnode.echo_space = echo_space fmap_coreg.inputs.inputnode.te_diff = te_diff fmap_coreg.inputs.inputnode.pe_dir = pe_dir # workflow for applying transformations to timeseries transform_ts = create_transform_pipeline() transform_ts.inputs.inputnode.resolution = epi_resolution # workflow to denoise timeseries denoise = create_denoise_pipeline() denoise.inputs.inputnode.highpass_sigma = 1. / (2 * TR * highpass) denoise.inputs.inputnode.lowpass_sigma = 1. / (2 * TR * lowpass) # https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1205&L=FSL&P=R57592&1=FSL&9=A&I=-3&J=on&d=No+Match%3BMatch%3BMatches&z=4 denoise.inputs.inputnode.tr = TR # workflow to transform timeseries to MNI ants_registration = create_ants_registration_pipeline() ants_registration.inputs.inputnode.ref = standard_brain_resampled ants_registration.inputs.inputnode.tr_sec = TR # FL added fullspectrum # workflow to transform fullspectrum timeseries to MNI ants_registration_full = create_ants_registration_pipeline('ants_registration_full') ants_registration_full.inputs.inputnode.ref = standard_brain_resampled ants_registration_full.inputs.inputnode.tr_sec = TR # workflow to smooth smoothing = create_smoothing_pipeline() smoothing.inputs.inputnode.fwhm = fwhm_smoothing # visualize registration results visualize = create_visualize_pipeline() visualize.inputs.inputnode.mni_template = standard_brain_resampled # sink to store files sink = Node(nio.DataSink(parameterization=False, base_directory=out_dir, substitutions=[('fmap_phase_fslprepared', 'fieldmap'), ('fieldmap_fslprepared_fieldmap_unmasked_vsm', 'shiftmap'), ('plot.rest_coregistered', 'outlier_plot'), ('filter_motion_comp_norm_compcor_art_dmotion', 'nuissance_matrix'), ('rest_realigned.nii.gz_abs.rms', 'rest_realigned_abs.rms'), ('rest_realigned.nii.gz.par', 'rest_realigned.par'), ('rest_realigned.nii.gz_rel.rms', 'rest_realigned_rel.rms'), ('rest_realigned.nii.gz_abs_disp', 'abs_displacement_plot'), ('rest_realigned.nii.gz_rel_disp', 'rel_displacment_plot'), ('art.rest_coregistered_outliers', 'outliers'), ('global_intensity.rest_coregistered', 'global_intensity'), ('norm.rest_coregistered', 'composite_norm'), ('stats.rest_coregistered', 'stats'), ('rest_denoised_bandpassed_norm.nii.gz', 'rest_preprocessed_nativespace.nii.gz'), ('rest_denoised_bandpassed_norm_trans.nii.gz', 'rest_mni_unsmoothed.nii.gz'), ('rest_denoised_bandpassed_norm_trans_smooth.nii', 'rest_mni_smoothed.nii'), # FL added ('rest2anat_masked.nii.gz', 'rest_coregistered_nativespace.nii.gz'), ('rest2anat_denoised.nii.gz', 'rest_preprocessed_nativespace_fullspectrum.nii.gz'), ('rest2anat_denoised_trans.nii.gz', 'rest_mni_unsmoothed_fullspectrum.nii.gz') ]), name='sink') # connections func_preproc.connect([ # remove the first volumes (selectfiles, remove_vol, [('func', 'in_file')]), # align volumes and motion correction (remove_vol, moco, [('out_file', 'inputnode.epi')]), # prepare field map (selectfiles, fmap_coreg, [('fmap_phase', 'inputnode.phase'), ('fmap_mag', 'inputnode.mag'), ('anat_head', 'inputnode.anat_head'), ('anat_brain', 'inputnode.anat_brain') ]), (moco, fmap_coreg, [('outputnode.epi_mean', 'inputnode.epi_mean')]), # transform timeseries (remove_vol, transform_ts, [('out_file', 'inputnode.orig_ts')]), (selectfiles, transform_ts, [('anat_head', 'inputnode.anat_head')]), (selectfiles, transform_ts, [('brain_mask', 'inputnode.brain_mask')]), (moco, transform_ts, [('outputnode.mat_moco', 'inputnode.mat_moco')]), (fmap_coreg, transform_ts, [('outputnode.fmap_fullwarp', 'inputnode.fullwarp')]), # correct slicetiming # FIXME slice timing? # (transform_ts, slicetiming, [('outputnode.trans_ts_masked', 'inputnode.ts')]), # (slicetiming, denoise, [('outputnode.ts_slicetcorrected', 'inputnode.epi_coreg')]), (transform_ts, denoise, [('outputnode.trans_ts_masked', 'inputnode.epi_coreg')]), # denoise data (selectfiles, denoise, [('brain_mask', 'inputnode.brain_mask'), ('anat_brain', 'inputnode.anat_brain')]), (moco, denoise, [('outputnode.par_moco', 'inputnode.moco_par')]), (fmap_coreg, denoise, [('outputnode.epi2anat_dat', 'inputnode.epi2anat_dat'), ('outputnode.unwarped_mean_epi2fmap', 'inputnode.unwarped_mean')]), (denoise, ants_registration, [('outputnode.normalized_file', 'inputnode.denoised_ts')]), # registration to MNI space (selectfiles, ants_registration, [('ants_affine', 'inputnode.ants_affine')]), (selectfiles, ants_registration, [('ants_warp', 'inputnode.ants_warp')]), # FL added fullspectrum (denoise, ants_registration_full, [('outputnode.ts_fullspectrum', 'inputnode.denoised_ts')]), (selectfiles, ants_registration_full, [('ants_affine', 'inputnode.ants_affine')]), (selectfiles, ants_registration_full, [('ants_warp', 'inputnode.ants_warp')]), (ants_registration, smoothing, [('outputnode.ants_reg_ts', 'inputnode.ts_transformed')]), (smoothing, visualize, [('outputnode.ts_smoothed', 'inputnode.ts_transformed')]), ##all the output (moco, sink, [ # ('outputnode.epi_moco', 'realign.@realigned_ts'), ('outputnode.par_moco', 'realign.@par'), ('outputnode.rms_moco', 'realign.@rms'), ('outputnode.mat_moco', 'realign.MAT.@mat'), ('outputnode.epi_mean', 'realign.@mean'), ('outputnode.rotplot', 'realign.plots.@rotplot'), ('outputnode.transplot', 'realign.plots.@transplot'), ('outputnode.dispplots', 'realign.plots.@dispplots'), ('outputnode.tsnr_file', 'realign.@tsnr')]), (fmap_coreg, sink, [('outputnode.fmap', 'coregister.transforms2anat.@fmap'), # ('outputnode.unwarpfield_epi2fmap', 'coregister.@unwarpfield_epi2fmap'), ('outputnode.unwarped_mean_epi2fmap', 'coregister.@unwarped_mean_epi2fmap'), ('outputnode.epi2fmap', 'coregister.@epi2fmap'), # ('outputnode.shiftmap', 'coregister.@shiftmap'), ('outputnode.fmap_fullwarp', 'coregister.transforms2anat.@fmap_fullwarp'), ('outputnode.epi2anat', 'coregister.@epi2anat'), ('outputnode.epi2anat_mat', 'coregister.transforms2anat.@epi2anat_mat'), ('outputnode.epi2anat_dat', 'coregister.transforms2anat.@epi2anat_dat'), ('outputnode.epi2anat_mincost', 'coregister.@epi2anat_mincost') ]), (transform_ts, sink, [('outputnode.trans_ts_masked', 'coregister.@full_transform_ts'), ('outputnode.trans_ts_mean', 'coregister.@full_transform_mean'), ('outputnode.resamp_brain', 'coregister.@resamp_brain')]), (denoise, sink, [ ('outputnode.wmcsf_mask', 'denoise.mask.@wmcsf_masks'), ('outputnode.combined_motion', 'denoise.artefact.@combined_motion'), ('outputnode.outlier_files', 'denoise.artefact.@outlier'), ('outputnode.intensity_files', 'denoise.artefact.@intensity'), ('outputnode.outlier_stats', 'denoise.artefact.@outlierstats'), ('outputnode.outlier_plots', 'denoise.artefact.@outlierplots'), ('outputnode.mc_regressor', 'denoise.regress.@mc_regressor'), ('outputnode.comp_regressor', 'denoise.regress.@comp_regressor'), ('outputnode.mc_F', 'denoise.regress.@mc_F'), ('outputnode.mc_pF', 'denoise.regress.@mc_pF'), ('outputnode.comp_F', 'denoise.regress.@comp_F'), ('outputnode.comp_pF', 'denoise.regress.@comp_pF'), ('outputnode.brain_mask_resamp', 'denoise.mask.@brain_resamp'), ('outputnode.brain_mask2epi', 'denoise.mask.@brain_mask2epi'), ('outputnode.normalized_file', 'denoise.@normalized'), # FL added fullspectrum ('outputnode.ts_fullspectrum', 'denoise.@ts_fullspectrum') ]), (ants_registration, sink, [('outputnode.ants_reg_ts', 'ants.@antsnormalized')]), (ants_registration_full, sink, [('outputnode.ants_reg_ts', 'ants.@antsnormalized_fullspectrum')]), (smoothing, sink, [('outputnode.ts_smoothed', '@smoothed.FWHM6')]), ]) func_preproc.write_graph(dotfilename='func_preproc.dot', graph2use='colored', format='pdf', simple_form=True) func_preproc.run(plugin='CondorDAGMan', plugin_args={'initial_specs': 'request_memory = 1500'})
def create_resting(): # main workflow func_preproc = Workflow(name='resting') inputnode = Node(util.IdentityInterface(fields=[ 'subject', 'out_dir', 'freesurfer_dir', 'func', 'fmap_mag', 'fmap_phase', 'anat_head', 'anat_brain', 'anat_brain_mask', 'vol_to_remove', 'TR', 'epi_resolution', 'echo_space', 'te_diff', 'pe_dir' ]), name='inputnode') # node to remove first volumes remove_vol = Node(util.Function(input_names=['in_file', 't_min'], output_names=["out_file"], function=strip_rois_func), name='remove_vol') # workflow for motion correction moco = create_moco_pipeline() # workflow for fieldmap correction and coregistration #have to rename subject for fu def rename_subject_for_fu(input_id): output_id = input_id + "_fu" return output_id #modify subject name so it can be saved in the same folder as other LIFE- freesurfer data rename = Node(util.Function(input_names=['input_id'], output_names=['output_id'], function=rename_subject_for_fu), name="rename") fmap_coreg = create_fmap_coreg_pipeline() # workflow for applying transformations to timeseries transform_ts = create_transform_pipeline() #detrending detrend = Node(afni.Detrend(), name="detrend") detrend.inputs.args = '-polort 2' detrend.inputs.outputtype = "NIFTI" #outputnode outputnode = Node(util.IdentityInterface(fields=[ 'par', 'rms', 'mean_epi', 'tsnr', 'fmap', 'unwarped_mean_epi2fmap', 'coregistered_epi2fmap', 'fmap_fullwarp', 'epi2anat', 'epi2anat_mat', 'epi2anat_dat', 'epi2anat_mincost', 'full_transform_ts', 'full_transform_mean', 'resamp_brain', 'detrended_epi' ]), name='outputnode') # connections func_preproc.connect([ #remove the first volumes (inputnode, remove_vol, [('func', 'in_file')]), (inputnode, remove_vol, [('vol_to_remove', 't_min')]), #align volumes and motion correction (remove_vol, moco, [('out_file', 'inputnode.epi')]), #prepare field map (inputnode, rename, [('subject', 'input_id')]), (rename, fmap_coreg, [('output_id', 'inputnode.fs_subject_id')]), (inputnode, fmap_coreg, [('fmap_phase', 'inputnode.phase'), ('freesurfer_dir', 'inputnode.fs_subjects_dir'), ('echo_space', 'inputnode.echo_space'), ('te_diff', 'inputnode.te_diff'), ('pe_dir', 'inputnode.pe_dir'), ('fmap_mag', 'inputnode.mag'), ('anat_head', 'inputnode.anat_head'), ('anat_brain', 'inputnode.anat_brain')]), (moco, fmap_coreg, [('outputnode.epi_mean', 'inputnode.epi_mean')]), #transform ts (remove_vol, transform_ts, [('out_file', 'inputnode.orig_ts')]), (inputnode, transform_ts, [('anat_head', 'inputnode.anat_head')]), (inputnode, transform_ts, [('anat_brain_mask', 'inputnode.brain_mask') ]), (inputnode, transform_ts, [('epi_resolution', 'inputnode.resolution') ]), (moco, transform_ts, [('outputnode.mat_moco', 'inputnode.mat_moco')]), (fmap_coreg, transform_ts, [('outputnode.fmap_fullwarp', 'inputnode.fullwarp')]), (transform_ts, detrend, [('outputnode.trans_ts', 'in_file')]), ##all the output ( moco, outputnode, [ #('outputnode.epi_moco', 'realign.@realigned_ts'), ('outputnode.par_moco', 'par'), ('outputnode.rms_moco', 'rms'), ('outputnode.epi_mean', 'mean_epi'), ('outputnode.tsnr_file', 'tsnr') ]), (fmap_coreg, outputnode, [('outputnode.fmap', 'fmap'), ('outputnode.unwarped_mean_epi2fmap', 'unwarped_mean_epi2fmap'), ('outputnode.epi2fmap', 'coregistered_epi2fmap'), ('outputnode.fmap_fullwarp', 'fmap_fullwarp'), ('outputnode.epi2anat', 'epi2anat'), ('outputnode.epi2anat_mat', 'epi2anat_mat'), ('outputnode.epi2anat_dat', 'epi2anat_dat'), ('outputnode.epi2anat_mincost', 'epi2anat_mincost')]), (transform_ts, outputnode, [('outputnode.trans_ts', 'full_transform_ts'), ('outputnode.trans_ts_mean', 'full_transform_mean'), ('outputnode.resamp_brain', 'resamp_brain')]), (detrend, outputnode, [('out_file', 'detrended_epi')]) ]) return func_preproc
def create_lemon_resting( subject, working_dir, data_dir, freesurfer_dir, out_dir, vol_to_remove, TR, epi_resolution, highpass, lowpass, echo_space, te_diff, pe_dir, standard_brain, standard_brain_resampled, standard_brain_mask, standard_brain_mask_resampled, fwhm_smoothing, ): # set fsl output type to nii.gz fsl.FSLCommand.set_default_output_type("NIFTI_GZ") # main workflow func_preproc = Workflow(name="lemon_resting") func_preproc.base_dir = working_dir func_preproc.config["execution"]["crashdump_dir"] = func_preproc.base_dir + "/crash_files" # select files templates = { "func": "func/EPI_t2.nii", "fmap_phase": "unwarp/B0_ph.nii", "fmap_mag": "unwarp/B0_mag.nii", "anat_head": "preprocessed/mod/anat/T1.nii.gz", # either with mod or without "anat_brain": "preprocessed/mod/anat/brain.nii.gz", # new version with brain_extraction from freesurfer #T1_brain_brain.nii.gz', "brain_mask": "preprocessed/mod/anat/T1_brain_mask.nii.gz", # T1_brain_brain_mask.nii.gz', "ants_affine": "preprocessed/mod/anat/transforms2mni/transform0GenericAffine.mat", "ants_warp": "preprocessed/mod/anat/transforms2mni/transform1Warp.nii.gz", } selectfiles = Node(nio.SelectFiles(templates, base_directory=data_dir), name="selectfiles") # node to remove first volumes remove_vol = Node( util.Function(input_names=["in_file", "t_min"], output_names=["out_file"], function=strip_rois_func), name="remove_vol", ) remove_vol.inputs.t_min = vol_to_remove # workflow for motion correction moco = create_moco_pipeline() # workflow for fieldmap correction and coregistration fmap_coreg = create_fmap_coreg_pipeline() fmap_coreg.inputs.inputnode.fs_subjects_dir = freesurfer_dir fmap_coreg.inputs.inputnode.fs_subject_id = subject fmap_coreg.inputs.inputnode.echo_space = echo_space fmap_coreg.inputs.inputnode.te_diff = te_diff fmap_coreg.inputs.inputnode.pe_dir = pe_dir # workflow for applying transformations to timeseries transform_ts = create_transform_pipeline() transform_ts.inputs.inputnode.resolution = epi_resolution # workflow to convert signal into percent signal change normalize = create_normalize_pipeline() normalize.inputs.inputnode.tr = TR # workflow to transform timeseries to MNI ants_registration = create_ants_registration_pipeline() ants_registration.inputs.inputnode.ref = standard_brain_resampled # workflow to smooth smoothing = create_smoothing_pipeline() smoothing.inputs.inputnode.fwhm = fwhm_smoothing # workflow to correct slice timing slicetiming = create_slice_timing_pipeline() # visualize registration results visualize = create_visualize_pipeline() visualize.inputs.inputnode.mni_template = standard_brain_resampled # sink to store files sink = Node( nio.DataSink( parameterization=False, base_directory=out_dir, substitutions=[ ("fmap_phase_fslprepared", "fieldmap"), ("fieldmap_fslprepared_fieldmap_unmasked_vsm", "shiftmap"), ("plot.rest_coregistered", "outlier_plot"), ("filter_motion_comp_norm_compcor_art_dmotion", "nuissance_matrix"), ("rest_realigned.nii.gz_abs.rms", "rest_realigned_abs.rms"), ("rest_realigned.nii.gz.par", "rest_realigned.par"), ("rest_realigned.nii.gz_rel.rms", "rest_realigned_rel.rms"), ("rest_realigned.nii.gz_abs_disp", "abs_displacement_plot"), ("rest_realigned.nii.gz_rel_disp", "rel_displacment_plot"), ("art.rest_coregistered_outliers", "outliers"), ("global_intensity.rest_coregistered", "global_intensity"), ("norm.rest_coregistered", "composite_norm"), ("stats.rest_coregistered", "stats"), ("rest_denoised_bandpassed_norm.nii.gz", "rest_preprocessed.nii.gz"), ("rest_denoised_bandpassed_norm_trans.nii.gz", "rest_mni.nii.gz"), ("rest2anat_masked_st_norm_trans_smooth.nii", "rest_mni_smoothed.nii"), ], ), name="sink", ) # connections func_preproc.connect( [ # remove the first volumes (selectfiles, remove_vol, [("func", "in_file")]), # align volumes and motion correction (remove_vol, moco, [("out_file", "inputnode.epi")]), # prepare field map ( selectfiles, fmap_coreg, [ ("fmap_phase", "inputnode.phase"), ("fmap_mag", "inputnode.mag"), ("anat_head", "inputnode.anat_head"), ("anat_brain", "inputnode.anat_brain"), ], ), (moco, fmap_coreg, [("outputnode.epi_mean", "inputnode.epi_mean")]), (remove_vol, transform_ts, [("out_file", "inputnode.orig_ts")]), (selectfiles, transform_ts, [("anat_head", "inputnode.anat_head")]), (selectfiles, transform_ts, [("brain_mask", "inputnode.brain_mask")]), (moco, transform_ts, [("outputnode.mat_moco", "inputnode.mat_moco")]), (fmap_coreg, transform_ts, [("outputnode.fmap_fullwarp", "inputnode.fullwarp")]), ##add slice time correction after applying motion realignement + unwarping (transform_ts, slicetiming, [("outputnode.trans_ts_masked", "inputnode.ts")]), (slicetiming, normalize, [("outputnode.ts_slicetcorrected", "inputnode.epi_coreg")]), (normalize, ants_registration, [("outputnode.normalized_file", "inputnode.denoised_ts")]), # registration to MNI space (selectfiles, ants_registration, [("ants_affine", "inputnode.ants_affine")]), (selectfiles, ants_registration, [("ants_warp", "inputnode.ants_warp")]), (ants_registration, smoothing, [("outputnode.ants_reg_ts", "inputnode.ts_transformed")]), (smoothing, visualize, [("outputnode.ts_smoothed", "inputnode.ts_transformed")]), ##all the output ( moco, sink, [ # ('outputnode.epi_moco', 'realign.@realigned_ts'), ("outputnode.par_moco", "realign.@par"), ("outputnode.rms_moco", "realign.@rms"), ("outputnode.mat_moco", "realign.MAT.@mat"), ("outputnode.epi_mean", "realign.@mean"), ("outputnode.rotplot", "realign.plots.@rotplot"), ("outputnode.transplot", "realign.plots.@transplot"), ("outputnode.dispplots", "realign.plots.@dispplots"), ("outputnode.tsnr_file", "realign.@tsnr"), ], ), ( fmap_coreg, sink, [ ("outputnode.fmap", "coregister.transforms2anat.@fmap"), # ('outputnode.unwarpfield_epi2fmap', 'coregister.@unwarpfield_epi2fmap'), ("outputnode.unwarped_mean_epi2fmap", "coregister.@unwarped_mean_epi2fmap"), ("outputnode.epi2fmap", "coregister.@epi2fmap"), # ('outputnode.shiftmap', 'coregister.@shiftmap'), ("outputnode.fmap_fullwarp", "coregister.transforms2anat.@fmap_fullwarp"), ("outputnode.epi2anat", "coregister.@epi2anat"), ("outputnode.epi2anat_mat", "coregister.transforms2anat.@epi2anat_mat"), ("outputnode.epi2anat_dat", "coregister.transforms2anat.@epi2anat_dat"), ("outputnode.epi2anat_mincost", "coregister.@epi2anat_mincost"), ], ), ( transform_ts, sink, [ # ('outputnode.trans_ts', 'coregister.@full_transform_ts'), ("outputnode.trans_ts_mean", "coregister.@full_transform_mean"), ("outputnode.resamp_brain", "coregister.@resamp_brain"), ], ), (ants_registration, sink, [("outputnode.ants_reg_ts", "ants.@antsnormalized")]), (smoothing, sink, [("outputnode.ts_smoothed", "@smoothed.FWHM6")]), ] ) # func_preproc.write_graph(dotfilename='func_preproc.dot', graph2use='colored', format='pdf', simple_form=True) func_preproc.run()
def create_lemon_resting(subject, working_dir, data_dir, freesurfer_dir, out_dir, vol_to_remove, TR, epi_resolution, highpass, lowpass, echo_space, te_diff, pe_dir, standard_brain, standard_brain_resampled, standard_brain_mask, standard_brain_mask_resampled, fwhm_smoothing): # set fsl output type to nii.gz fsl.FSLCommand.set_default_output_type('NIFTI_GZ') # main workflow func_preproc = Workflow(name='lemon_resting') func_preproc.base_dir = working_dir func_preproc.config['execution'][ 'crashdump_dir'] = func_preproc.base_dir + "/crash_files" # select files templates = { 'func': 'raw_data/{subject}/func/EPI_t2.nii', 'fmap_phase': 'raw_data/{subject}/unwarp/B0_ph.nii', 'fmap_mag': 'raw_data/{subject}/unwarp/B0_mag.nii', 'anat_head': 'preprocessed/{subject}/structural/T1.nii.gz', # either with mod or without 'anat_brain': 'preprocessed/{subject}/structural/brain.nii.gz', # new version with brain_extraction from freesurfer #T1_brain_brain.nii.gz', 'brain_mask': 'preprocessed/{subject}/structural/T1_brain_mask.nii.gz', # T1_brain_brain_mask.nii.gz', 'ants_affine': 'preprocessed/{subject}/structural/transforms2mni/transform0GenericAffine.mat', 'ants_warp': 'preprocessed/{subject}/structural/transforms2mni/transform1Warp.nii.gz' } selectfiles = Node(nio.SelectFiles(templates, base_directory=data_dir), name="selectfiles") selectfiles.inputs.subject = subject # node to remove first volumes remove_vol = Node(util.Function(input_names=['in_file', 't_min'], output_names=["out_file"], function=strip_rois_func), name='remove_vol') remove_vol.inputs.t_min = vol_to_remove # workflow for motion correction moco = create_moco_pipeline() # workflow for fieldmap correction and coregistration fmap_coreg = create_fmap_coreg_pipeline() fmap_coreg.inputs.inputnode.fs_subjects_dir = freesurfer_dir fmap_coreg.inputs.inputnode.fs_subject_id = subject fmap_coreg.inputs.inputnode.echo_space = echo_space fmap_coreg.inputs.inputnode.te_diff = te_diff fmap_coreg.inputs.inputnode.pe_dir = pe_dir # workflow for applying transformations to timeseries transform_ts = create_transform_pipeline() transform_ts.inputs.inputnode.resolution = epi_resolution # workflow to denoise timeseries denoise = create_denoise_pipeline() denoise.inputs.inputnode.highpass_sigma = 1. / (2 * TR * highpass) denoise.inputs.inputnode.lowpass_sigma = 1. / (2 * TR * lowpass) # https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1205&L=FSL&P=R57592&1=FSL&9=A&I=-3&J=on&d=No+Match%3BMatch%3BMatches&z=4 denoise.inputs.inputnode.tr = TR # workflow to transform timeseries to MNI ants_registration = create_ants_registration_pipeline() ants_registration.inputs.inputnode.ref = standard_brain_resampled ants_registration.inputs.inputnode.tr_sec = TR # FL added fullspectrum # workflow to transform fullspectrum timeseries to MNI ants_registration_full = create_ants_registration_pipeline( 'ants_registration_full') ants_registration_full.inputs.inputnode.ref = standard_brain_resampled ants_registration_full.inputs.inputnode.tr_sec = TR # workflow to smooth smoothing = create_smoothing_pipeline() smoothing.inputs.inputnode.fwhm = fwhm_smoothing # visualize registration results visualize = create_visualize_pipeline() visualize.inputs.inputnode.mni_template = standard_brain_resampled # sink to store files sink = Node( nio.DataSink( parameterization=False, base_directory=out_dir, substitutions=[ ('fmap_phase_fslprepared', 'fieldmap'), ('fieldmap_fslprepared_fieldmap_unmasked_vsm', 'shiftmap'), ('plot.rest_coregistered', 'outlier_plot'), ('filter_motion_comp_norm_compcor_art_dmotion', 'nuissance_matrix'), ('rest_realigned.nii.gz_abs.rms', 'rest_realigned_abs.rms'), ('rest_realigned.nii.gz.par', 'rest_realigned.par'), ('rest_realigned.nii.gz_rel.rms', 'rest_realigned_rel.rms'), ('rest_realigned.nii.gz_abs_disp', 'abs_displacement_plot'), ('rest_realigned.nii.gz_rel_disp', 'rel_displacment_plot'), ('art.rest_coregistered_outliers', 'outliers'), ('global_intensity.rest_coregistered', 'global_intensity'), ('norm.rest_coregistered', 'composite_norm'), ('stats.rest_coregistered', 'stats'), ('rest_denoised_bandpassed_norm.nii.gz', 'rest_preprocessed_nativespace.nii.gz'), ('rest_denoised_bandpassed_norm_trans.nii.gz', 'rest_mni_unsmoothed.nii.gz'), ('rest_denoised_bandpassed_norm_trans_smooth.nii', 'rest_mni_smoothed.nii'), # FL added ('rest2anat_masked.nii.gz', 'rest_coregistered_nativespace.nii.gz'), ('rest2anat_denoised.nii.gz', 'rest_preprocessed_nativespace_fullspectrum.nii.gz'), ('rest2anat_denoised_trans.nii.gz', 'rest_mni_unsmoothed_fullspectrum.nii.gz') ]), name='sink') # connections func_preproc.connect([ # remove the first volumes (selectfiles, remove_vol, [('func', 'in_file')]), # align volumes and motion correction (remove_vol, moco, [('out_file', 'inputnode.epi')]), # prepare field map (selectfiles, fmap_coreg, [('fmap_phase', 'inputnode.phase'), ('fmap_mag', 'inputnode.mag'), ('anat_head', 'inputnode.anat_head'), ('anat_brain', 'inputnode.anat_brain')]), (moco, fmap_coreg, [('outputnode.epi_mean', 'inputnode.epi_mean')]), # transform timeseries (remove_vol, transform_ts, [('out_file', 'inputnode.orig_ts')]), (selectfiles, transform_ts, [('anat_head', 'inputnode.anat_head')]), (selectfiles, transform_ts, [('brain_mask', 'inputnode.brain_mask')]), (moco, transform_ts, [('outputnode.mat_moco', 'inputnode.mat_moco')]), (fmap_coreg, transform_ts, [('outputnode.fmap_fullwarp', 'inputnode.fullwarp')]), # correct slicetiming # FIXME slice timing? # (transform_ts, slicetiming, [('outputnode.trans_ts_masked', 'inputnode.ts')]), # (slicetiming, denoise, [('outputnode.ts_slicetcorrected', 'inputnode.epi_coreg')]), (transform_ts, denoise, [('outputnode.trans_ts_masked', 'inputnode.epi_coreg')]), # denoise data (selectfiles, denoise, [('brain_mask', 'inputnode.brain_mask'), ('anat_brain', 'inputnode.anat_brain')]), (moco, denoise, [('outputnode.par_moco', 'inputnode.moco_par')]), (fmap_coreg, denoise, [('outputnode.epi2anat_dat', 'inputnode.epi2anat_dat'), ('outputnode.unwarped_mean_epi2fmap', 'inputnode.unwarped_mean')]), (denoise, ants_registration, [('outputnode.normalized_file', 'inputnode.denoised_ts')]), # registration to MNI space (selectfiles, ants_registration, [('ants_affine', 'inputnode.ants_affine')]), (selectfiles, ants_registration, [('ants_warp', 'inputnode.ants_warp') ]), # FL added fullspectrum (denoise, ants_registration_full, [('outputnode.ts_fullspectrum', 'inputnode.denoised_ts')]), (selectfiles, ants_registration_full, [('ants_affine', 'inputnode.ants_affine')]), (selectfiles, ants_registration_full, [('ants_warp', 'inputnode.ants_warp')]), (ants_registration, smoothing, [('outputnode.ants_reg_ts', 'inputnode.ts_transformed')]), (smoothing, visualize, [('outputnode.ts_smoothed', 'inputnode.ts_transformed')]), ##all the output ( moco, sink, [ # ('outputnode.epi_moco', 'realign.@realigned_ts'), ('outputnode.par_moco', 'realign.@par'), ('outputnode.rms_moco', 'realign.@rms'), ('outputnode.mat_moco', 'realign.MAT.@mat'), ('outputnode.epi_mean', 'realign.@mean'), ('outputnode.rotplot', 'realign.plots.@rotplot'), ('outputnode.transplot', 'realign.plots.@transplot'), ('outputnode.dispplots', 'realign.plots.@dispplots'), ('outputnode.tsnr_file', 'realign.@tsnr') ]), ( fmap_coreg, sink, [ ('outputnode.fmap', 'coregister.transforms2anat.@fmap'), # ('outputnode.unwarpfield_epi2fmap', 'coregister.@unwarpfield_epi2fmap'), ('outputnode.unwarped_mean_epi2fmap', 'coregister.@unwarped_mean_epi2fmap'), ('outputnode.epi2fmap', 'coregister.@epi2fmap'), # ('outputnode.shiftmap', 'coregister.@shiftmap'), ('outputnode.fmap_fullwarp', 'coregister.transforms2anat.@fmap_fullwarp'), ('outputnode.epi2anat', 'coregister.@epi2anat'), ('outputnode.epi2anat_mat', 'coregister.transforms2anat.@epi2anat_mat'), ('outputnode.epi2anat_dat', 'coregister.transforms2anat.@epi2anat_dat'), ('outputnode.epi2anat_mincost', 'coregister.@epi2anat_mincost') ]), (transform_ts, sink, [('outputnode.trans_ts_masked', 'coregister.@full_transform_ts'), ('outputnode.trans_ts_mean', 'coregister.@full_transform_mean'), ('outputnode.resamp_brain', 'coregister.@resamp_brain')]), ( denoise, sink, [ ('outputnode.wmcsf_mask', 'denoise.mask.@wmcsf_masks'), ('outputnode.combined_motion', 'denoise.artefact.@combined_motion'), ('outputnode.outlier_files', 'denoise.artefact.@outlier'), ('outputnode.intensity_files', 'denoise.artefact.@intensity'), ('outputnode.outlier_stats', 'denoise.artefact.@outlierstats'), ('outputnode.outlier_plots', 'denoise.artefact.@outlierplots'), ('outputnode.mc_regressor', 'denoise.regress.@mc_regressor'), ('outputnode.comp_regressor', 'denoise.regress.@comp_regressor'), ('outputnode.mc_F', 'denoise.regress.@mc_F'), ('outputnode.mc_pF', 'denoise.regress.@mc_pF'), ('outputnode.comp_F', 'denoise.regress.@comp_F'), ('outputnode.comp_pF', 'denoise.regress.@comp_pF'), ('outputnode.brain_mask_resamp', 'denoise.mask.@brain_resamp'), ('outputnode.brain_mask2epi', 'denoise.mask.@brain_mask2epi'), ('outputnode.normalized_file', 'denoise.@normalized'), # FL added fullspectrum ('outputnode.ts_fullspectrum', 'denoise.@ts_fullspectrum') ]), (ants_registration, sink, [('outputnode.ants_reg_ts', 'ants.@antsnormalized')]), (ants_registration_full, sink, [('outputnode.ants_reg_ts', 'ants.@antsnormalized_fullspectrum')]), (smoothing, sink, [('outputnode.ts_smoothed', '@smoothed.FWHM6')]), ]) func_preproc.write_graph(dotfilename='func_preproc.dot', graph2use='colored', format='pdf', simple_form=True) func_preproc.run(plugin='CondorDAGMan', plugin_args={'initial_specs': 'request_memory = 1500'})