コード例 #1
0
def create_structural(subject, working_dir, data_dir, freesurfer_dir, out_dir,
                      standard_brain):

    # main workflow
    struct_preproc = Workflow(name='anat_preproc')
    struct_preproc.base_dir = working_dir
    struct_preproc.config['execution'][
        'crashdump_dir'] = struct_preproc.base_dir + "/crash_files"

    # select files
    #templates={'anat': '3T/nifti/MPRAGEADNI32Ch.nii.gz'}
    #selectfiles = Node(nio.SelectFiles(templates, base_directory=data_dir),    name="selectfiles")

    # workflow to run freesurfer reconall
    reconall = create_reconall_pipeline()
    reconall.inputs.inputnode.fs_subjects_dir = freesurfer_dir
    reconall.inputs.inputnode.fs_subject_id = subject

    # workflow to get brain, head and wmseg from freesurfer and convert to nifti
    mgzconvert = create_mgzconvert_pipeline()
    mgzconvert.inputs.inputnode.fs_subjects_dir = freesurfer_dir
    mgzconvert.inputs.inputnode.fs_subject_id = subject

    normalize = create_normalize_pipeline()
    normalize.inputs.inputnode.standard = standard_brain

    # sink to store files
    sink = Node(nio.DataSink(base_directory=out_dir,
                             parameterization=False,
                             substitutions=[('transform_Warped',
                                             'T1_brain2mni')]),
                name='sink')

    # connections
    struct_preproc.connect([  #(selectfiles, sink, [('anat', 'outputnode.test')]),
        #(selectfiles, reconall, [('anat', 'inputnode.anat')]),
        #(reconall, mgzconvert,  [('outputnode.fs_subject_id', 'inputnode.fs_subject_id'),
        #                         ('outputnode.fs_subjects_dir', 'inputnode.fs_subjects_dir')]),
        #for second round of structural don't redo FREESURFER
        (mgzconvert, normalize, [('outputnode.anat_brain', 'inputnode.anat')]),
        (mgzconvert, sink, [('outputnode.anat_head', '@head')]),
        (mgzconvert, sink, [('outputnode.anat_brain', '@brain')]),
        (mgzconvert, sink, [('outputnode.anat_brain_mask', '@mask')]),
        (mgzconvert, sink, [('outputnode.wmedge', '@wmedge')]),
        (normalize, sink, [('outputnode.anat2std', '@anat2std'),
                           ('outputnode.anat2std_transforms',
                            'transforms2mni.@anat2std_transforms'),
                           ('outputnode.std2anat_transforms',
                            'transforms2mni.@std2anat_transforms')])
    ])

    struct_preproc.write_graph(dotfilename='struct_preproc.dot',
                               graph2use='colored',
                               format='pdf',
                               simple_form=True)
    # struct_preproc.run()
    struct_preproc.run(
    )  #, plugin_args = {'initial_specs': 'request_memory = 1500'}plugin='CondorDAGMan'
コード例 #2
0
def create_structural():

    # main workflow
    struct_preproc = Workflow(name='anat_preproc')
    #struct_preproc.config['execution']['crashdump_dir'] = struct_preproc.base_dir + "/crash_files"
    #inputnode
    inputnode = Node(util.IdentityInterface(fields=[
        'subject', 'anat', 'out_dir', 'freesurfer_dir', 'standard_brain'
    ]),
                     name='inputnode')

    outputnode = Node(util.IdentityInterface(fields=[
        'brain', 'brainmask', 'anat2std_transforms', 'std2anat_transforms',
        'anat2std', 'anat_head', 'wmseg', 'wmedge'
    ]),
                      name='outputnode')

    # workflow to run freesurfer reconall
    reconall = create_reconall_pipeline()

    # workflow to get brain, head and wmseg from freesurfer and convert to nifti
    mgzconvert = create_mgzconvert_pipeline()

    normalize = create_normalize_pipeline()

    # sink to store files
    #sink = Node(nio.DataSink(parameterization=False,
    #                         substitutions=[
    #                             ('transform_Warped', 'T1_brain2mni')]),
    #            name='sink')

    # connections
    struct_preproc.connect([
        (inputnode, reconall, [('anat', 'inputnode.anat')]),
        (inputnode, reconall, [('subject', 'inputnode.fs_subject_id')]),
        (inputnode, reconall, [('freesurfer_dir', 'inputnode.fs_subjects_dir')
                               ]),
        (reconall, mgzconvert,
         [('outputnode.fs_subject_id', 'inputnode.fs_subject_id'),
          ('outputnode.fs_subjects_dir', 'inputnode.fs_subjects_dir')]),
        (inputnode, normalize, [('standard_brain', 'inputnode.standard')]),
        (mgzconvert, normalize, [('outputnode.anat_brain', 'inputnode.anat')]),
        (normalize, outputnode,
         [('outputnode.anat2std', 'anat2std'),
          ('outputnode.anat2std_transforms', 'anat2std_transforms'),
          ('outputnode.std2anat_transforms', 'std2anat_transforms')]),
        (mgzconvert, outputnode, [('outputnode.anat_brain', 'brain')]),
        (mgzconvert, outputnode, [('outputnode.anat_brain_mask', 'brainmask')
                                  ]),
        (mgzconvert, outputnode, [('outputnode.anat_head', 'anat_head')]),
        (mgzconvert, outputnode, [('outputnode.wmseg', 'wmseg')]),
        (mgzconvert, outputnode, [('outputnode.wmedge', 'wmedge')])
    ])

    return struct_preproc
