niftyreg.nonlinear
function performs nonlinear 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. The warping is based on free-form deformations, parameterised using an image of control points. A precalculated transformation can be applied to a new image using the applyControlPoints
function.niftyreg.nonlinear(source, target, targetMask = NULL, initAffine = NULL,
initControl = NULL, symmetric = FALSE, sourceMask = NULL, nLevels = 3,
maxIterations = 300, nBins = 64, bendingEnergyWeight = 0.005,
jacobianWeight = 0, inverseConsistencyWeight = 0.01,
finalSpacing = c(5,5,5), spacingUnit = c("vox","mm"),
finalInterpolation = 3, verbose = FALSE, estimateOnly = FALSE)applyControlPoints(controlPointImage, source, target,
finalInterpolation = 3)
"nifti"
with 2, 3 or 4 dimensions. Package oro.nifti
defines this class and provides functions for reading and writing NIfTI files."nifti"
with 2 or 3 dimensions."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.initControl
are NULL
, the identity matrix is used, with an appropriate offset to account for differences in the image origins"nifti"
, or a list of images, representing fields of previously-calculated control points to use as initialisation for the algorithm. This parameter takes priority over initAffine
if both are not
TRUE
, a symmetric version of the registration algorithm is used to simultaneously obtain transformations from source
to target
and target
to source
. There are somesymmetric
is FALSE
.symmetric
is FALSE
.initControl
image if one is supplied.finalSpacing
is specified: either "vox"
for voxels or "mm"
for millimetres (which is assumed to be the spatial unit of the source and target images).TRUE
, the code will give some feedback on its progress; otherwise, nothing will be output while the algorithm runs.TRUE
, the transformation(s) will be estimated but the image(s) will not be resampled.applyControlPoints
, the control point map to apply to the source image.niftyreg
.symmetric
is TRUE
). Unlike niftyreg.linear
, this transformation is nonlinear, and the degree of deformation may vary across the image.The nonlinear warping is based on free-form deformations. A lattice of equally-spaced control points is defined over the target image, each of which can be moved to locally modify the mapping to the source image. In order to assess the quality of the warping between the two images, an objective function based on the normalised mutual information is used, with penalty terms based on the bending energy or the squared log of the Jacobian determinant. The objective function value is optimised using a conjugate gradient scheme.
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 image of control points is returned for each registration performed.
The symmetric
option allows registration to be performed in both directions simultaneously. This may be preferable to performing two one-way registrations, since a constraint is applied to ensure that the control point maps in the two directions are consistent. However, the source and target images must have the same dimensionality in this case, and an initial control point map may not be used.
The applyControlPoints
function is a convenience wrapper that calls niftyreg.nonlinear
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.nonlinear
.
M. Modat, G.R. Ridgway, Z.A. Taylor, M. Lehmann, J. Barnes, D.J. Hawkes, N.C. Fox & S. Ourselin (2010). Fast free-form deformation using graphics processing units. Computer Methods and Programs in Biomedicine 98(3):278-284.
niftyreg
, which can be used as an interface to this function, and niftyreg.linear
for linear registration. Also, transformWithControlPoints
for transforming points, rather than images, using the estimated control points. See 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
.