def get_surface_workflow(name='surface_1sample'): import nipype.pipeline.engine as pe import nipype.interfaces.freesurfer as fs import nipype.interfaces.io as nio import nipype.interfaces.utility as niu wf = pe.Workflow(name=name) inputspec = pe.Node(niu.IdentityInterface( fields=["copes", "regfiles", "surf_template", "subjects_dir"]), name='inputspec') formatter = pe.Node(niu.Function(input_names=['copes', 'regfiles'], output_names=['out'], function=do_format), name='formatter') preproc = pe.MapNode(fs.MRISPreproc(), name='preproc', iterfield=['hemi']) preproc.inputs.hemi = ['lh', 'rh'] glmfit = pe.MapNode(fs.GLMFit(one_sample=True, surf=True), name='glmfit', iterfield=['hemi', 'in_file']) glmfit.inputs.hemi = ['lh', 'rh'] outputspec = pe.Node(niu.IdentityInterface(fields=[ "beta_file", "dof_file", "error_file", "error_stddev_file", "error_var_file", "estimate_file", "frame_eigenvectors", "ftest_file", "fwhm_file", "gamma_file", "gamma_var_file", "mask_file", "sig_file" ]), name='outputspec') #connections wf.connect(inputspec, 'copes', formatter, 'copes') wf.connect(inputspec, 'regfiles', formatter, 'regfiles') wf.connect(inputspec, 'surf_template', preproc, 'target') wf.connect(inputspec, 'surf_template', glmfit, 'subject_id') wf.connect(inputspec, 'subjects_dir', preproc, 'subjects_dir') wf.connect(inputspec, 'subjects_dir', glmfit, 'subjects_dir') wf.connect(formatter, 'out', preproc, 'vol_measure_file') wf.connect(preproc, 'out_file', glmfit, 'in_file') wf.connect([(glmfit, outputspec, [('beta_file', 'beta_file'), ('dof_file', 'dof_file'), ('error_file', 'error_file'), ('error_stddev_file', 'error_stddev_file'), ('error_var_file', 'error_var_file'), ('estimate_file', 'estimate_file'), ('frame_eigenvectors', 'frame_eigenvectors'), ('ftest_file', 'ftest_file'), ('fwhm_file', 'fwhm_file'), ('gamma_file', 'gamma_file'), ('gamma_var_file', 'gamma_var_file'), ('mask_file', 'mask_file'), ('sig_file', 'sig_file')])]) return wf
if '/%s/' % s in f: outlist.append(f) continue print(outlist) return outlist l2flow.connect(l2source, ('con', ordersubjects, subject_list), mergenode, 'in1') l2flow.connect(l2source, ('reg', ordersubjects, subject_list), mergenode, 'in2') """ Concatenate contrast images projected to fsaverage """ l2concat = pe.Node(interface=fs.MRISPreproc(), name='concat') l2concat.inputs.target = 'fsaverage' l2concat.inputs.fwhm = 5 def list2tuple(listoflist): return [tuple(x) for x in listoflist] l2flow.connect(l2inputnode, 'hemi', l2concat, 'hemi') l2flow.connect(mergenode, ('out', list2tuple), l2concat, 'vol_measure_file') """ Perform a one sample t-test """ l2ttest = pe.Node(interface=fs.OneSampleTTest(), name='onesample')
def test_mrispreproc(): input_map = dict( args=dict(argstr='%s', ), environ=dict(), fsgd_file=dict( xor=('subjects', 'fsgd_file', 'subject_file'), argstr='--fsgd %s', ), fwhm=dict( xor=['num_iters'], argstr='--fwhm %f', ), fwhm_source=dict( xor=['num_iters_source'], argstr='--fwhm-src %f', ), hemi=dict( argstr='--hemi %s', mandatory=True, ), num_iters=dict( xor=['fwhm'], argstr='--niters %d', ), num_iters_source=dict( xor=['fwhm_source'], argstr='--niterssrc %d', ), out_file=dict(argstr='--out %s', ), proj_frac=dict(argstr='--projfrac %s', ), smooth_cortex_only=dict(argstr='--smooth-cortex-only', ), source_format=dict(argstr='--srcfmt %s', ), subject_file=dict( xor=('subjects', 'fsgd_file', 'subject_file'), argstr='--f %s', ), subjects=dict( xor=('subjects', 'fsgd_file', 'subject_file'), argstr='--s %s...', ), subjects_dir=dict(), surf_area=dict( xor=('surf_measure', 'surf_measure_file', 'surf_area'), argstr='--area %s', ), surf_dir=dict(argstr='--surfdir %s', ), surf_measure=dict( xor=('surf_measure', 'surf_measure_file', 'surf_area'), argstr='--meas %s', ), surf_measure_file=dict( xor=('surf_measure', 'surf_measure_file', 'surf_area'), argstr='--is %s...', ), target=dict( mandatory=True, argstr='--target %s', ), vol_measure_file=dict(argstr='--iv %s %s...', ), ) instance = freesurfer.MRISPreproc() for key, metadata in input_map.items(): for metakey, value in metadata.items(): yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value