コード例 #3
0
def create_structural(subject, working_dir, data_dir, freesurfer_dir, out_dir, standard_brain):
    # main workflow
    struct_preproc = Workflow(name='anat_preproc')
    struct_preproc.base_dir = working_dir
    struct_preproc.config['execution']['crashdump_dir'] = struct_preproc.base_dir + "/crash_files"


    # workflow to get brain, head and wmseg from freesurfer and convert to nifti
    mgzconvert = create_mgzconvert_pipeline()
    mgzconvert.inputs.inputnode.fs_subjects_dir = freesurfer_dir
    mgzconvert.inputs.inputnode.fs_subject_id = subject

    normalize = create_normalize_pipeline()
    normalize.inputs.inputnode.standard = standard_brain

    # sink to store files
    sink = Node(nio.DataSink(base_directory=out_dir,
                             parameterization=False,
                             substitutions=[
                                 ('transform_Warped', 'T1_brain2mni')]),
                name='sink')

    # connections
    struct_preproc.connect(
        [(mgzconvert, normalize, [('outputnode.anat_brain', 'inputnode.anat')]),
         (mgzconvert, sink, [('outputnode.anat_head', '@head')]),
         (mgzconvert, sink, [('outputnode.anat_brain', '@brain')]),
         (mgzconvert, sink, [('outputnode.anat_brain_mask', '@mask')]),
         (normalize, sink, [('outputnode.anat2std', '@anat2std'),
                            ('outputnode.anat2std_transforms', 'transforms2mni.@anat2std_transforms'),
                            ('outputnode.std2anat_transforms', 'transforms2mni.@std2anat_transforms')])
         ])

    struct_preproc.write_graph(dotfilename='struct_preproc.dot', graph2use='colored', format='pdf', simple_form=True)
    # struct_preproc.run()
    struct_preproc.run(plugin='CondorDAGMan', plugin_args = {'initial_specs': 'request_memory = 1500'})  #
コード例 #4
0
def create_structural(subject, working_dir, data_dir, freesurfer_dir, out_dir,
                      standard_brain):
    # main workflow
    struct_preproc = Workflow(name='anat_preproc')
    struct_preproc.base_dir = working_dir
    struct_preproc.config['execution'][
        'crashdump_dir'] = struct_preproc.base_dir + "/crash_files"

    #########-----------------------------------------------------------#######
    #if freesurfer doesn't exists --> run freesurfer additionally, uncomment
    #########                         this section
    #########-----------------------------------------------------------#######

    # select files
    #templates={'anat': 'anat/MPRAGE_t1.nii'}
    #selectfiles = Node(nio.SelectFiles(templates, base_directory=data_dir),    name="selectfiles")

    # workflow to run freesurfer reconall
    #reconall=create_reconall_pipeline()
    #reconall.inputs.inputnode.fs_subjects_dir=freesurfer_dir
    #reconall.inputs.inputnode.fs_subject_id=subject

    # workflow to get brain, head and wmseg from freesurfer and convert to nifti

    #########-----------------------------------------------------------#######
    #if freesurfer already exists --> start directly with mgzconvert
    #########-----------------------------------------------------------#######
    mgzconvert = create_mgzconvert_pipeline()
    mgzconvert.inputs.inputnode.fs_subjects_dir = freesurfer_dir
    mgzconvert.inputs.inputnode.fs_subject_id = subject

    normalize = create_normalize_pipeline()
    normalize.inputs.inputnode.standard = standard_brain

    #sink to store files
    sink = Node(nio.DataSink(base_directory=out_dir,
                             parameterization=False,
                             substitutions=[('transform_Warped',
                                             'T1_brain2mni')]),
                name='sink')

    # connections
    struct_preproc.connect([

        #########-----------------------------------------------------------#######
        #if freesurfer doesn't exist --> uncomment this section
        #########-----------------------------------------------------------#######
        #(selectfiles, reconall, [('anat', 'inputnode.anat')]),
        #(reconall, mgzconvert,  [('outputnode.fs_subject_id', 'inputnode.fs_subject_id'),
        #                        ('outputnode.fs_subjects_dir', 'inputnode.fs_subjects_dir')]),

        #########-----------------------------------------------------------#######
        #if freesurfer already exists
        #########-----------------------------------------------------------#######
        (mgzconvert, normalize, [('outputnode.anat_brain', 'inputnode.anat')]),
        (mgzconvert, sink, [('outputnode.anat_head',
                             'preprocessed.mod.anat.@head')]),
        (mgzconvert, sink, [('outputnode.anat_brain',
                             'preprocessed.mod.anat.@brain')]),
        (mgzconvert, sink, [('outputnode.anat_brain_mask',
                             'preprocessed.mod.anat.@mask')]),
        (normalize, sink,
         [('outputnode.anat2std', 'preprocessed.mod.anat.@anat2std'),
          ('outputnode.anat2std_transforms',
           'preprocessed.mod.anat.transforms2mni.@anat2std_transforms'),
          ('outputnode.std2anat_transforms',
           'preprocessed.mod.anat.transforms2mni.@std2anat_transforms')])
    ])

    #struct_preproc.write_graph(dotfilename='struct_preproc.dot', graph2use='colored', format='pdf', simple_form=True)

    #struct_preproc.run()
    struct_preproc.run(plugin='CondorDAGMan')  #
