Learn R Programming

RNiftyReg (version 0.4.1)

niftyreg: Two and three dimensional image registration

Description

The niftyreg function performs registration for two and three dimensional images. 4D images may also be registered volumewise to a 3D image, or 3D images slicewise to a 2D image. Rigid-body (6 degrees of freedom) and affine (12 degrees of freedom) registration can currently be performed. A precalculated transformation can be applied to a new image using the applyAffine function.

Usage

niftyreg(source, target, targetMask = NULL, initAffine = NULL,
           scope = c("affine","rigid"), nLevels = 3, maxIterations = 5,
           useBlockPercentage = 50, finalInterpolation = 3, verbose = FALSE)

applyAffine(affine, source, target, affineType = NULL, finalInterpolation = 3)

Arguments

source
The source image, an object of class "nifti" with 2, 3 or 4 dimensions. Package oro.nifti defines this class and provides functions for reading and writing NIfTI files.
target
The target image, an object of class "nifti" with 2 or 3 dimensions.
targetMask
An optional mask image (again a "nifti" object), whose nonzero region will be taken as the region of interest for the registration. Must have the same voxel and image dimensions as the target image.
initAffine
An optional affine matrix to initialise the algorithm. If NULL, the identity matrix is used, with an appropriate offset to account for differences in the image origins.
scope
A string describing the scope, or number of degrees of freedom (DOF), of the registration. Only "affine" (12 DOF) and "rigid" (6 DOF) are currently supported.
nLevels
A single integer specifying the number of levels of the algorithm that should be applied. If zero, no optimisation will be performed, and the final affine matrix will be the same as its initialisation value.
maxIterations
A single integer specifying the maximum number of iterations to be used within each level. Fewer iterations may be used if a convergence test deems the process to have completed.
useBlockPercentage
A single integer giving the percentage of blocks to use for calculating correspondence at each step of the algorithm. The blocks with the highest intensity variance will be chosen.
finalInterpolation
A single integer specifying the type of interpolation to be applied to the final resampled image. May be 0 (nearest neighbour), 1 (trilinear) or 3 (cubic spline). No other values are valid.
verbose
A single logical value: if TRUE, the code will give some feedback on its progress; otherwise, nothing will be output while the algorithm runs.
affine
For applyAffine, the affine transformation to apply to the source image.
affineType
For applyAffine, the storage convention type of the affine matrix, if it is not stored in the affineType attribute of the matrix.

Value

  • For both functions, a list of class "niftyreg" with components
  • imageAn image object of class "nifti" representing the registered and resampled source image in the space of the target image.
  • affineA list of 4x4 matrices containing the optimised affine transformations for each slice or volume of the source image. If the target is a 2D image, elements involving the Z dimension will have no effect.
  • scopeCopied from the function argument of the same name.

Details

This function performs the dual operations of finding a transformation to optimise image alignment, and resampling the source image into the space of the target image.

The algorithm is based on a block-matching approach and Least Trimmed Squares (LTS) fitting. Firstly, the block matching provides a set of corresponding points between a target and a source image. Secondly, using this set of corresponding points, the best rigid or affine transformation is evaluated. This two-step loop is repeated until convergence to the best transformation.

In the NiftyReg implementation, normalised cross-correlation between the target and source blocks is used to evaluate correspondence. The block width is constant and has been set to 4 voxels. A coarse-to-fine approach is used, where the registration is first performed on down-sampled images (using a Gaussian filter to resample images), and finally performed on full resolution images.

The source image may have 2, 3 or 4 dimensions, and the target 2 or 3. The dimensionality of the target image determines whether 2D or 3D registration is applied, and source images with one more dimension than the target (i.e. 4D to 3D, or 3D to 2D) will be registered volumewise or slicewise, as appropriate. In the latter case the last dimension of the resulting image is taken from the source image, while all other dimensions come from the target. One affine matrix is returned for each registration performed.

The applyAffine function is a convenience wrapper that calls niftyreg with nLevels=0 to apply the specified transformation without any further optimisation. Note that a target image must still be specified in this case, since the metadata associated with that image is needed by niftyreg.

References

The algorithm used by this function is described in the following publications.

Ourselin, S., Roche, A., Subsol, G., Pennec, X. and Ayache, N. (2000). Reconstructing a 3D structure from serial histological sections. Image and Vision Computing 19(1-2):25-31.

Ourselin, S., Stefanescu, R. and Pennec, X. (2002). Robust registration of multi-modal images: towards real-time clinical applications. Medical Image Computing and Computer-Assisted Intervention. Vol. 2489 of Lecture Notes in Computer Science, pp. 140-147.

See Also

nifti (no relation!), in the oro.nifti package, for creating the image objects passed to this function. Useful related functions are as.nifti, readNIfTI and writeNIfTI.