The niftyreg
function performs linear or 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. This
function is a common wrapper for niftyreg.linear
and
niftyreg.nonlinear
.
niftyreg(source, target, scope = c("affine", "rigid", "nonlinear"),
init = NULL, sourceMask = NULL, targetMask = NULL, symmetric = TRUE,
interpolation = 3L, estimateOnly = FALSE, sequentialInit = FALSE,
internal = NA, precision = c("double", "single"),
threads = getOption("RNiftyReg.threads"), ...)# S3 method for niftyreg
asNifti(x, ...)
# S3 method for niftyreg
as.array(x, ...)
A list of class "niftyreg"
with components:
An array or internal image representing the registered and
resampled source
image in the space of the target
image.
This element is NULL
if the estimateOnly
parameter is
TRUE
.
A list of (linear or nonlinear) transformations from source to target space.
A list of (linear or nonlinear) transformations from target to source space.
A list of integer vectors, giving the number of iterations completed at each ``level'' of the algorithm. Note that for the first level of the linear algorithm specifically, twice the specified number of iterations is allowed.
An internal representation of the source image for each registration.
An internal representation of the target image.
The as.array
method for this class returns the image
element.
The source image, an object of class "nifti"
or
"internalImage"
, or a plain array, or a NIfTI-1 filename. Must have
2, 3 or 4 dimensions.
The target image, an object of class "nifti"
or
"internalImage"
, or a plain array, or a NIfTI-1 filename. Must have
2 or 3 dimensions.
A string describing the scope, or number of degrees of freedom
(DOF), of the registration. The currently supported values are
"affine"
(12 DOF), "rigid"
(6 DOF) or "nonlinear"
(high DOF, with the exact number depending on the image sizes).
Transformation(s) to be used for initialisation, which may be
NULL
, for no initialisation, or an affine matrix or control point
image (nonlinear only). For multiple registration, where the source image
has one more dimension than the target, this may also be a list whose
components are likewise NULL
or a suitable initial transform.
An optional mask image in source space, whose nonzero
region will be taken as the region of interest for the registration.
Ignored when symmetric
is FALSE
.
An optional mask image in target space, whose nonzero region will be taken as the region of interest for the registration.
Logical value. Should forward and reverse transformations be estimated simultaneously?
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
, transformations will be
estimated, but images will not be resampled.
If TRUE
and source
has higher
dimensionality than target
, transformations which are not
explicitly initialised will begin from the result of the previous
registration.
If NA
, the default, the final resampled image will be
returned as a standard R array, but control point maps will be objects of
class "internalImage"
, containing only basic metadata and a C-level
pointer to the full image. (See also readNifti
.) If
TRUE
, all image-type objects in the result will be internal images;
if FALSE
, they will all be R arrays. The default is fine for most
purposes, but using TRUE
may save memory, while using FALSE
can be necessary if there is a chance that external pointers will be
invalidated, for example when returning from worker threads.
Working precision for the registration. Using single- precision may be desirable to save memory when coregistering large images.
For OpenMP-capable builds of the package, the maximum number of threads to use.
Further arguments to niftyreg.linear
or
niftyreg.nonlinear
.
A "niftyreg"
object.
Jon Clayden <code@clayden.org>
Please see niftyreg.linear
or
niftyreg.nonlinear
for references relating to each type of
registration.
niftyreg.linear
and niftyreg.nonlinear
,
which do most of the work. Also, forward
and
reverse
to extract transformations, and
applyTransform
to apply them to new images or points.
if (FALSE) {
source <- readNifti(system.file("extdata", "epi_t2.nii.gz",
package="RNiftyReg"))
target <- readNifti(system.file("extdata", "flash_t1.nii.gz",
package="RNiftyReg"))
result <- niftyreg(source, target, scope="affine")
}
Run the code above in your browser using DataLab