コード例 #5
0
def create_structural(subject, working_dir, data_dir, freesurfer_dir, out_dir, standard_brain):
    # main workflow
    struct_preproc = Workflow(name='anat_preproc')   
    struct_preproc.base_dir = working_dir
    struct_preproc.config['execution']['crashdump_dir'] = struct_preproc.base_dir + "/crash_files"
    

    #########-----------------------------------------------------------#######
    #if freesurfer doesn't exists --> run freesurfer additionally, uncomment
    #########                         this section
    #########-----------------------------------------------------------#######    
    
    # select files
    #templates={'anat': 'anat/MPRAGE_t1.nii'}
    #selectfiles = Node(nio.SelectFiles(templates, base_directory=data_dir),    name="selectfiles")
    
    # workflow to run freesurfer reconall
    #reconall=create_reconall_pipeline()
    #reconall.inputs.inputnode.fs_subjects_dir=freesurfer_dir
    #reconall.inputs.inputnode.fs_subject_id=subject
    
 
 
   # workflow to get brain, head and wmseg from freesurfer and convert to nifti  
     
    #########-----------------------------------------------------------#######
    #if freesurfer already exists --> start directly with mgzconvert
    #########-----------------------------------------------------------#######
    mgzconvert=create_mgzconvert_pipeline() 
    mgzconvert.inputs.inputnode.fs_subjects_dir=freesurfer_dir
    mgzconvert.inputs.inputnode.fs_subject_id=subject
   
    

    normalize=create_normalize_pipeline()
    normalize.inputs.inputnode.standard = standard_brain
    
    #sink to store files
    sink = Node(nio.DataSink(base_directory=out_dir,
    parameterization=False,
    substitutions=[
    ('transform_Warped', 'T1_brain2mni')]),
    name='sink')
    
    # connections
    struct_preproc.connect(
    [  
    
    #########-----------------------------------------------------------#######
    #if freesurfer doesn't exist --> uncomment this section
    #########-----------------------------------------------------------#######
    #(selectfiles, reconall, [('anat', 'inputnode.anat')]),   
    #(reconall, mgzconvert,  [('outputnode.fs_subject_id', 'inputnode.fs_subject_id'),
    #                        ('outputnode.fs_subjects_dir', 'inputnode.fs_subjects_dir')]),    
    
    #########-----------------------------------------------------------#######
    #if freesurfer already exists
    #########-----------------------------------------------------------####### 

    (mgzconvert, normalize, [('outputnode.anat_brain', 'inputnode.anat')]),
    (mgzconvert, sink, [('outputnode.anat_head', 'preprocessed.mod.anat.@head')]),
    (mgzconvert, sink, [('outputnode.anat_brain', 'preprocessed.mod.anat.@brain')]),
    (mgzconvert, sink, [('outputnode.anat_brain_mask', 'preprocessed.mod.anat.@mask')]),
    (normalize, sink, [('outputnode.anat2std', 'preprocessed.mod.anat.@anat2std'),
    ('outputnode.anat2std_transforms', 'preprocessed.mod.anat.transforms2mni.@anat2std_transforms'),
    ('outputnode.std2anat_transforms', 'preprocessed.mod.anat.transforms2mni.@std2anat_transforms')])
    ])
    
    
    #struct_preproc.write_graph(dotfilename='struct_preproc.dot', graph2use='colored', format='pdf', simple_form=True)

    #struct_preproc.run()
    struct_preproc.run(plugin='CondorDAGMan')#