applyTransform: Apply a precomputed transformation

Description Usage Arguments Details Value Author(s) See Also


This function allows a precomputed transformation to be applied to a new image or set of points.


applyTransform(transform, x, interpolation = 3L, nearest = FALSE,
  internal = FALSE)



A transform, possibly obtained from forward or reverse.


A numeric vector, representing a pixel/voxel location in source space, or a matrix with rows representing such points, or an image with the same dimensions as the original source image.


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.


Logical value: if TRUE and x contains points, the nearest voxel centre location in target space will be returned. Otherwise a more precise subvoxel location will be given.


If FALSE, the default, the returned image will be returned as a standard R array. If TRUE, it will instead be an object of class "internalImage", containing only basic metadata and a C-level pointer to the full image. (See also readNifti.) This can occasionally be useful to save memory.


Points may be transformed from source to target space exactly under an affine transformation, but nonlinear transformation is inexact. Its accuracy will depend to some extent on the density of the control point grid and the geometry of the deformation in the vicinity of the points of interest. Nevertheless, it should be quite sufficient for most purposes.

The method is to first convert the control points to a deformation field (cf. deformationField), which encodes the location of each target space voxel in the source space. The target voxel closest to the requested location is found by searching through this deformation field, and returned if nearest is TRUE or it coincides exactly with the requested location. Otherwise, a block of four voxels in each dimension around the point of interest is extracted from the deformation field, and the final location is estimated by local cubic spline regression.


A resampled image or matrix of transformed points.


Jon Clayden <[email protected]>

See Also

niftyreg.linear, niftyreg.nonlinear

RNiftyReg documentation built on Sept. 11, 2019, 9:05 a.m.