interfaces.ants.resampling¶
ApplyTransforms¶
Wraps the executable command antsApplyTransforms
.
ApplyTransforms, applied to an input image, transforms it according to a reference image and a transform (or a set of transforms).
Examples¶
>>> from nipype.interfaces.ants import ApplyTransforms
>>> at = ApplyTransforms()
>>> at.inputs.input_image = 'moving1.nii'
>>> at.inputs.reference_image = 'fixed1.nii'
>>> at.inputs.transforms = 'identity'
>>> at.cmdline
'antsApplyTransforms --default-value 0 --float 0 --input moving1.nii --interpolation Linear --output moving1_trans.nii --reference-image fixed1.nii -t identity'
>>> at = ApplyTransforms()
>>> at.inputs.dimension = 3
>>> at.inputs.input_image = 'moving1.nii'
>>> at.inputs.reference_image = 'fixed1.nii'
>>> at.inputs.output_image = 'deformed_moving1.nii'
>>> at.inputs.interpolation = 'Linear'
>>> at.inputs.default_value = 0
>>> at.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
>>> at.inputs.invert_transform_flags = [False, False]
>>> at.cmdline
'antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input moving1.nii --interpolation Linear --output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] --transform [ trans.mat, 0 ]'
>>> at1 = ApplyTransforms()
>>> at1.inputs.dimension = 3
>>> at1.inputs.input_image = 'moving1.nii'
>>> at1.inputs.reference_image = 'fixed1.nii'
>>> at1.inputs.output_image = 'deformed_moving1.nii'
>>> at1.inputs.interpolation = 'BSpline'
>>> at1.inputs.interpolation_parameters = (5,)
>>> at1.inputs.default_value = 0
>>> at1.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
>>> at1.inputs.invert_transform_flags = [False, False]
>>> at1.cmdline
'antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input moving1.nii --interpolation BSpline[ 5 ] --output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] --transform [ trans.mat, 0 ]'
Inputs:
[Mandatory]
input_image: (a pathlike object or string representing an existing
file)
image to apply transformation to (generally a coregistered
functional)
argument: ``--input %s``
reference_image: (a pathlike object or string representing an
existing file)
reference image space that you wish to warp INTO
argument: ``--reference-image %s``
transforms: (a list of items which are a pathlike object or string
representing an existing file or 'identity')
transform files: will be applied in reverse order. For example, the
last specified transform will be applied first.
argument: ``%s``
[Optional]
dimension: (2 or 3 or 4)
This option forces the image to be treated as a specified-
dimensional image. If not specified, antsWarp tries to infer the
dimensionality from the input image.
argument: ``--dimensionality %d``
input_image_type: (0 or 1 or 2 or 3)
Option specifying the input image type of scalar (default), vector,
tensor, or time series.
argument: ``--input-image-type %d``
output_image: (a unicode string)
output file name
argument: ``--output %s``
out_postfix: (a unicode string, nipype default value: _trans)
Postfix that is appended to all output files (default = _trans)
interpolation: ('Linear' or 'NearestNeighbor' or 'CosineWindowedSinc'
or 'WelchWindowedSinc' or 'HammingWindowedSinc' or
'LanczosWindowedSinc' or 'MultiLabel' or 'Gaussian' or 'BSpline',
nipype default value: Linear)
argument: ``%s``
interpolation_parameters: (a tuple of the form: (an integer (int or
long)) or a tuple of the form: (a float, a float))
invert_transform_flags: (a list of items which are a boolean)
default_value: (a float, nipype default value: 0.0)
argument: ``--default-value %g``
print_out_composite_warp_file: (a boolean)
output a composite warp file instead of a transformed image
requires: output_image
float: (a boolean, nipype default value: False)
Use float instead of double for computations.
argument: ``--float %d``
num_threads: (an integer (int or long), nipype default value: 1)
Number of ITK threads to use
args: (a unicode string)
Additional parameters to the command
argument: ``%s``
environ: (a dictionary with keys which are a bytes or None or a value
of class 'str' and with values which are a bytes or None or a
value of class 'str', nipype default value: {})
Environment variables
Outputs:
output_image: (a pathlike object or string representing an existing
file)
Warped image
ApplyTransformsToPoints¶
Wraps the executable command antsApplyTransformsToPoints
.
ApplyTransformsToPoints, applied to an CSV file, transforms coordinates using provided transform (or a set of transforms).
Examples¶
>>> from nipype.interfaces.ants import ApplyTransforms
>>> at = ApplyTransformsToPoints()
>>> at.inputs.dimension = 3
>>> at.inputs.input_file = 'moving.csv'
>>> at.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
>>> at.inputs.invert_transform_flags = [False, False]
>>> at.cmdline
'antsApplyTransformsToPoints --dimensionality 3 --input moving.csv --output moving_transformed.csv --transform [ trans.mat, 0 ] --transform [ ants_Warp.nii.gz, 0 ]'
Inputs:
[Mandatory]
input_file: (a pathlike object or string representing an existing
file)
Currently, the only input supported is a csv file with columns
including x,y (2D), x,y,z (3D) or x,y,z,t,label (4D) column headers.
The points should be defined in physical space. If in doubt how to
convert coordinates from your files to the space required by
antsApplyTransformsToPoints try creating/drawing a simple label
volume with only one voxel set to 1 and all others set to 0. Write
down the voxel coordinates. Then use ImageMaths LabelStats to find
out what coordinates for this voxel antsApplyTransformsToPoints is
expecting.
argument: ``--input %s``
transforms: (a list of items which are a pathlike object or string
representing an existing file)
transforms that will be applied to the points
argument: ``%s``
[Optional]
dimension: (2 or 3 or 4)
This option forces the image to be treated as a specified-
dimensional image. If not specified, antsWarp tries to infer the
dimensionality from the input image.
argument: ``--dimensionality %d``
output_file: (a unicode string)
Name of the output CSV file
argument: ``--output %s``
invert_transform_flags: (a list of items which are a boolean)
list indicating if a transform should be reversed
num_threads: (an integer (int or long), nipype default value: 1)
Number of ITK threads to use
args: (a unicode string)
Additional parameters to the command
argument: ``%s``
environ: (a dictionary with keys which are a bytes or None or a value
of class 'str' and with values which are a bytes or None or a
value of class 'str', nipype default value: {})
Environment variables
Outputs:
output_file: (a pathlike object or string representing an existing
file)
csv file with transformed coordinates
WarpImageMultiTransform¶
Wraps the executable command WarpImageMultiTransform
.
Warps an image from one space to another
Examples¶
>>> from nipype.interfaces.ants import WarpImageMultiTransform
>>> wimt = WarpImageMultiTransform()
>>> wimt.inputs.input_image = 'structural.nii'
>>> wimt.inputs.reference_image = 'ants_deformed.nii.gz'
>>> wimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
>>> wimt.cmdline
'WarpImageMultiTransform 3 structural.nii structural_wimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz ants_Affine.txt'
>>> wimt = WarpImageMultiTransform()
>>> wimt.inputs.input_image = 'diffusion_weighted.nii'
>>> wimt.inputs.reference_image = 'functional.nii'
>>> wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz', 'dwi2anat_Warp.nii.gz','dwi2anat_coreg_Affine.txt']
>>> wimt.inputs.invert_affine = [1] # this will invert the 1st Affine file: 'func2anat_coreg_Affine.txt'
>>> wimt.cmdline
'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii -i func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz dwi2anat_coreg_Affine.txt'
Inputs:
[Mandatory]
input_image: (a pathlike object or string representing a file)
image to apply transformation to (generally a coregistered
functional)
argument: ``%s``, position: 2
transformation_series: (a list of items which are a pathlike object
or string representing an existing file)
transformation file(s) to be applied
argument: ``%s``, position: -1
[Optional]
dimension: (3 or 2, nipype default value: 3)
image dimension (2 or 3)
argument: ``%d``, position: 1
output_image: (a pathlike object or string representing a file)
name of the output warped image
argument: ``%s``, position: 3
mutually_exclusive: out_postfix
out_postfix: (a pathlike object or string representing a file, nipype
default value: _wimt)
Postfix that is prepended to all output files (default = _wimt)
mutually_exclusive: output_image
reference_image: (a pathlike object or string representing a file)
reference image space that you wish to warp INTO
argument: ``-R %s``
mutually_exclusive: tightest_box
tightest_box: (a boolean)
computes tightest bounding box (overrided by reference_image if
given)
argument: ``--tightest-bounding-box``
mutually_exclusive: reference_image
reslice_by_header: (a boolean)
Uses orientation matrix and origin encoded in reference image file
header. Not typically used with additional transforms
argument: ``--reslice-by-header``
use_nearest: (a boolean)
Use nearest neighbor interpolation
argument: ``--use-NN``
use_bspline: (a boolean)
Use 3rd order B-Spline interpolation
argument: ``--use-BSpline``
invert_affine: (a list of items which are an integer (int or long))
List of Affine transformations to invert.E.g.: [1,4,5] inverts the
1st, 4th, and 5th Affines found in transformation_series. Note that
indexing starts with 1 and does not include warp fields. Affine
transformations are distinguished from warp fields by the word
"affine" included in their filenames.
num_threads: (an integer (int or long), nipype default value: 1)
Number of ITK threads to use
args: (a unicode string)
Additional parameters to the command
argument: ``%s``
environ: (a dictionary with keys which are a bytes or None or a value
of class 'str' and with values which are a bytes or None or a
value of class 'str', nipype default value: {})
Environment variables
Outputs:
output_image: (a pathlike object or string representing an existing
file)
Warped image
WarpTimeSeriesImageMultiTransform¶
Wraps the executable command WarpTimeSeriesImageMultiTransform
.
Warps a time-series from one space to another
Examples¶
>>> from nipype.interfaces.ants import WarpTimeSeriesImageMultiTransform
>>> wtsimt = WarpTimeSeriesImageMultiTransform()
>>> wtsimt.inputs.input_image = 'resting.nii'
>>> wtsimt.inputs.reference_image = 'ants_deformed.nii.gz'
>>> wtsimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
>>> wtsimt.cmdline
'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz ants_Affine.txt'
>>> wtsimt = WarpTimeSeriesImageMultiTransform()
>>> wtsimt.inputs.input_image = 'resting.nii'
>>> wtsimt.inputs.reference_image = 'ants_deformed.nii.gz'
>>> wtsimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
>>> wtsimt.inputs.invert_affine = [1] # # this will invert the 1st Affine file: ants_Affine.txt
>>> wtsimt.cmdline
'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz -i ants_Affine.txt'
Inputs:
[Mandatory]
input_image: (a pathlike object or string representing a file)
image to apply transformation to (generally a coregistered
functional)
argument: ``%s``
transformation_series: (a list of items which are a pathlike object
or string representing an existing file)
transformation file(s) to be applied
argument: ``%s``
[Optional]
dimension: (4 or 3, nipype default value: 4)
image dimension (3 or 4)
argument: ``%d``, position: 1
out_postfix: (a unicode string, nipype default value: _wtsimt)
Postfix that is prepended to all output files (default = _wtsimt)
argument: ``%s``
reference_image: (a pathlike object or string representing a file)
reference image space that you wish to warp INTO
argument: ``-R %s``
mutually_exclusive: tightest_box
tightest_box: (a boolean)
computes tightest bounding box (overrided by reference_image if
given)
argument: ``--tightest-bounding-box``
mutually_exclusive: reference_image
reslice_by_header: (a boolean)
Uses orientation matrix and origin encoded in reference image file
header. Not typically used with additional transforms
argument: ``--reslice-by-header``
use_nearest: (a boolean)
Use nearest neighbor interpolation
argument: ``--use-NN``
use_bspline: (a boolean)
Use 3rd order B-Spline interpolation
argument: ``--use-Bspline``
invert_affine: (a list of items which are an integer (int or long))
List of Affine transformations to invert.E.g.: [1,4,5] inverts the
1st, 4th, and 5th Affines found in transformation_series. Note that
indexing starts with 1 and does not include warp fields. Affine
transformations are distinguished from warp fields by the word
"affine" included in their filenames.
num_threads: (an integer (int or long), nipype default value: 1)
Number of ITK threads to use
args: (a unicode string)
Additional parameters to the command
argument: ``%s``
environ: (a dictionary with keys which are a bytes or None or a value
of class 'str' and with values which are a bytes or None or a
value of class 'str', nipype default value: {})
Environment variables
Outputs:
output_image: (a pathlike object or string representing an existing
file)
Warped image