Beispiel #1
0
def test_FAST_inputs():
    input_map = dict(
        args=dict(argstr='%s', ),
        bias_iters=dict(argstr='-I %d', ),
        bias_lowpass=dict(
            argstr='-l %d',
            units='mm',
        ),
        environ=dict(
            nohash=True,
            usedefault=True,
        ),
        hyper=dict(argstr='-H %.2f', ),
        ignore_exception=dict(
            nohash=True,
            usedefault=True,
        ),
        img_type=dict(argstr='-t %d', ),
        in_files=dict(
            argstr='%s',
            copyfile=False,
            mandatory=True,
            position=-1,
        ),
        init_seg_smooth=dict(argstr='-f %.3f', ),
        init_transform=dict(argstr='-a %s', ),
        iters_afterbias=dict(argstr='-O %d', ),
        manual_seg=dict(argstr='-s %s', ),
        mixel_smooth=dict(argstr='-R %.2f', ),
        no_bias=dict(argstr='-N', ),
        no_pve=dict(argstr='--nopve', ),
        number_classes=dict(argstr='-n %d', ),
        other_priors=dict(argstr='-A %s', ),
        out_basename=dict(argstr='-o %s', ),
        output_biascorrected=dict(argstr='-B', ),
        output_biasfield=dict(argstr='-b', ),
        output_type=dict(),
        probability_maps=dict(argstr='-p', ),
        segment_iters=dict(argstr='-W %d', ),
        segments=dict(argstr='-g', ),
        terminal_output=dict(
            mandatory=True,
            nohash=True,
        ),
        use_priors=dict(argstr='-P', ),
        verbose=dict(argstr='-v', ),
    )
    inputs = FAST.input_spec()

    for key, metadata in input_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(inputs.traits()[key], metakey), value
Beispiel #2
0
def test_FAST_outputs():
    output_map = dict(bias_field=dict(),
    mixeltype=dict(),
    partial_volume_files=dict(),
    partial_volume_map=dict(),
    probability_maps=dict(),
    restored_image=dict(),
    tissue_class_files=dict(),
    tissue_class_map=dict(),
    )
    outputs = FAST.output_spec()

    for key, metadata in output_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(outputs.traits()[key], metakey), value
Beispiel #3
0
def test_FAST_outputs():
    output_map = dict(
        bias_field=dict(),
        mixeltype=dict(),
        partial_volume_files=dict(),
        partial_volume_map=dict(),
        probability_maps=dict(),
        restored_image=dict(),
        tissue_class_files=dict(),
        tissue_class_map=dict(),
    )
    outputs = FAST.output_spec()

    for key, metadata in output_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(outputs.traits()[key], metakey), value
Beispiel #4
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
Beispiel #5
0
# In[3]:

## Nodes for preprocessing

# Reorient to standard space using FSL
reorientfunc = Node(Reorient2Std(), name='reorientfunc')
reorientstruct = Node(Reorient2Std(), name='reorientstruct')

# Reslice- using MRI_convert
reslice = Node(MRIConvert(vox_size=resampled_voxel_size, out_type='nii'),
               name='reslice')

# Segment structural scan
#segment = Node(Segment(affine_regularization='none'), name='segment')
segment = Node(FAST(no_bias=True, segments=True, number_classes=3),
               name='segment')

#Slice timing correction based on interleaved acquisition using FSL
slicetime_correct = Node(SliceTimer(interleaved=interleave,
                                    slice_direction=slice_dir,
                                    time_repetition=TR),
                         name='slicetime_correct')

# Motion correction
motion_correct = Node(MCFLIRT(save_plots=True, mean_vol=True),
                      name='motion_correct')

# Registration- using FLIRT
# The BOLD image is 'in_file', the anat is 'reference', the output is 'out_file'
coreg1 = Node(FLIRT(), name='coreg1')
Beispiel #6
0
def test_FAST_inputs():
    input_map = dict(args=dict(argstr='%s',
    ),
    bias_iters=dict(argstr='-I %d',
    ),
    bias_lowpass=dict(argstr='-l %d',
    units='mm',
    ),
    environ=dict(nohash=True,
    usedefault=True,
    ),
    hyper=dict(argstr='-H %.2f',
    ),
    ignore_exception=dict(nohash=True,
    usedefault=True,
    ),
    img_type=dict(argstr='-t %d',
    ),
    in_files=dict(argstr='%s',
    copyfile=False,
    mandatory=True,
    position=-1,
    ),
    init_seg_smooth=dict(argstr='-f %.3f',
    ),
    init_transform=dict(argstr='-a %s',
    ),
    iters_afterbias=dict(argstr='-O %d',
    ),
    manual_seg=dict(argstr='-s %s',
    ),
    mixel_smooth=dict(argstr='-R %.2f',
    ),
    no_bias=dict(argstr='-N',
    ),
    no_pve=dict(argstr='--nopve',
    ),
    number_classes=dict(argstr='-n %d',
    ),
    other_priors=dict(argstr='-A %s',
    ),
    out_basename=dict(argstr='-o %s',
    ),
    output_biascorrected=dict(argstr='-B',
    ),
    output_biasfield=dict(argstr='-b',
    ),
    output_type=dict(),
    probability_maps=dict(argstr='-p',
    ),
    segment_iters=dict(argstr='-W %d',
    ),
    segments=dict(argstr='-g',
    ),
    terminal_output=dict(mandatory=True,
    nohash=True,
    ),
    use_priors=dict(argstr='-P',
    ),
    verbose=dict(argstr='-v',
    ),
    )
    inputs = FAST.input_spec()

    for key, metadata in input_map.items():
        for metakey, value in metadata.items():
            yield assert_equal, getattr(inputs.traits()[key], metakey), value
Beispiel #7
0
                         name='convert_to_nii', 
                         iterfield = ['in_file'])

#reorient brainmask file to standard
reorient_to_std = MapNode(Reorient2Std(),
                         name = 'reorient_to_std',
                         iterfield = ['in_file'])

# Reorient aseg to standard
reorient_aseg = MapNode(Reorient2Std(),
                         name = 'reorient_aseg',
                         iterfield = ['in_file'])

#T1 gets run through segmentation (2) ---> results in segmentation into 3 tissue classes (wm, gm, csf)
segment = MapNode(FAST(number_classes = 3, 
                       segments=True, 
                       no_bias=True), 
                  name = 'segment', 
                  iterfield = ['in_files'])

# Convert freesurfer aseg to nii
convert_aseg = MapNode(MRIConvert(out_file='aseg.nii.gz',
                                    out_type='niigz'), 
                         name='convert_aseg', 
                         iterfield = ['in_file'])

# Split aseg into to types of gray matter
aseg_to_gm = MapNode(Function(input_names=['aseg'],
                              output_names=['gm_list'],
                              function=aseg_to_tissuemaps),
                     name='aseg_to_gm',