nipype.interfaces.ants.resampling module

ANTS Apply Transforms interface

ApplyTransforms

Link to code

Bases: ANTSCommand

Wrapped executable: 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 --transform 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, True]
>>> 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 --transform [ trans.mat, 1 ]'
>>> 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 --transform trans.mat'

Identity transforms may be used as part of a chain:

>>> at2 = ApplyTransforms()
>>> at2.inputs.dimension = 3
>>> at2.inputs.input_image = 'moving1.nii'
>>> at2.inputs.reference_image = 'fixed1.nii'
>>> at2.inputs.output_image = 'deformed_moving1.nii'
>>> at2.inputs.interpolation = 'BSpline'
>>> at2.inputs.interpolation_parameters = (5,)
>>> at2.inputs.default_value = 0
>>> at2.inputs.transforms = ['identity', 'ants_Warp.nii.gz', 'trans.mat']
>>> at2.cmdline
'antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input moving1.nii --interpolation BSpline[ 5 ] --output deformed_moving1.nii --reference-image fixed1.nii --transform identity --transform ants_Warp.nii.gz --transform trans.mat'
input_image : a pathlike object or string representing an existing file
Image to apply transformation to (generally a coregistered functional). Maps to a command-line argument: --input %s.
reference_image : a pathlike object or string representing an existing file
Reference image space that you wish to warp INTO. Maps to a command-line 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. Maps to a command-line argument: %s.
args : a unicode string
Additional parameters to the command. Maps to a command-line argument: %s.
default_value : a float
Maps to a command-line argument: --default-value %g. (Nipype default value: 0.0)
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. Maps to a command-line argument: --dimensionality %d.
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’
Environment variables. (Nipype default value: {})
float : a boolean
Use float instead of double for computations. Maps to a command-line argument: --float %d. (Nipype default value: False)
input_image_type : 0 or 1 or 2 or 3
Option specifying the input image type of scalar (default), vector, tensor, or time series. Maps to a command-line argument: --input-image-type %d.
interpolation : ‘Linear’ or ‘NearestNeighbor’ or ‘CosineWindowedSinc’ or ‘WelchWindowedSinc’ or ‘HammingWindowedSinc’ or ‘LanczosWindowedSinc’ or ‘MultiLabel’ or ‘Gaussian’ or ‘BSpline’
Maps to a command-line argument: %s. (Nipype default value: Linear)

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 num_threads : an integer (int or long)

Number of ITK threads to use. (Nipype default value: 1)
out_postfix : a unicode string
Postfix that is appended to all output files (default = _trans). (Nipype default value: _trans)
output_image : a unicode string
Output file name. Maps to a command-line argument: --output %s.
print_out_composite_warp_file : a boolean
Output a composite warp file instead of a transformed image. Requires inputs: output_image.
output_image : a pathlike object or string representing an existing file
Warped image.

ApplyTransformsToPoints

Link to code

Bases: ANTSCommand

Wrapped executable: 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 ]'
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. Maps to a command-line 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. Maps to a command-line argument: %s.
args : a unicode string
Additional parameters to the command. Maps to a command-line argument: %s.
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. Maps to a command-line argument: --dimensionality %d.
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’
Environment variables. (Nipype default value: {})
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)
Number of ITK threads to use. (Nipype default value: 1)
output_file : a unicode string
Name of the output CSV file. Maps to a command-line argument: --output %s.
output_file : a pathlike object or string representing an existing file
Csv file with transformed coordinates.

WarpImageMultiTransform

Link to code

Bases: ANTSCommand

Wrapped executable: 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'
input_image : a pathlike object or string representing a file
Image to apply transformation to (generally a coregistered functional). Maps to a command-line 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. Maps to a command-line argument: %s (position: -1).
args : a unicode string
Additional parameters to the command. Maps to a command-line argument: %s.
dimension : 3 or 2
Image dimension (2 or 3). Maps to a command-line argument: %d (position: 1). (Nipype default value: 3)
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’
Environment variables. (Nipype default value: {})
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)
Number of ITK threads to use. (Nipype default value: 1)
out_postfix : a pathlike object or string representing a file
Postfix that is prepended to all output files (default = _wimt). Mutually exclusive with inputs: output_image. (Nipype default value: _wimt)
output_image : a pathlike object or string representing a file
Name of the output warped image. Maps to a command-line argument: %s (position: 3). Mutually exclusive with inputs: out_postfix.
reference_image : a pathlike object or string representing a file
Reference image space that you wish to warp INTO. Maps to a command-line argument: -R %s. Mutually exclusive with inputs: tightest_box.
reslice_by_header : a boolean
Uses orientation matrix and origin encoded in reference image file header. Not typically used with additional transforms. Maps to a command-line argument: --reslice-by-header.
tightest_box : a boolean
Computes tightest bounding box (overrided by reference_image if given). Maps to a command-line argument: --tightest-bounding-box. Mutually exclusive with inputs: reference_image.
use_bspline : a boolean
Use 3rd order B-Spline interpolation. Maps to a command-line argument: --use-BSpline.
use_nearest : a boolean
Use nearest neighbor interpolation. Maps to a command-line argument: --use-NN.
output_image : a pathlike object or string representing an existing file
Warped image.

WarpTimeSeriesImageMultiTransform

Link to code

Bases: ANTSCommand

Wrapped executable: 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'
input_image : a pathlike object or string representing a file
Image to apply transformation to (generally a coregistered functional). Maps to a command-line 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. Maps to a command-line argument: %s.
args : a unicode string
Additional parameters to the command. Maps to a command-line argument: %s.
dimension : 4 or 3
Image dimension (3 or 4). Maps to a command-line argument: %d (position: 1). (Nipype default value: 4)
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’
Environment variables. (Nipype default value: {})
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)
Number of ITK threads to use. (Nipype default value: 1)
out_postfix : a unicode string
Postfix that is prepended to all output files (default = _wtsimt). Maps to a command-line argument: %s. (Nipype default value: _wtsimt)
reference_image : a pathlike object or string representing a file
Reference image space that you wish to warp INTO. Maps to a command-line argument: -R %s. Mutually exclusive with inputs: tightest_box.
reslice_by_header : a boolean
Uses orientation matrix and origin encoded in reference image file header. Not typically used with additional transforms. Maps to a command-line argument: --reslice-by-header.
tightest_box : a boolean
Computes tightest bounding box (overrided by reference_image if given). Maps to a command-line argument: --tightest-bounding-box. Mutually exclusive with inputs: reference_image.
use_bspline : a boolean
Use 3rd order B-Spline interpolation. Maps to a command-line argument: --use-Bspline.
use_nearest : a boolean
Use nearest neighbor interpolation. Maps to a command-line argument: --use-NN.
output_image : a pathlike object or string representing an existing file
Warped image.