View source: R/antsApplyTransforms.R
antsApplyTransforms | R Documentation |
Apply a transform list to map an image from one domain to another. In image registration, one computes mappings between (usually) pairs of images. These transforms are often a sequence of increasingly complex maps, e.g. from translation, to rigid, to affine to deformation. The list of such transforms is passed to this function to interpolate one image domain into the next image domain, as below. The order matters strongly and the user is advised to familiarize with the standards established in examples.
antsApplyTransforms(
fixed,
moving,
transformlist = "",
interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline",
"cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc",
"lanczosWindowedSinc", "genericLabel"),
imagetype = 0,
whichtoinvert = NA,
compose = NA,
verbose = FALSE,
...
)
fixed |
fixed image defining domain into which the moving image is transformed. |
moving |
moving image to be mapped to fixed space. |
transformlist |
character vector of transforms generated by antsRegistration where each transform is a filename. |
interpolator |
Choice of interpolator. Supports partial matching.
|
imagetype |
choose 0/1/2/3 mapping to scalar/vector/tensor/time-series |
whichtoinvert |
optional list of booleans, same length as transforms. whichtoinvert[i] is TRUE if transformlist[i] is a matrix, and the matrix should be inverted. If transformlist[i] is a warp field, whichtoinvert[i] must be FALSE. If the transform list is a matrix followed by a warp field, whichtoinvert defaults to c(TRUE,FALSE). Otherwise it defaults to rep(FALSE, length(transformlist)). |
compose |
if it is a character string pointing to a valid file location, this will force the function to return a composite transformation filename. |
verbose |
print command and run verbose application of transform. |
... |
extra parameters |
an antsImage or transformation filename is output. 1 – Failure
Shrinidhi KL, Avants BB
antsRegistration
# will give the full form of help
antsApplyTransforms("-h")
# see antsRegistration
# example 1 - simplified
fixed <- ri(1)
moving <- ri(2)
fixed <- resampleImage(fixed, c(64, 64), 1, 0)
moving <- resampleImage(moving, c(68, 68), 1, 0)
mytx <- antsRegistration(
fixed = fixed, moving = moving,
typeofTransform = "SyN", verbose = TRUE, printArgs = TRUE
)
mywarpedimage <- antsApplyTransforms(
fixed = fixed, moving = moving,
transformlist = mytx$fwdtransforms
)
testthat::expect_true(antsImagePhysicalSpaceConsistency(mywarpedimage, fixed))
invwarped_image <- antsApplyTransforms(
fixed = moving, moving = fixed,
transformlist = mytx$invtransforms
)
testthat::expect_true(antsImagePhysicalSpaceConsistency(invwarped_image, moving))
# full access via listing the inputs in standard ANTs format
res1 <- antsApplyTransforms(
fixed = fixed, moving = moving,
transformlist = mytx$fwdtransforms[2],
whichtoinvert = 1, verbose = TRUE
)
cfile <- antsApplyTransforms(
fixed = fixed, moving = moving,
transformlist = mytx$fwdtransforms,
compose = tempfile()
)
cimg <- antsImageRead(cfile)
cout <- antsApplyTransforms(
fixed = fixed, moving = moving,
transformlist = cimg
)
testthat::expect_error(
antsApplyTransforms(
fixed = fixed, moving = moving,
transformlist = cimg, whichtoinvert = 1
), "nnot invert transform"
)
testthat::expect_error(
antsApplyTransforms(
fixed = fixed, moving = moving,
transformlist = cimg, whichtoinvert = c(1, 2)
), "same length"
)
testthat::expect_error(antsApplyTransforms(
fixed = fixed, moving = moving,
transformlist = ""
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.