def create_prep(name='preproc'): """ Base preprocessing workflow for task and resting state fMRI Parameters ---------- name : name of workflow. Default = 'preproc' Inputs ------ inputspec.fssubject_id : inputspec.fssubject_dir : inputspec.func : inputspec.highpass : inputspec.num_noise_components : inputspec.ad_normthresh : inputspec.ad_zthresh : inputspec.tr : inputspec.interleaved : inputspec.sliceorder : inputspec.compcor_select : inputspec.highpass_sigma : inputspec.lowpass_sigma : inputspec.reg_params : inputspec.FM_TEdiff : inputspec.FM_Echo_spacing : inputspec.FM_sigma : Outputs ------- outputspec.reference : outputspec.motion_parameters : outputspec.realigned_files : outputspec.mask : outputspec.smoothed_files : outputspec.highpassed_files : outputspec.mean : outputspec.combined_motion : outputspec.outlier_files : outputspec.mask : outputspec.reg_cost : outputspec.reg_file : outputspec.noise_components : outputspec.tsnr_file : outputspec.stddev_file : outputspec.filter_file : outputspec.scaled_files : outputspec.z_img : outputspec.motion_plots : outputspec.FM_unwarped_mean : outputspec.FM_unwarped_epi : Returns ------- workflow : preprocessing workflow """ import nipype.interfaces.fsl as fsl # fsl import nipype.algorithms.rapidart as ra # rapid artifact detection from nipype.workflows.smri.freesurfer.utils import create_getmask_flow from modular_nodes import create_mod_smooth, mod_realign, mod_despike import nipype.pipeline.engine as pe import nipype.interfaces.utility as util preproc = pe.Workflow(name=name) # Compcorr node compcor = create_compcorr() # Input node inputnode = pe.Node(util.IdentityInterface(fields=[ 'fssubject_id', 'fssubject_dir', 'func', 'highpass', 'num_noise_components', 'ad_normthresh', 'ad_zthresh', 'tr', 'do_slicetime', 'sliceorder', 'compcor_select', 'highpass_freq', 'lowpass_freq', 'reg_params', 'FM_TEdiff', 'FM_Echo_spacing', 'FM_sigma', 'motion_correct_node', 'smooth_type', 'surface_fwhm', 'filter_type', 'timepoints_to_remove', 'do_whitening', 'regress_before_PCA', 'realign_parameters', 'do_despike', 'anatomical' ]), name='inputspec') # Separate input node for FWHM inputnode_fwhm = pe.Node(util.IdentityInterface(fields=['fwhm']), name='fwhm_input') # strip ids strip_rois = pe.MapNode(fsl.ExtractROI(), name='extractroi', iterfield='in_file') strip_rois.inputs.t_size = -1 preproc.connect(inputnode, 'timepoints_to_remove', strip_rois, 't_min') # convert BOLD images to float img2float = pe.MapNode(interface=fsl.ImageMaths(out_data_type='float', op_string='', suffix='_dtype'), iterfield=['in_file'], name='img2float') #afni despike despike = pe.MapNode(util.Function(input_names=['in_file', "do_despike"], output_names=["out_file"], function=mod_despike), name="despike", iterfield=["in_file"]) preproc.connect(inputnode, "do_despike", despike, "do_despike") # define the motion correction node #motion_correct = pe.Node(interface=FmriRealign4d(), # name='realign') motion_correct = pe.Node(util.Function( input_names=[ 'node', 'in_file', 'tr', 'do_slicetime', 'sliceorder', "parameters" ], output_names=['out_file', 'par_file', 'parameter_source'], function=mod_realign), name="mod_realign") preproc.connect(inputnode, 'motion_correct_node', motion_correct, 'node') # construct motion plots #plot_motion = pe.MapNode(interface=fsl.PlotMotionParams(in_source='fsl'), # name='plot_motion', # iterfield=['in_file']) # rapidArt for artifactual timepoint detection ad = pe.Node(ra.ArtifactDetect(save_plot=False), name='artifactdetect') # extract the mean volume if the first functional run meanfunc = art_mean_workflow() # generate a freesurfer workflow that will return the mask getmask = create_getmask_flow() # create a SUSAN smoothing workflow, and smooth each run with # 75% of the median value for each run as the brightness # threshold. smooth = create_mod_smooth(name="modular_smooth", separate_masks=False) preproc.connect(inputnode, 'smooth_type', smooth, 'inputnode.smooth_type') # choose susan function """ The following node selects smooth or unsmoothed data depending on the fwhm. This is because SUSAN defaults to smoothing the data with about the voxel size of the input data if the fwhm parameter is less than 1/3 of the voxel size. """ choosesusan = pe.Node(util.Function( input_names=['fwhm', 'motion_files', 'smoothed_files'], output_names=['cor_smoothed_files'], function=choose_susan), name='select_smooth') # scale the median value of each run to 10,000 meanscale = pe.MapNode(interface=fsl.ImageMaths(suffix='_gms'), iterfield=['in_file', 'op_string'], name='scale_median') # determine the median value of the MASKED functional runs medianval = pe.MapNode(interface=fsl.ImageStats(op_string='-k %s -p 50'), iterfield=['in_file'], name='compute_median_val') # temporal highpass filtering highpass = pe.MapNode(interface=fsl.ImageMaths(suffix='_tempfilt'), iterfield=['in_file'], name='highpass') # Calculate the z-score of output zscore = pe.MapNode(interface=util.Function( input_names=['image', 'outliers'], output_names=['z_img'], function=z_image), name='z_score', iterfield=['image', 'outliers']) # declare some node inputs... #plot_motion.iterables = ('plot_type', ['rotations', 'translations']) #ad.inputs.parameter_source = 'FSL' meanfunc.inputs.inputspec.parameter_source = 'FSL' ad.inputs.mask_type = 'file' ad.inputs.use_differences = [True, False] getmask.inputs.inputspec.contrast_type = 't2' getmask.inputs.register.out_fsl_file = True fssource = getmask.get_node('fssource') # make connections... preproc.connect(inputnode, 'fssubject_id', getmask, 'inputspec.subject_id') preproc.connect(inputnode, 'ad_normthresh', ad, 'norm_threshold') preproc.connect(inputnode, 'ad_zthresh', ad, 'zintensity_threshold') preproc.connect(inputnode, 'tr', motion_correct, 'tr') preproc.connect(inputnode, 'realign_parameters', motion_correct, 'parameters') preproc.connect(motion_correct, 'parameter_source', ad, 'parameter_source') preproc.connect(inputnode, 'do_slicetime', motion_correct, 'do_slicetime') preproc.connect(inputnode, 'sliceorder', motion_correct, 'sliceorder') preproc.connect(inputnode, 'compcor_select', compcor, 'inputspec.selector') preproc.connect(inputnode, 'fssubject_dir', getmask, 'inputspec.subjects_dir') #preproc.connect(inputnode, 'func', # img2float, 'in_file') preproc.connect(inputnode, 'func', strip_rois, 'in_file') preproc.connect(strip_rois, 'roi_file', img2float, 'in_file') preproc.connect(img2float, 'out_file', despike, "in_file") preproc.connect(despike, "out_file", motion_correct, 'in_file') #preproc.connect(motion_correct, 'par_file', # plot_motion, 'in_file') preproc.connect(motion_correct, 'out_file', meanfunc, 'inputspec.realigned_files') preproc.connect(motion_correct, 'par_file', meanfunc, 'inputspec.realignment_parameters') preproc.connect(meanfunc, 'outputspec.mean_image', getmask, 'inputspec.source_file') preproc.connect(inputnode, 'num_noise_components', compcor, 'inputspec.num_components') preproc.connect(inputnode, 'regress_before_PCA', compcor, 'inputspec.regress_before_PCA') preproc.connect(motion_correct, 'out_file', compcor, 'inputspec.realigned_file') preproc.connect(meanfunc, 'outputspec.mean_image', compcor, 'inputspec.mean_file') preproc.connect(fssource, 'aseg', compcor, 'inputspec.fsaseg_file') preproc.connect(getmask, ('outputspec.reg_file', pickfirst), compcor, 'inputspec.reg_file') preproc.connect(ad, 'outlier_files', compcor, 'inputspec.outlier_files') preproc.connect(motion_correct, 'par_file', compcor, 'inputspec.realignment_parameters') preproc.connect(motion_correct, 'out_file', ad, 'realigned_files') preproc.connect(motion_correct, 'par_file', ad, 'realignment_parameters') preproc.connect(getmask, ('outputspec.mask_file', pickfirst), ad, 'mask_file') preproc.connect(getmask, ('outputspec.mask_file', pickfirst), medianval, 'mask_file') preproc.connect(inputnode_fwhm, 'fwhm', smooth, 'inputnode.fwhm') preproc.connect(motion_correct, 'out_file', smooth, 'inputnode.in_files') preproc.connect(getmask, ('outputspec.mask_file', pickfirst), smooth, 'inputnode.mask_file') preproc.connect(getmask, ('outputspec.reg_file', pickfirst), smooth, 'inputnode.reg_file') preproc.connect(inputnode, 'surface_fwhm', smooth, 'inputnode.surface_fwhm') preproc.connect(inputnode, 'fssubject_dir', smooth, 'inputnode.surf_dir') preproc.connect(smooth, 'outputnode.smoothed_files', choosesusan, 'smoothed_files') preproc.connect(motion_correct, 'out_file', choosesusan, 'motion_files') preproc.connect(inputnode_fwhm, 'fwhm', choosesusan, 'fwhm') preproc.connect(choosesusan, 'cor_smoothed_files', meanscale, 'in_file') preproc.connect(choosesusan, 'cor_smoothed_files', medianval, 'in_file') preproc.connect(medianval, ('out_stat', getmeanscale), meanscale, 'op_string') preproc.connect(inputnode, ('highpass', highpass_operand), highpass, 'op_string') preproc.connect(meanscale, 'out_file', highpass, 'in_file') preproc.connect(highpass, 'out_file', zscore, 'image') preproc.connect(ad, 'outlier_files', zscore, 'outliers') # create output node outputnode = pe.Node(interface=util.IdentityInterface(fields=[ 'mean', 'motion_parameters', 'realigned_files', 'smoothed_files', 'highpassed_files', 'combined_motion', 'outlier_files', 'outlier_stat_files', 'mask', 'reg_cost', 'reg_file', 'reg_fsl_file', 'noise_components', 'tsnr_file', 'stddev_file', 'tsnr_detrended', 'filter_file', 'scaled_files', 'unmasked_fullspectrum', 'z_img', 'motion_plots', 'FM_unwarped_epi', 'FM_unwarped_mean', 'vsm_file', 'bandpassed_file', 'intensity_files', 'noise_mask', 'csf_mask' ]), name='outputspec') # make output connection preproc.connect(meanfunc, 'outputspec.mean_image', outputnode, 'mean') preproc.connect(motion_correct, 'par_file', outputnode, 'motion_parameters') preproc.connect(motion_correct, 'out_file', outputnode, 'realigned_files') preproc.connect(highpass, 'out_file', outputnode, 'highpassed_files') preproc.connect(ad, 'norm_files', outputnode, 'combined_motion') preproc.connect(ad, 'outlier_files', outputnode, 'outlier_files') preproc.connect(ad, 'intensity_files', outputnode, 'intensity_files') preproc.connect(ad, 'statistic_files', outputnode, 'outlier_stat_files') preproc.connect(compcor, 'outputspec.noise_components', outputnode, 'noise_components') preproc.connect(compcor, 'outputspec.noise_mask', outputnode, 'noise_mask') preproc.connect(compcor, 'outputspec.csf_mask', outputnode, 'csf_mask') preproc.connect(getmask, 'outputspec.mask_file', outputnode, 'mask') preproc.connect(getmask, 'register.out_fsl_file', outputnode, 'reg_fsl_file') preproc.connect(getmask, 'outputspec.reg_file', outputnode, 'reg_file') preproc.connect(getmask, 'outputspec.reg_cost', outputnode, 'reg_cost') preproc.connect(choosesusan, 'cor_smoothed_files', outputnode, 'smoothed_files') preproc.connect(compcor, 'outputspec.tsnr_file', outputnode, 'tsnr_file') preproc.connect(compcor, 'outputspec.stddev_file', outputnode, 'stddev_file') preproc.connect(compcor, 'outputspec.tsnr_detrended', outputnode, 'tsnr_detrended') preproc.connect(zscore, 'z_img', outputnode, 'z_img') #preproc.connect(plot_motion,'out_file', # outputnode,'motion_plots') return preproc
def create_eddy_correct_pipeline(name="eddy_correct"): """Creates a pipeline that replaces eddy_correct script in FSL. It takes a series of diffusion weighted images and linearly corregisters them to one reference image. Example ------- >>> nipype_eddycorrect = create_eddy_correct_pipeline("nipype_eddycorrect") >>> nipype_eddycorrect.inputs.inputnode.in_file = 'diffusion.nii' >>> nipype_eddycorrect.inputs.inputnode.ref_num = 0 >>> nipype_eddycorrect.run() # doctest: +SKIP Inputs:: inputnode.in_file inputnode.ref_num Outputs:: outputnode.eddy_corrected """ import nipype.pipeline.engine as pe import nipype.interfaces.utility as util import nipype.interfaces.fsl as fsl inputnode = pe.Node(interface = util.IdentityInterface(fields=["in_file", "bvals"]), name="inputnode") pipeline = pe.Workflow(name=name) split = pe.MapNode(fsl.Split(dimension='t'), name="split", iterfield=['in_file']) pipeline.connect([(inputnode, split, [("in_file", "in_file")])]) getb0 = pe.Node(util.Function(input_names=['bvals'], output_names=['b0'], function=get_b0), name='get_b0_indices') pick_ref = pe.MapNode(util.Select(), name="pick_b0_scans", iterfield=["inlist"]) pick0 = pe.MapNode(util.Select(index=0), name="pick_first_scan", iterfield=["inlist"]) getmotion = pe.MapNode(util.Function(input_names=['flirt_out_mats'], output_names=['motion_params'], function=get_flirt_motion_parameters), name='getmotion', iterfield=['flirt_out_mats']) pipeline.connect(split, 'out_files', pick_ref, "inlist") pipeline.connect(split, 'out_files', pick0, "inlist") pipeline.connect(inputnode,'bvals', getb0, 'bvals') pipeline.connect(getb0, 'b0', pick_ref, "index") #pipeline.connect([(split, pick_ref, [("out_files", "inlist")]), # (inputnode, pick_ref, [("ref_num", "index")])]) coregistration = pe.MapNode(util.Function(input_names=['in_file', 'reference'], output_names=['out_file', 'out_matrix_file'], function = mapnode_coregistration), name = "coregister_b0", iterfield=["in_file","reference"]) pipeline.connect([(pick_ref, coregistration, [("out", "in_file")]), (pick0, coregistration, [("out", "reference")])]) art_mean = art_mean_workflow() art_mean.inputs.inputspec.parameter_source='FSL' pipeline.connect(coregistration,'out_matrix_file', getmotion, 'flirt_out_mats') pipeline.connect(getmotion, 'motion_params', art_mean, 'inputspec.realignment_parameters') merge = pe.MapNode(fsl.Merge(dimension="t"), name="merge", iterfield=["in_files"]) pipeline.connect([(coregistration, merge, [("out_file", "in_files")]) ]) pipeline.connect(merge,'merged_file',art_mean,'inputspec.realigned_files') outputnode = pe.Node(interface = util.IdentityInterface(fields=["eddy_corrected","mean_image","coreg_mat_files"]), name="outputnode") pipeline.connect(art_mean, 'outputspec.mean_image', outputnode, "mean_image") coreg_all = coregistration.clone("coregister_all") pipeline.connect(split, 'out_files', coreg_all, 'in_file') pipeline.connect(art_mean,'outputspec.mean_image',coreg_all,"reference") merge_all = merge.clone("merge_all") pipeline.connect([(coreg_all, merge_all, [("out_file", "in_files")]) ]) pipeline.connect(coreg_all, 'out_matrix_file', outputnode, "coreg_mat_files") pipeline.connect(merge_all,'merged_file',outputnode,"eddy_corrected") return pipeline
def create_prep(name='preproc'): """ Base preprocessing workflow for task and resting state fMRI Parameters ---------- name : name of workflow. Default = 'preproc' Inputs ------ inputspec.fssubject_id : inputspec.fssubject_dir : inputspec.func : inputspec.highpass : inputspec.num_noise_components : inputspec.ad_normthresh : inputspec.ad_zthresh : inputspec.tr : inputspec.interleaved : inputspec.sliceorder : inputspec.compcor_select : inputspec.highpass_sigma : inputspec.lowpass_sigma : inputspec.reg_params : inputspec.FM_TEdiff : inputspec.FM_Echo_spacing : inputspec.FM_sigma : Outputs ------- outputspec.reference : outputspec.motion_parameters : outputspec.realigned_files : outputspec.mask : outputspec.smoothed_files : outputspec.highpassed_files : outputspec.mean : outputspec.combined_motion : outputspec.outlier_files : outputspec.mask : outputspec.reg_cost : outputspec.reg_file : outputspec.noise_components : outputspec.tsnr_file : outputspec.stddev_file : outputspec.filter_file : outputspec.scaled_files : outputspec.z_img : outputspec.motion_plots : outputspec.FM_unwarped_mean : outputspec.FM_unwarped_epi : Returns ------- workflow : preprocessing workflow """ import nipype.interfaces.fsl as fsl # fsl import nipype.algorithms.rapidart as ra # rapid artifact detection from nipype.workflows.smri.freesurfer.utils import create_getmask_flow from modular_nodes import create_mod_smooth, mod_realign, mod_despike import nipype.pipeline.engine as pe import nipype.interfaces.utility as util preproc = pe.Workflow(name=name) # Compcorr node compcor = create_compcorr() # Input node inputnode = pe.Node(util.IdentityInterface(fields=['fssubject_id', 'fssubject_dir', 'func', 'highpass', 'num_noise_components', 'ad_normthresh', 'ad_zthresh', 'tr', 'do_slicetime', 'sliceorder', 'compcor_select', 'highpass_freq', 'lowpass_freq', 'reg_params', 'FM_TEdiff', 'FM_Echo_spacing', 'FM_sigma', 'motion_correct_node', 'smooth_type', 'surface_fwhm', 'filter_type', 'timepoints_to_remove', 'do_whitening', 'regress_before_PCA', 'realign_parameters', 'do_despike', 'anatomical']), name='inputspec') # Separate input node for FWHM inputnode_fwhm = pe.Node(util.IdentityInterface(fields=['fwhm']), name='fwhm_input') # strip ids strip_rois = pe.MapNode(fsl.ExtractROI(),name='extractroi',iterfield='in_file') strip_rois.inputs.t_size = -1 preproc.connect(inputnode,'timepoints_to_remove',strip_rois,'t_min') # convert BOLD images to float img2float = pe.MapNode(interface=fsl.ImageMaths(out_data_type='float', op_string='', suffix='_dtype'), iterfield=['in_file'], name='img2float') #afni despike despike=pe.MapNode(util.Function(input_names=['in_file',"do_despike"], output_names=["out_file"], function=mod_despike), name="despike",iterfield=["in_file"]) preproc.connect(inputnode,"do_despike",despike,"do_despike") # define the motion correction node #motion_correct = pe.Node(interface=FmriRealign4d(), # name='realign') motion_correct = pe.Node(util.Function(input_names=['node','in_file','tr', 'do_slicetime','sliceorder',"parameters"], output_names=['out_file','par_file','parameter_source'], function=mod_realign), name="mod_realign") preproc.connect(inputnode,'motion_correct_node', motion_correct, 'node') # construct motion plots #plot_motion = pe.MapNode(interface=fsl.PlotMotionParams(in_source='fsl'), # name='plot_motion', # iterfield=['in_file']) # rapidArt for artifactual timepoint detection ad = pe.Node(ra.ArtifactDetect(save_plot=False), name='artifactdetect') # extract the mean volume if the first functional run meanfunc = art_mean_workflow() # generate a freesurfer workflow that will return the mask getmask = create_getmask_flow() # create a SUSAN smoothing workflow, and smooth each run with # 75% of the median value for each run as the brightness # threshold. smooth = create_mod_smooth(name="modular_smooth", separate_masks=False) preproc.connect(inputnode,'smooth_type', smooth,'inputnode.smooth_type') # choose susan function """ The following node selects smooth or unsmoothed data depending on the fwhm. This is because SUSAN defaults to smoothing the data with about the voxel size of the input data if the fwhm parameter is less than 1/3 of the voxel size. """ choosesusan = pe.Node(util.Function(input_names=['fwhm', 'motion_files', 'smoothed_files'], output_names=['cor_smoothed_files'], function=choose_susan), name='select_smooth') # scale the median value of each run to 10,000 meanscale = pe.MapNode(interface=fsl.ImageMaths(suffix='_gms'), iterfield=['in_file', 'op_string'], name='scale_median') # determine the median value of the MASKED functional runs medianval = pe.MapNode(interface=fsl.ImageStats(op_string='-k %s -p 50'), iterfield=['in_file'], name='compute_median_val') # temporal highpass filtering highpass = pe.MapNode(interface=fsl.ImageMaths(suffix='_tempfilt'), iterfield=['in_file'], name='highpass') # Calculate the z-score of output zscore = pe.MapNode(interface=util.Function(input_names=['image','outliers'], output_names=['z_img'], function=z_image), name='z_score', iterfield=['image','outliers']) # declare some node inputs... #plot_motion.iterables = ('plot_type', ['rotations', 'translations']) #ad.inputs.parameter_source = 'FSL' meanfunc.inputs.inputspec.parameter_source = 'FSL' ad.inputs.mask_type = 'file' ad.inputs.use_differences = [True, False] getmask.inputs.inputspec.contrast_type = 't2' getmask.inputs.register.out_fsl_file = True fssource = getmask.get_node('fssource') # make connections... preproc.connect(inputnode, 'fssubject_id', getmask, 'inputspec.subject_id') preproc.connect(inputnode, 'ad_normthresh', ad, 'norm_threshold') preproc.connect(inputnode, 'ad_zthresh', ad, 'zintensity_threshold') preproc.connect(inputnode, 'tr', motion_correct, 'tr') preproc.connect(inputnode, 'realign_parameters', motion_correct, 'parameters') preproc.connect(motion_correct,'parameter_source', ad,'parameter_source') preproc.connect(inputnode, 'do_slicetime', motion_correct, 'do_slicetime') preproc.connect(inputnode, 'sliceorder', motion_correct, 'sliceorder') preproc.connect(inputnode, 'compcor_select', compcor, 'inputspec.selector') preproc.connect(inputnode, 'fssubject_dir', getmask, 'inputspec.subjects_dir') #preproc.connect(inputnode, 'func', # img2float, 'in_file') preproc.connect(inputnode, 'func', strip_rois, 'in_file') preproc.connect(strip_rois, 'roi_file', img2float, 'in_file') preproc.connect(img2float, 'out_file', despike, "in_file") preproc.connect(despike,"out_file", motion_correct, 'in_file') #preproc.connect(motion_correct, 'par_file', # plot_motion, 'in_file') preproc.connect(motion_correct, 'out_file', meanfunc, 'inputspec.realigned_files') preproc.connect(motion_correct, 'par_file', meanfunc, 'inputspec.realignment_parameters') preproc.connect(meanfunc, 'outputspec.mean_image', getmask, 'inputspec.source_file') preproc.connect(inputnode, 'num_noise_components', compcor, 'inputspec.num_components') preproc.connect(inputnode, 'regress_before_PCA', compcor, 'inputspec.regress_before_PCA') preproc.connect(motion_correct, 'out_file', compcor, 'inputspec.realigned_file') preproc.connect(meanfunc, 'outputspec.mean_image', compcor, 'inputspec.mean_file') preproc.connect(fssource, 'aseg', compcor, 'inputspec.fsaseg_file') preproc.connect(getmask, ('outputspec.reg_file', pickfirst), compcor, 'inputspec.reg_file') preproc.connect(ad, 'outlier_files', compcor, 'inputspec.outlier_files') preproc.connect(motion_correct, 'par_file', compcor, 'inputspec.realignment_parameters') preproc.connect(motion_correct, 'out_file', ad, 'realigned_files') preproc.connect(motion_correct, 'par_file', ad, 'realignment_parameters') preproc.connect(getmask, ('outputspec.mask_file', pickfirst), ad, 'mask_file') preproc.connect(getmask, ('outputspec.mask_file', pickfirst), medianval, 'mask_file') preproc.connect(inputnode_fwhm, 'fwhm', smooth, 'inputnode.fwhm') preproc.connect(motion_correct, 'out_file', smooth, 'inputnode.in_files') preproc.connect(getmask, ('outputspec.mask_file',pickfirst), smooth, 'inputnode.mask_file') preproc.connect(getmask, ('outputspec.reg_file', pickfirst), smooth, 'inputnode.reg_file') preproc.connect(inputnode,'surface_fwhm', smooth, 'inputnode.surface_fwhm') preproc.connect(inputnode, 'fssubject_dir', smooth, 'inputnode.surf_dir') preproc.connect(smooth, 'outputnode.smoothed_files', choosesusan, 'smoothed_files') preproc.connect(motion_correct, 'out_file', choosesusan, 'motion_files') preproc.connect(inputnode_fwhm, 'fwhm', choosesusan, 'fwhm') preproc.connect(choosesusan, 'cor_smoothed_files', meanscale, 'in_file') preproc.connect(choosesusan, 'cor_smoothed_files', medianval, 'in_file') preproc.connect(medianval, ('out_stat', getmeanscale), meanscale, 'op_string') preproc.connect(inputnode, ('highpass', highpass_operand), highpass, 'op_string') preproc.connect(meanscale, 'out_file', highpass, 'in_file') preproc.connect(highpass, 'out_file', zscore, 'image') preproc.connect(ad, 'outlier_files', zscore, 'outliers') # create output node outputnode = pe.Node(interface=util.IdentityInterface( fields=['mean', 'motion_parameters', 'realigned_files', 'smoothed_files', 'highpassed_files', 'combined_motion', 'outlier_files', 'outlier_stat_files', 'mask', 'reg_cost', 'reg_file', 'reg_fsl_file', 'noise_components', 'tsnr_file', 'stddev_file', 'tsnr_detrended', 'filter_file', 'scaled_files','unmasked_fullspectrum', 'z_img', 'motion_plots', 'FM_unwarped_epi', 'FM_unwarped_mean', 'vsm_file', 'bandpassed_file', 'intensity_files', 'noise_mask', 'csf_mask']), name='outputspec') # make output connection preproc.connect(meanfunc, 'outputspec.mean_image', outputnode, 'mean') preproc.connect(motion_correct, 'par_file', outputnode, 'motion_parameters') preproc.connect(motion_correct, 'out_file', outputnode, 'realigned_files') preproc.connect(highpass, 'out_file', outputnode, 'highpassed_files') preproc.connect(ad, 'norm_files', outputnode, 'combined_motion') preproc.connect(ad, 'outlier_files', outputnode, 'outlier_files') preproc.connect(ad, 'intensity_files', outputnode, 'intensity_files') preproc.connect(ad, 'statistic_files', outputnode, 'outlier_stat_files') preproc.connect(compcor, 'outputspec.noise_components', outputnode, 'noise_components') preproc.connect(compcor, 'outputspec.noise_mask', outputnode, 'noise_mask') preproc.connect(compcor, 'outputspec.csf_mask', outputnode, 'csf_mask') preproc.connect(getmask, 'outputspec.mask_file', outputnode, 'mask') preproc.connect(getmask, 'register.out_fsl_file', outputnode, 'reg_fsl_file') preproc.connect(getmask, 'outputspec.reg_file', outputnode, 'reg_file') preproc.connect(getmask, 'outputspec.reg_cost', outputnode, 'reg_cost') preproc.connect(choosesusan, 'cor_smoothed_files', outputnode, 'smoothed_files') preproc.connect(compcor, 'outputspec.tsnr_file', outputnode, 'tsnr_file') preproc.connect(compcor, 'outputspec.stddev_file', outputnode, 'stddev_file') preproc.connect(compcor, 'outputspec.tsnr_detrended', outputnode, 'tsnr_detrended') preproc.connect(zscore,'z_img', outputnode,'z_img') #preproc.connect(plot_motion,'out_file', # outputnode,'motion_plots') return preproc