def test_WarpTimeSeriesImageMultiTransform_outputs():
    output_map = dict(output_image=dict(), )
    outputs = WarpTimeSeriesImageMultiTransform.output_spec()

    for key, metadata in output_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(outputs.traits()[key], metakey), value
def test_WarpTimeSeriesImageMultiTransform_outputs():
    output_map = dict(output_image=dict(),
    )
    outputs = WarpTimeSeriesImageMultiTransform.output_spec()

    for key, metadata in output_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(outputs.traits()[key], metakey), value
Example #3
0
def test_WarpTimeSeriesImageMultiTransform_inputs():
    input_map = dict(
        args=dict(argstr='%s', ),
        dimension=dict(
            argstr='%d',
            position=1,
            usedefault=True,
        ),
        environ=dict(
            nohash=True,
            usedefault=True,
        ),
        ignore_exception=dict(
            nohash=True,
            usedefault=True,
        ),
        input_image=dict(
            argstr='%s',
            copyfile=True,
            mandatory=True,
        ),
        invert_affine=dict(),
        num_threads=dict(
            nohash=True,
            usedefault=True,
        ),
        out_postfix=dict(
            argstr='%s',
            usedefault=True,
        ),
        reference_image=dict(
            argstr='-R %s',
            xor=['tightest_box'],
        ),
        reslice_by_header=dict(argstr='--reslice-by-header', ),
        terminal_output=dict(
            mandatory=True,
            nohash=True,
        ),
        tightest_box=dict(
            argstr='--tightest-bounding-box',
            xor=['reference_image'],
        ),
        transformation_series=dict(
            argstr='%s',
            copyfile=False,
            mandatory=True,
        ),
        use_bspline=dict(argstr='--use-Bspline', ),
        use_nearest=dict(argstr='--use-NN', ),
    )
    inputs = WarpTimeSeriesImageMultiTransform.input_spec()

    for key, metadata in input_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(inputs.traits()[key], metakey), value
def test_WarpTimeSeriesImageMultiTransform_inputs():
    input_map = dict(ignore_exception=dict(nohash=True,
    usedefault=True,
    ),
    num_threads=dict(nohash=True,
    usedefault=True,
    ),
    invert_affine=dict(),
    reslice_by_header=dict(argstr='--reslice-by-header',
    ),
    tightest_box=dict(xor=['reference_image'],
    argstr='--tightest-bounding-box',
    ),
    out_postfix=dict(argstr='%s',
    usedefault=True,
    ),
    use_nearest=dict(argstr='--use-NN',
    ),
    args=dict(argstr='%s',
    ),
    terminal_output=dict(mandatory=True,
    nohash=True,
    ),
    environ=dict(nohash=True,
    usedefault=True,
    ),
    reference_image=dict(xor=['tightest_box'],
    argstr='-R %s',
    ),
    input_image=dict(copyfile=True,
    mandatory=True,
    argstr='%s',
    ),
    use_bspline=dict(argstr='--use-Bspline',
    ),
    transformation_series=dict(copyfile=False,
    mandatory=True,
    argstr='%s',
    ),
    dimension=dict(position=1,
    usedefault=True,
    argstr='%d',
    ),
    )
    inputs = WarpTimeSeriesImageMultiTransform.input_spec()

    for key, metadata in input_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(inputs.traits()[key], metakey), value
Example #5
0
def create_t1_based_unwarp(name='unwarp'):
    """
    Unwarp an fMRI time series based on non-linear registration to T1.
        NOTE: AS IT STANDS THIS METHOD DID NOT PRODUCE ACCEPTABLE RESULTS
        IF BRAIN COVERAGE IS NOT COMPLETE ON THE EPI IMAGE.
        ALSO: NEED TO ADD AUTOMATIC READING OF EPI RESOLUTION TO GET

    """

    unwarpflow = pe.Workflow(name=name)
    inputnode = pe.Node(
        interface=util.IdentityInterface(fields=['epi', 'T1W']),
        name='inputspec')
    outputnode = pe.Node(interface=util.IdentityInterface(
        fields=['unwarped_func', 'warp_files']),
                         name='outputspec')

    tmedian = pe.Node(interface=ImageMaths(), name='tmedian')
    tmedian.inputs.op_string = '-Tmedian'
    epi_brain_ext = pe.Node(interface=util.Function(
        function=epi_brain_extract,
        input_names=['in_file'],
        output_names=['out_vol', 'out_mask']),
                            name='epi_brain_ext')

    fast_debias = pe.Node(interface=FAST(), name='FAST_debias')
    fast_debias.inputs.output_biascorrected = True

    robex = pe.Node(interface=util.Function(
        function=my_robex,
        input_names=['in_file'],
        output_names=['out_file', 'out_mask']),
                    name='robex')

    downsample_T1 = pe.Node(MRIConvert(), name='downsample_dti')
    downsample_T1.inputs.vox_size = (3.438, 3.438, 3.000)
    downsample_T1.inputs.out_type = 'niigz'

    contrast_invert = pe.Node(interface=util.Function(
        function=invert_contrast,
        input_names=['in_t1_brain', 'in_b0_brain'],
        output_names=['out_fn']),
                              name='contrast_invert')

    ants_syn = pe.Node(interface=util.Function(
        function=my_ants_registration_syn,
        input_names=['in_T1W', 'in_epi'],
        output_names=['out_transforms']),
                       name='ants_syn')
    ants_warp = pe.Node(interface=WarpTimeSeriesImageMultiTransform(),
                        name='ants_warp')
    '''connections'''
    # unwarpflow.connect(inputnode, 'T1W', robex, 'in_file')
    unwarpflow.connect(inputnode, 'T1W', fast_debias, 'in_files')
    # unwarpflow.connect(robex, 'out_file', fast_debias, 'in_files')
    unwarpflow.connect(fast_debias, 'restored_image', robex, 'in_file')
    # unwarpflow.connect(fast_debias, 'restored_image', downsample_T1, 'in_file')
    unwarpflow.connect(robex, 'out_file', downsample_T1, 'in_file')
    unwarpflow.connect(downsample_T1, 'out_file', contrast_invert,
                       'in_t1_brain')
    unwarpflow.connect(inputnode, 'epi', tmedian, 'in_file')
    unwarpflow.connect(tmedian, 'out_file', epi_brain_ext, 'in_file')
    unwarpflow.connect(epi_brain_ext, 'out_vol', contrast_invert,
                       'in_b0_brain')
    unwarpflow.connect(contrast_invert, 'out_fn', ants_syn, 'in_T1W')
    unwarpflow.connect(epi_brain_ext, 'out_vol', ants_syn, 'in_epi')
    unwarpflow.connect(ants_syn, 'out_transforms', outputnode,
                       'out_transforms')

    unwarpflow.connect(inputnode, 'epi', ants_warp, 'input_image')
    unwarpflow.connect(contrast_invert, 'out_fn', ants_warp, 'reference_image')
    unwarpflow.connect(ants_syn, 'out_transforms', ants_warp,
                       'transformation_series')

    unwarpflow.connect(ants_syn, 'out_transforms', outputnode, 'warp_files')
    unwarpflow.connect(ants_warp, 'output_image', outputnode, 'unwarped_func')

    return unwarpflow