def rs_secondlevel(copes, varcopes, dofs, output_dir, work_dir): from nipype.workflows.fmri.fsl.estimate import create_fixed_effects_flow from nipype.interfaces.fsl import Info level2workflow = pe.Workflow(name="level2workflow") level2workflow.base_dir = work_dir fixedfx = create_fixed_effects_flow() fixedfx.inputs.inputspec.copes = copes fixedfx.inputs.inputspec.varcopes = varcopes fixedfx.inputs.inputspec.dof_files = dofs fixedfx.inputs.l2model.num_copes = len(dofs) fixedfx.inputs.flameo.mask_file = Info.standard_image( 'MNI152_T1_2mm_brain_mask.nii.gz') datasink = pe.Node(nio.DataSink(), name='sinker') datasink.inputs.base_directory = work_dir level2workflow.connect([(fixedfx, datasink, [('outputspec.copes', 'copes'), ('outputspec.varcopes', 'varcopes'), ('outputspec.zstats', 'zstats'), ('gendofvolume.dof_volume', 'dofs')])]) level2workflow.run() #copy data to directory shutil.rmtree(op.join(work_dir, 'level2workflow')) files_to_copy = glob(op.join(work_dir, '*', '_flameo0', '*')) for tmp_fn in files_to_copy: shutil.copy(tmp_fn, output_dir) shutil.copy(op.join(work_dir, 'dofs', 'dof_file.nii.gz'), output_dir) shutil.rmtree(work_dir)
def create_fixedfx(name='fixedfx'): selectnode = pe.Node(interface=util.IdentityInterface(fields=['runs']), name='idselect') selectnode.iterables = ('runs', [range(0,len(c.subjectinfo(c.subjects[0])))]) # this is really bad. copeselect = pe.MapNode(interface=util.Select(), name='copeselect', iterfield=['inlist']) varcopeselect = pe.MapNode(interface=util.Select(), name='varcopeselect', iterfield=['inlist']) dofselect = pe.Node(interface=util.Select(), name='dofselect') infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id','fwhm']), name="infosource") infosource.iterables = [('subject_id', c.subjects), ('fwhm',c.fwhm)] datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id','fwhm'], outfields=['copes', 'varcopes', 'dof_files', 'mask_file']), name = 'datasource') datasource.inputs.base_directory = os.path.join(c.sink_dir,'analyses','func') datasource.inputs.template ='*' datasource.inputs.sort_filelist = True datasource.inputs.field_template = dict(copes='%s/modelfit/contrasts/fwhm_%d/_estimate_contrast*/cope%02d*.nii.gz', varcopes='%s/modelfit/contrasts/fwhm_%d/_estimate_contrast*/varcope%02d*.nii.gz', dof_files='%s/modelfit/dofs/fwhm_%d/*/*', mask_file='%s/preproc/mask/*.nii') fixedfx = create_fixed_effects_flow() fixedfxflow = pe.Workflow(name=name) fixedfxflow.config = {'execution' : {'crashdump_dir' : c.crash_dir}} overlay = create_overlay_workflow(name='overlay') fixedfxflow.connect(infosource, 'subject_id', datasource, 'subject_id') fixedfxflow.connect(infosource, ('subject_id',getinfo, c.getcontrasts, c.subjectinfo), datasource, 'template_args') fixedfxflow.connect(infosource, 'fwhm', datasource, 'fwhm') fixedfxflow.connect(datasource,'copes', copeselect,'inlist') fixedfxflow.connect(selectnode,'runs', copeselect,'index') fixedfxflow.connect(datasource,'copes', fixedfx,'inputspec.copes') fixedfxflow.connect(datasource,'varcopes', varcopeselect,'inlist') fixedfxflow.connect(selectnode,'runs', varcopeselect,'index') fixedfxflow.connect(datasource,'varcopes', fixedfx,'inputspec.varcopes') fixedfxflow.connect(datasource,'dof_files', dofselect,'inlist') fixedfxflow.connect(selectnode,'runs', dofselect,'index') fixedfxflow.connect(datasource,'dof_files', fixedfx,'inputspec.dof_files') fixedfxflow.connect(datasource,('copes',num_copes), fixedfx,'l2model.num_copes') fixedfxflow.connect(datasource,'mask_file', fixedfx,'flameo.mask_file') fixedfxflow.connect(infosource, 'subject_id', overlay, 'inputspec.subject_id') fixedfxflow.connect(infosource, 'fwhm', overlay, 'inputspec.fwhm') fixedfxflow.connect(fixedfx, 'outputspec.zstats', overlay, 'inputspec.stat_image') datasink = pe.Node(interface=nio.DataSink(), name="datasink") datasink.inputs.base_directory = os.path.join(c.sink_dir,'analyses','func') # store relevant outputs from various stages of the 1st level analysis fixedfxflow.connect([(infosource, datasink,[('subject_id','container'), (('subject_id', getsubs, c.getcontrasts), 'substitutions') ]), (fixedfx, datasink,[('outputspec.copes','fixedfx.@copes'), ('outputspec.varcopes','fixedfx.@varcopes'), ('outputspec.tstats','fixedfx.@tstats'), ('outputspec.zstats','fixedfx.@zstats'), ('outputspec.res4d','fixedfx.@pvals'), ]) ]) fixedfxflow.connect(overlay, 'slicestats.out_file', datasink, 'overlays') return fixedfxflow
def create_fixedfx(c, first_c=foo0, name='fixedfx'): from nipype.workflows.fmri.fsl.estimate import create_fixed_effects_flow import nipype.interfaces.io as nio # i/o routines import nipype.interfaces.utility as util # utility import nipype.pipeline.engine as pe # pypeline engine copeselect = pe.MapNode(interface=util.Select(), name='copeselect', iterfield=['inlist','index']) varcopeselect = pe.MapNode(interface=util.Select(), name='varcopeselect', iterfield=['inlist','index']) dofselect = pe.MapNode(interface=util.Select(), name='dofselect',iterfield=['inlist','index']) datasource = c.datagrabber.create_dataflow() infosource = datasource.get_node('subject_id_iterable') selectnode = pe.Node(interface=util.IdentityInterface(fields=['runs']), name='idselect') #selectnode.iterables = ('runs', [range(0,c.num_runs)]) # this is really bad. fixedfx = create_fixed_effects_flow() fixedfxflow = pe.Workflow(name=name) fixedfxflow.config = {'execution' : {'crashdump_dir' : c.crash_dir}} fixedfxflow.connect(datasource,('datagrabber.copes',num_copes_range), selectnode, 'runs') #overlay = create_overlay_workflow(c,name='overlay') #subjectinfo = pe.Node(util.Function(input_names=['subject_id'], output_names=['output']), name='subjectinfo') #subjectinfo.inputs.function_str = first_c.subjectinfo def getcontrasts(data_inputs): import os infiles = [os.path.split(d[0])[1] for d in data_inputs] contrasts = [inf[7:].split('.nii')[0] for inf in infiles] print contrasts return contrasts #if first_c.uuid.startswith('8e'): # print "Using 8e contrasts!!" # contrasts = pe.Node(util.Function(input_names=['subject_id'], output_names=['contrasts']), name='getcontrasts') # contrasts.inputs.function_str = first_c.contrasts # fixedfxflow.connect(infosource, 'subject_id', contrasts, 'subject_id') #else: contrasts = pe.Node(util.Function(input_names=['data_inputs'], output_names=['contrasts'],function=getcontrasts), name='getcontrasts') fixedfxflow.connect(datasource,('datagrabber.copes',doublelist), contrasts,'data_inputs') #get_info = pe.Node(util.Function(input_names=['cons','info'], output_names=['info'], function=getinfo), name='getinfo') get_subs = pe.Node(util.Function(input_names=['subject_id','cons'], output_names=['subs'], function=getsubs), name='getsubs') #fixedfxflow.connect(infosource, 'subject_id', datasource, 'subject_id') #fixedfxflow.connect(infosource, ('subject_id',getinfo, c.getcontrasts, c.subjectinfo), datasource, 'template_args') #fixedfxflow.connect(infosource, 'subject_id', subjectinfo, 'subject_id') #fixedfxflow.connect(contrasts, 'contrasts', get_info, 'cons') #fixedfxflow.connect(subjectinfo, 'output', get_info, 'info') #fixedfxflow.connect(get_info,'info',datasource,'template_args') #fixedfxflow.connect(infosource, 'fwhm', datasource, 'fwhm') #fixedfxflow.connect(datasource,('datagrabber.copes',doublelist), copeselect,'inlist') #fixedfxflow.connect(selectnode,'runs', copeselect,'index') fixedfxflow.connect(datasource,('datagrabber.copes',doublelist), fixedfx,'inputspec.copes') #fixedfxflow.connect(datasource,('datagrabber.varcopes',doublelist), varcopeselect,'inlist') #fixedfxflow.connect(selectnode,'runs', varcopeselect,'index') fixedfxflow.connect(datasource,('datagrabber.varcopes',doublelist), fixedfx,'inputspec.varcopes') #fixedfxflow.connect(datasource,'datagrabber.dof_files', dofselect,'inlist') #fixedfxflow.connect(selectnode,'runs', dofselect,'index') fixedfxflow.connect(datasource,'datagrabber.dof_files', fixedfx,'inputspec.dof_files') fixedfxflow.connect(datasource,('datagrabber.copes',num_copes), fixedfx,'l2model.num_copes') fixedfxflow.connect(datasource,'datagrabber.mask_file', fixedfx,'flameo.mask_file') #fixedfxflow.connect(infosource, 'subject_id', overlay, 'inputspec.subject_id') #fixedfxflow.connect(infosource, 'fwhm', overlay, 'inputspec.fwhm') #fixedfxflow.connect(fixedfx, 'outputspec.zstats', overlay, 'inputspec.stat_image') datasink = pe.Node(interface=nio.DataSink(), name="datasink") datasink.inputs.base_directory = c.sink_dir # store relevant outputs from various stages of the 1st level analysis fixedfxflow.connect([(infosource, datasink,[('subject_id','container'), #(('subject_id', getsubs, c.getcontrasts), 'substitutions') ]), (fixedfx, datasink,[('outputspec.copes','fixedfx.@copes'), ('outputspec.varcopes','fixedfx.@varcopes'), ('outputspec.tstats','fixedfx.@tstats'), ('outputspec.zstats','fixedfx.@zstats'), ('outputspec.res4d','fixedfx.@pvals'), ]) ]) fixedfxflow.connect(infosource,'subject_id', get_subs, 'subject_id') fixedfxflow.connect(contrasts,'contrasts', get_subs, 'cons') fixedfxflow.connect(get_subs, 'subs', datasink, 'substitutions') #fixedfxflow.connect(overlay, 'slicestats.out_file', datasink, 'overlays') return fixedfxflow
def create_fixedfx(c, first_c=foo0, name='fixedfx'): from nipype.workflows.fmri.fsl.estimate import create_fixed_effects_flow import nipype.interfaces.io as nio # i/o routines import nipype.interfaces.utility as util # utility import nipype.pipeline.engine as pe # pypeline engine selectnode = pe.Node(interface=util.IdentityInterface(fields=['runs']), name='idselect') selectnode.iterables = ('runs', [range(0, c.num_runs)]) # this is really bad. copeselect = pe.MapNode(interface=util.Select(), name='copeselect', iterfield=['inlist']) varcopeselect = pe.MapNode(interface=util.Select(), name='varcopeselect', iterfield=['inlist']) dofselect = pe.Node(interface=util.Select(), name='dofselect') """if c.test_mode: infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id','fwhm']), name="infosource") infosource.iterables = [('subject_id', [c.subjects[0]]), ('fwhm',prep_c.fwhm)] else: infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id','fwhm']), name="infosource") infosource.iterables = [('subject_id', c.subjects),('fwhm',prep_c.fwhm)] datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id','fwhm'], outfields=['copes', 'varcopes', 'dof_files', 'mask_file']), name = 'datasource') datasource.inputs.base_directory = c.sink_dir datasource.inputs.template ='*' datasource.inputs.sort_filelist = True datasource.inputs.field_template = dict(copes='%s/modelfit/contrasts/fwhm_%s/_estimate_contrast*/cope%02d*.nii*', varcopes='%s/modelfit/contrasts/fwhm_%s/_estimate_contrast*/varcope%02d*.nii*', dof_files='%s/modelfit/dofs/fwhm_%s/*/*', mask_file='%s/preproc/mask/*.nii*')""" datasource = c.datagrabber.create_dataflow() infosource = datasource.get_node('subject_id_iterable') fixedfx = create_fixed_effects_flow() fixedfxflow = pe.Workflow(name=name) fixedfxflow.config = {'execution': {'crashdump_dir': c.crash_dir}} #overlay = create_overlay_workflow(c,name='overlay') subjectinfo = pe.Node(util.Function(input_names=['subject_id'], output_names=['output']), name='subjectinfo') subjectinfo.inputs.function_str = first_c.subjectinfo contrasts = pe.Node(util.Function(input_names=['subject_id'], output_names=['contrasts']), name='getcontrasts') contrasts.inputs.function_str = first_c.contrasts #get_info = pe.Node(util.Function(input_names=['cons','info'], output_names=['info'], function=getinfo), name='getinfo') get_subs = pe.Node(util.Function(input_names=['subject_id', 'cons'], output_names=['subs'], function=getsubs), name='getsubs') #fixedfxflow.connect(infosource, 'subject_id', datasource, 'subject_id') #fixedfxflow.connect(infosource, ('subject_id',getinfo, c.getcontrasts, c.subjectinfo), datasource, 'template_args') fixedfxflow.connect(infosource, 'subject_id', contrasts, 'subject_id') fixedfxflow.connect(infosource, 'subject_id', subjectinfo, 'subject_id') #fixedfxflow.connect(contrasts, 'contrasts', get_info, 'cons') #fixedfxflow.connect(subjectinfo, 'output', get_info, 'info') #fixedfxflow.connect(get_info,'info',datasource,'template_args') #fixedfxflow.connect(infosource, 'fwhm', datasource, 'fwhm') fixedfxflow.connect(datasource, 'datagrabber.copes', copeselect, 'inlist') fixedfxflow.connect(selectnode, 'runs', copeselect, 'index') fixedfxflow.connect(datasource, 'datagrabber.copes', fixedfx, 'inputspec.copes') fixedfxflow.connect(datasource, 'datagrabber.varcopes', varcopeselect, 'inlist') fixedfxflow.connect(selectnode, 'runs', varcopeselect, 'index') fixedfxflow.connect(datasource, 'datagrabber.varcopes', fixedfx, 'inputspec.varcopes') fixedfxflow.connect(datasource, 'datagrabber.dof_files', dofselect, 'inlist') fixedfxflow.connect(selectnode, 'runs', dofselect, 'index') fixedfxflow.connect(datasource, 'datagrabber.dof_files', fixedfx, 'inputspec.dof_files') fixedfxflow.connect(datasource, ('datagrabber.copes', num_copes), fixedfx, 'l2model.num_copes') fixedfxflow.connect(datasource, 'datagrabber.mask_file', fixedfx, 'flameo.mask_file') #fixedfxflow.connect(infosource, 'subject_id', overlay, 'inputspec.subject_id') #fixedfxflow.connect(infosource, 'fwhm', overlay, 'inputspec.fwhm') #fixedfxflow.connect(fixedfx, 'outputspec.zstats', overlay, 'inputspec.stat_image') datasink = pe.Node(interface=nio.DataSink(), name="datasink") datasink.inputs.base_directory = c.sink_dir # store relevant outputs from various stages of the 1st level analysis fixedfxflow.connect([ ( infosource, datasink, [ ('subject_id', 'container'), #(('subject_id', getsubs, c.getcontrasts), 'substitutions') ]), (fixedfx, datasink, [ ('outputspec.copes', 'fixedfx.@copes'), ('outputspec.varcopes', 'fixedfx.@varcopes'), ('outputspec.tstats', 'fixedfx.@tstats'), ('outputspec.zstats', 'fixedfx.@zstats'), ('outputspec.res4d', 'fixedfx.@pvals'), ]) ]) fixedfxflow.connect(infosource, 'subject_id', get_subs, 'subject_id') fixedfxflow.connect(contrasts, 'contrasts', get_subs, 'cons') fixedfxflow.connect(get_subs, 'subs', datasink, 'substitutions') #fixedfxflow.connect(overlay, 'slicestats.out_file', datasink, 'overlays') return fixedfxflow
meta_workflow.connect([ (selector, modelfit_workflow, [('epi', 'inputspec.functional_data')]), (session_info_getter, specifymodel, [('session_info', 'subject_info'),]), (selector, specifymodel, [('epi', 'functional_runs'),]), (selector, specifymodel, [('realignment_parameters', 'realignment_parameters'),]), (specifymodel, modelfit_workflow, [('session_info', 'inputspec.session_info'),]) ]) fixedfx = create_fixed_effects_flow() def get_first(list_in): return list_in[0] meta_workflow.connect(selector, ('mask', get_first), fixedfx, 'flameo.mask_file') def num_copes(files): return len(files) def transpose_copes(copes): import numpy as np return np.array(copes).T.tolist() meta_workflow.connect([(modelfit_workflow, fixedfx, [(('outputspec.copes', transpose_copes), 'inputspec.copes'),
def create_fixedfx(c, first_c=foo0, name="fixedfx"): from nipype.workflows.fmri.fsl.estimate import create_fixed_effects_flow import nipype.interfaces.io as nio # i/o routines import nipype.interfaces.utility as util # utility import nipype.pipeline.engine as pe # pypeline engine selectnode = pe.Node(interface=util.IdentityInterface(fields=["runs"]), name="idselect") selectnode.iterables = ("runs", [range(0, c.num_runs)]) # this is really bad. copeselect = pe.MapNode(interface=util.Select(), name="copeselect", iterfield=["inlist"]) varcopeselect = pe.MapNode(interface=util.Select(), name="varcopeselect", iterfield=["inlist"]) dofselect = pe.Node(interface=util.Select(), name="dofselect") """if c.test_mode: infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id','fwhm']), name="infosource") infosource.iterables = [('subject_id', [c.subjects[0]]), ('fwhm',prep_c.fwhm)] else: infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id','fwhm']), name="infosource") infosource.iterables = [('subject_id', c.subjects),('fwhm',prep_c.fwhm)] datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id','fwhm'], outfields=['copes', 'varcopes', 'dof_files', 'mask_file']), name = 'datasource') datasource.inputs.base_directory = c.sink_dir datasource.inputs.template ='*' datasource.inputs.sort_filelist = True datasource.inputs.field_template = dict(copes='%s/modelfit/contrasts/fwhm_%s/_estimate_contrast*/cope%02d*.nii*', varcopes='%s/modelfit/contrasts/fwhm_%s/_estimate_contrast*/varcope%02d*.nii*', dof_files='%s/modelfit/dofs/fwhm_%s/*/*', mask_file='%s/preproc/mask/*.nii*')""" datasource = c.datagrabber.create_dataflow() infosource = datasource.get_node("subject_id_iterable") fixedfx = create_fixed_effects_flow() fixedfxflow = pe.Workflow(name=name) fixedfxflow.config = {"execution": {"crashdump_dir": c.crash_dir}} # overlay = create_overlay_workflow(c,name='overlay') subjectinfo = pe.Node(util.Function(input_names=["subject_id"], output_names=["output"]), name="subjectinfo") subjectinfo.inputs.function_str = first_c.subjectinfo contrasts = pe.Node(util.Function(input_names=["subject_id"], output_names=["contrasts"]), name="getcontrasts") contrasts.inputs.function_str = first_c.contrasts # get_info = pe.Node(util.Function(input_names=['cons','info'], output_names=['info'], function=getinfo), name='getinfo') get_subs = pe.Node( util.Function(input_names=["subject_id", "cons"], output_names=["subs"], function=getsubs), name="getsubs" ) # fixedfxflow.connect(infosource, 'subject_id', datasource, 'subject_id') # fixedfxflow.connect(infosource, ('subject_id',getinfo, c.getcontrasts, c.subjectinfo), datasource, 'template_args') fixedfxflow.connect(infosource, "subject_id", contrasts, "subject_id") fixedfxflow.connect(infosource, "subject_id", subjectinfo, "subject_id") # fixedfxflow.connect(contrasts, 'contrasts', get_info, 'cons') # fixedfxflow.connect(subjectinfo, 'output', get_info, 'info') # fixedfxflow.connect(get_info,'info',datasource,'template_args') # fixedfxflow.connect(infosource, 'fwhm', datasource, 'fwhm') fixedfxflow.connect(datasource, "datagrabber.copes", copeselect, "inlist") fixedfxflow.connect(selectnode, "runs", copeselect, "index") fixedfxflow.connect(datasource, "datagrabber.copes", fixedfx, "inputspec.copes") fixedfxflow.connect(datasource, "datagrabber.varcopes", varcopeselect, "inlist") fixedfxflow.connect(selectnode, "runs", varcopeselect, "index") fixedfxflow.connect(datasource, "datagrabber.varcopes", fixedfx, "inputspec.varcopes") fixedfxflow.connect(datasource, "datagrabber.dof_files", dofselect, "inlist") fixedfxflow.connect(selectnode, "runs", dofselect, "index") fixedfxflow.connect(datasource, "datagrabber.dof_files", fixedfx, "inputspec.dof_files") fixedfxflow.connect(datasource, ("datagrabber.copes", num_copes), fixedfx, "l2model.num_copes") fixedfxflow.connect(datasource, "datagrabber.mask_file", fixedfx, "flameo.mask_file") # fixedfxflow.connect(infosource, 'subject_id', overlay, 'inputspec.subject_id') # fixedfxflow.connect(infosource, 'fwhm', overlay, 'inputspec.fwhm') # fixedfxflow.connect(fixedfx, 'outputspec.zstats', overlay, 'inputspec.stat_image') datasink = pe.Node(interface=nio.DataSink(), name="datasink") datasink.inputs.base_directory = c.sink_dir # store relevant outputs from various stages of the 1st level analysis fixedfxflow.connect( [ ( infosource, datasink, [ ("subject_id", "container"), # (('subject_id', getsubs, c.getcontrasts), 'substitutions') ], ), ( fixedfx, datasink, [ ("outputspec.copes", "fixedfx.@copes"), ("outputspec.varcopes", "fixedfx.@varcopes"), ("outputspec.tstats", "fixedfx.@tstats"), ("outputspec.zstats", "fixedfx.@zstats"), ("outputspec.res4d", "fixedfx.@pvals"), ], ), ] ) fixedfxflow.connect(infosource, "subject_id", get_subs, "subject_id") fixedfxflow.connect(contrasts, "contrasts", get_subs, "cons") fixedfxflow.connect(get_subs, "subs", datasink, "substitutions") # fixedfxflow.connect(overlay, 'slicestats.out_file', datasink, 'overlays') return fixedfxflow
def create_fixedfx(c, first_c=foo0, name='fixedfx'): from nipype.workflows.fmri.fsl.estimate import create_fixed_effects_flow import nipype.interfaces.io as nio # i/o routines import nipype.interfaces.utility as util # utility import nipype.pipeline.engine as pe # pypeline engine copeselect = pe.MapNode(interface=util.Select(), name='copeselect', iterfield=['inlist', 'index']) varcopeselect = pe.MapNode(interface=util.Select(), name='varcopeselect', iterfield=['inlist', 'index']) dofselect = pe.MapNode(interface=util.Select(), name='dofselect', iterfield=['inlist', 'index']) datasource = c.datagrabber.create_dataflow() infosource = datasource.get_node('subject_id_iterable') selectnode = pe.Node(interface=util.IdentityInterface(fields=['runs']), name='idselect') #selectnode.iterables = ('runs', [range(0,c.num_runs)]) # this is really bad. fixedfx = create_fixed_effects_flow() fixedfxflow = pe.Workflow(name=name) fixedfxflow.config = {'execution': {'crashdump_dir': c.crash_dir}} fixedfxflow.connect(datasource, ('datagrabber.copes', num_copes_range), selectnode, 'runs') #overlay = create_overlay_workflow(c,name='overlay') #subjectinfo = pe.Node(util.Function(input_names=['subject_id'], output_names=['output']), name='subjectinfo') #subjectinfo.inputs.function_str = first_c.subjectinfo def getcontrasts(data_inputs): import os infiles = [os.path.split(d[0])[1] for d in data_inputs] contrasts = [inf[7:].split('.nii')[0] for inf in infiles] print contrasts return contrasts #if first_c.uuid.startswith('8e'): # print "Using 8e contrasts!!" # contrasts = pe.Node(util.Function(input_names=['subject_id'], output_names=['contrasts']), name='getcontrasts') # contrasts.inputs.function_str = first_c.contrasts # fixedfxflow.connect(infosource, 'subject_id', contrasts, 'subject_id') #else: contrasts = pe.Node(util.Function(input_names=['data_inputs'], output_names=['contrasts'], function=getcontrasts), name='getcontrasts') fixedfxflow.connect(datasource, ('datagrabber.copes', doublelist), contrasts, 'data_inputs') #get_info = pe.Node(util.Function(input_names=['cons','info'], output_names=['info'], function=getinfo), name='getinfo') get_subs = pe.Node(util.Function(input_names=['subject_id', 'cons'], output_names=['subs'], function=getsubs), name='getsubs') #fixedfxflow.connect(infosource, 'subject_id', datasource, 'subject_id') #fixedfxflow.connect(infosource, ('subject_id',getinfo, c.getcontrasts, c.subjectinfo), datasource, 'template_args') #fixedfxflow.connect(infosource, 'subject_id', subjectinfo, 'subject_id') #fixedfxflow.connect(contrasts, 'contrasts', get_info, 'cons') #fixedfxflow.connect(subjectinfo, 'output', get_info, 'info') #fixedfxflow.connect(get_info,'info',datasource,'template_args') #fixedfxflow.connect(infosource, 'fwhm', datasource, 'fwhm') #fixedfxflow.connect(datasource,('datagrabber.copes',doublelist), copeselect,'inlist') #fixedfxflow.connect(selectnode,'runs', copeselect,'index') fixedfxflow.connect(datasource, ('datagrabber.copes', doublelist), fixedfx, 'inputspec.copes') #fixedfxflow.connect(datasource,('datagrabber.varcopes',doublelist), varcopeselect,'inlist') #fixedfxflow.connect(selectnode,'runs', varcopeselect,'index') fixedfxflow.connect(datasource, ('datagrabber.varcopes', doublelist), fixedfx, 'inputspec.varcopes') #fixedfxflow.connect(datasource,'datagrabber.dof_files', dofselect,'inlist') #fixedfxflow.connect(selectnode,'runs', dofselect,'index') fixedfxflow.connect(datasource, 'datagrabber.dof_files', fixedfx, 'inputspec.dof_files') fixedfxflow.connect(datasource, ('datagrabber.copes', num_copes), fixedfx, 'l2model.num_copes') fixedfxflow.connect(datasource, 'datagrabber.mask_file', fixedfx, 'flameo.mask_file') #fixedfxflow.connect(infosource, 'subject_id', overlay, 'inputspec.subject_id') #fixedfxflow.connect(infosource, 'fwhm', overlay, 'inputspec.fwhm') #fixedfxflow.connect(fixedfx, 'outputspec.zstats', overlay, 'inputspec.stat_image') datasink = pe.Node(interface=nio.DataSink(), name="datasink") datasink.inputs.base_directory = c.sink_dir # store relevant outputs from various stages of the 1st level analysis fixedfxflow.connect([ ( infosource, datasink, [ ('subject_id', 'container'), #(('subject_id', getsubs, c.getcontrasts), 'substitutions') ]), (fixedfx, datasink, [ ('outputspec.copes', 'fixedfx.@copes'), ('outputspec.varcopes', 'fixedfx.@varcopes'), ('outputspec.tstats', 'fixedfx.@tstats'), ('outputspec.zstats', 'fixedfx.@zstats'), ('outputspec.res4d', 'fixedfx.@pvals'), ]) ]) fixedfxflow.connect(infosource, 'subject_id', get_subs, 'subject_id') fixedfxflow.connect(contrasts, 'contrasts', get_subs, 'cons') fixedfxflow.connect(get_subs, 'subs', datasink, 'substitutions') #fixedfxflow.connect(overlay, 'slicestats.out_file', datasink, 'overlays') return fixedfxflow