Example #1
0
def test_blip_distcor():

    # good data to use
    s3_prefix = "s3://fcp-indi/data/Projects/HBN/MRI/Site-CBIC/sub-NDARAB708LM5"
    s3_paths = [
        "func/sub-NDARAB708LM5_task-rest_run-1_bold.nii.gz",
        "fmap/sub-NDARAB708LM5_dir-PA_acq-fMRI_epi.nii.gz",
        "fmap/sub-NDARAB708LM5_dir-AP_acq-fMRI_epi.nii.gz"
    ]

    wf, ds, local_paths = setup_test_wf(s3_prefix, s3_paths,
                                        "test_blip_distcor",
                                        workdirs_to_keep=["func_preproc_automask"])

    func_preproc = create_func_preproc(tool='fsl',
                                       wf_name='func_preproc_automask')
    func_preproc.inputs.inputspec.func = local_paths["func/sub-NDARAB708LM5_task-rest_run-1_bold.nii.gz"]

    blip = blip_distcor_wf("blip_distcor")
    blip.inputs.inputspec.opposite_pe_epi = local_paths["fmap/sub-NDARAB708LM5_dir-PA_acq-fMRI_epi.nii.gz"]
    blip.inputs.inputspec.same_pe_epi = local_paths["fmap/sub-NDARAB708LM5_dir-AP_acq-fMRI_epi.nii.gz"]

    wf.connect(func_preproc, 'outputspec.func_mean',
               blip, 'inputspec.func_mean')

    wf.connect(blip, 'outputspec.blip_warp', ds, 'source_warp')
    wf.connect(blip, 'outputspec.new_func_mean', ds, 'new_func_mean')
    wf.connect(blip, 'outputspec.new_func_mask', ds, 'new_func_mask')

    wf.run()
Example #2
0
def connect_func_preproc(workflow, strat_list, c):

    from CPAC.func_preproc.func_preproc import create_func_preproc

    new_strat_list = []

    for num_strat, strat in enumerate(strat_list):

        for tool in c.functionalMasking:

            tool = tool.lower()

            new_strat = strat.fork()

            func_preproc = create_func_preproc(tool=tool,
                                               wf_name='func_preproc_%s_%d' %
                                               (tool, num_strat))
            node, out_file = new_strat.get_leaf_properties()
            workflow.connect(node, out_file, func_preproc, 'inputspec.func')

            func_preproc.inputs.inputspec.twopass = \
                getattr(c, 'functional_volreg_twopass', True)

            new_strat.append_name(func_preproc.name)
            new_strat.set_leaf_properties(func_preproc,
                                          'outputspec.preprocessed')

            new_strat.update_resource_pool({
                'mean_functional': (func_preproc, 'outputspec.func_mean'),
                'functional_preprocessed_mask':
                (func_preproc, 'outputspec.preprocessed_mask'),
                'movement_parameters':
                (func_preproc, 'outputspec.movement_parameters'),
                'max_displacement':
                (func_preproc, 'outputspec.max_displacement'),
                'functional_preprocessed':
                (func_preproc, 'outputspec.preprocessed'),
                'functional_brain_mask': (func_preproc, 'outputspec.mask'),
                'motion_correct': (func_preproc, 'outputspec.motion_correct'),
                'coordinate_transformation': (func_preproc,
                                              'outputspec.oned_matrix_save'),
            })

            new_strat_list.append(new_strat)

    return workflow, new_strat_list
Example #3
0
def connect_func_preproc(workflow, strat_list, c):

    from CPAC.func_preproc.func_preproc import create_func_preproc

    new_strat_list = []

    for num_strat, strat in enumerate(strat_list):

        nodes = strat.get_nodes_names()

        for skullstrip_tool in c.functionalMasking:

            skullstrip_tool = skullstrip_tool.lower()

            new_strat = strat.fork()

            func_preproc = create_func_preproc(
                skullstrip_tool=skullstrip_tool,
                n4_correction=c.n4_correct_mean_EPI,
                wf_name='func_preproc_%s_%d' % (skullstrip_tool, num_strat))

            node, out_file = new_strat.get_leaf_properties()
            workflow.connect(node, out_file, func_preproc, 'inputspec.func')

            node, out_file = strat['anatomical_reorient']
            workflow.connect(node, out_file, func_preproc,
                             'inputspec.anat_skull')

            node, out_file = strat['anatomical_brain_mask']
            workflow.connect(node, out_file, func_preproc,
                             'inputspec.anatomical_brain_mask')

            func_preproc.inputs.inputspec.twopass = \
                getattr(c, 'functional_volreg_twopass', True)

            new_strat.append_name(func_preproc.name)
            new_strat.set_leaf_properties(func_preproc,
                                          'outputspec.preprocessed')

            if 'gen_motion_stats_before_stc' in nodes:

                new_strat.update_resource_pool({
                    'mean_functional': (func_preproc, 'outputspec.func_mean'),
                    'functional_preprocessed_mask':
                    (func_preproc, 'outputspec.preprocessed_mask'),
                    'functional_preprocessed':
                    (func_preproc, 'outputspec.preprocessed'),
                    'functional_brain_mask': (func_preproc, 'outputspec.mask'),
                    'motion_correct':
                    (func_preproc, 'outputspec.motion_correct'),
                })

            else:

                new_strat.update_resource_pool({
                    'mean_functional': (func_preproc, 'outputspec.func_mean'),
                    'functional_preprocessed_mask':
                    (func_preproc, 'outputspec.preprocessed_mask'),
                    'movement_parameters':
                    (func_preproc, 'outputspec.movement_parameters'),
                    'max_displacement':
                    (func_preproc, 'outputspec.max_displacement'),
                    'functional_preprocessed': (func_preproc,
                                                'outputspec.preprocessed'),
                    'functional_brain_mask': (func_preproc, 'outputspec.mask'),
                    'motion_correct': (func_preproc,
                                       'outputspec.motion_correct'),
                    'coordinate_transformation':
                    (func_preproc, 'outputspec.transform_matrices'),
                })

            new_strat_list.append(new_strat)

    return workflow, new_strat_list