Ejemplo n.º 1
0
def test_fsl_apply_transform_func_to_mni_linear_mapnode():

    c, strat = configuration_strategy_mock(method='FSL')

    strat.append_name('anat_mni_flirt_register_0')

    # build the workflow
    workflow = pe.Workflow(
        name='test_fsl_apply_transform_func_to_mni_linear_mapnode')
    workflow.base_dir = c.workingDirectory
    workflow.config['execution'] = {
        'hash_method': 'timestamp',
        'crashdump_dir': os.path.abspath(c.crashLogDirectory)
    }

    workflow = fsl_apply_transform_func_to_mni(
        workflow,
        'dr_tempreg_to_standard',
        'dr_tempreg_maps_files',
        'template_brain_for_func_preproc',
        0,
        strat,
        c.funcRegFSLinterpolation,
        map_node=True)

    workflow.run()
Ejemplo n.º 2
0
def test_ants_apply_warp_func_mni_symm():

    test_name = 'test_ants_apply_warps_func_mni_symm'

    # get the config and strat for the mock
    c, strat = configuration_strategy_mock()
    num_strat = 0

    node, out = strat['mean_functional']
    mean_functional = node.inputs.file

    # build the workflow
    workflow = pe.Workflow(name=test_name)
    workflow.base_dir = c.workingDirectory
    workflow.config['execution'] = {
        'hash_method': 'timestamp',
        'crashdump_dir': os.path.abspath(c.crashLogDirectory)
    }

    workflow = ants_apply_warps_func_mni(
        workflow,
        'mean_functional_to_standard_symm',
        'mean_functional',
        'template_brain_for_func_preproc',
        num_strat,
        strat,
        interpolation_method=c.funcRegANTSinterpolation,
        distcor=False,
        map_node=False,
        inverse=False,
        symmetry='symmetric',
        input_image_type=0,
        num_ants_cores=8)

    workflow = ants_apply_warps_func_mni(
        workflow,
        'mean_functional_standard_to_original_symm',
        'mean_functional_to_standard_symm',
        'mean_functional',
        num_strat,
        strat,
        interpolation_method=c.funcRegANTSinterpolation,
        distcor=False,
        map_node=False,
        inverse=True,
        symmetry='symmetric',
        input_image_type=0,
        num_ants_cores=1)

    retval = workflow.run()

    mean_functional_after_transform = os.path.join(
        c.workingDirectory, test_name,
        'apply_ants_warp_mean_functional_standard_to_original_symm_inverse_0',
        'sub-M10978008_ses-NFB3_task-test_bold_calc_tshift_resample_volreg_calc_tstat_antswarp_antswarp.nii.gz'
    )

    assert (test_utils.pearson_correlation(
        mean_functional, mean_functional_after_transform) > .93)
def test_output_func_to_standard_FSL_nonlinear():

    test_name = 'test_output_func_to_standard_FSL_nonlinear'

    # get the config and strat for the mock
    c, strat = configuration_strategy_mock(method='FSL')
    strat.append_name('anat_mni_fnirt_register_0')
    num_strat = 0

    # build the workflow
    workflow = pe.Workflow(name='test_output_func_to_standard_FSL_nonlinear')
    workflow.base_dir = c.workingDirectory
    workflow.config['execution'] = {
        'hash_method': 'timestamp',
        'crashdump_dir': os.path.abspath(c.crashLogDirectory)
    }

    output_func_to_standard(workflow,
            'mean_functional',
            'template_brain_for_func_preproc',
            'mean_functional_to_standard',
            strat, num_strat, c, input_image_type='func_derivative')

    out1_name = os.path.join(c.workingDirectory, test_name, 
            'func_mni_fsl_warp_mean_functional_to_standard_0',
            'sub-M10978008_ses-NFB3_task-test_bold_calc_tshift_resample_volreg_calc_tstat_warp.nii.gz')

    node, out_file = strat['mean_functional']
    output_func_to_standard(workflow,
            (node, out_file),
            'template_brain_for_func_preproc',
            'mean_functional_to_standard_node',
            strat, num_strat, c, input_image_type='func_derivative')

    out2_name = os.path.join(c.workingDirectory, test_name, 
            'func_mni_fsl_warp_mean_functional_to_standard_node_0',
            'sub-M10978008_ses-NFB3_task-test_bold_calc_tshift_resample_volreg_calc_tstat_warp.nii.gz')

    workflow.run()

    assert(test_utils.pearson_correlation(out1_name, out2_name) > .99)
Ejemplo n.º 4
0
def test_ants_apply_warps_func_mni_mapnode():

    test_name = 'test_ants_apply_warps_func_mni_mapnode'

    # get the config and strat for the mock
    c, strat = configuration_strategy_mock()
    num_strat = 0

    node, out = strat['dr_tempreg_maps_files']
    dr_spatmaps = node.inputs.file

    # build the workflow
    workflow = pe.Workflow(name='test_ants_apply_warps_func_mni_mapnode')
    workflow.base_dir = c.workingDirectory
    workflow.config['execution'] = {
        'hash_method': 'timestamp',
        'crashdump_dir': os.path.abspath(c.crashLogDirectory)
    }

    workflow = ants_apply_warps_func_mni(
        workflow,
        'dr_tempreg_maps_to_standard',
        'dr_tempreg_maps_files',
        'template_brain_for_func_preproc',
        num_strat,
        strat,
        interpolation_method=c.funcRegANTSinterpolation,
        distcor=False,
        map_node=True,
        inverse=False,
        input_image_type=0,
        num_ants_cores=1)

    workflow = ants_apply_warps_func_mni(
        workflow,
        'dr_tempreg_maps_standard_to_original',
        'dr_tempreg_maps_to_standard',
        'mean_functional',
        num_strat,
        strat,
        interpolation_method=c.funcRegANTSinterpolation,
        distcor=False,
        map_node=True,
        inverse=True,
        input_image_type=0,
        num_ants_cores=8)

    workflow.run()

    dr_spatmaps_after_transform = [
        os.path.join(
            c.workingDirectory, test_name,
            'apply_ants_warp_dr_tempreg_maps_standard_to_original_mapnode_inverse_0',
            'mapflow',
            '_apply_ants_warp_dr_tempreg_maps_standard_to_original_mapnode_inverse_0{0}'
            .format(n),
            'temp_reg_map_000{0}_antswarp_antswarp.nii.gz'.format(n))
        for n in range(0, 10)
    ]


    test_results = [ test_utils.pearson_correlation(orig_file, xformed_file) > 0.99 \
        for orig_file, xformed_file in zip(dr_spatmaps, dr_spatmaps_after_transform)]

    assert all(test_results)