Apply a transform list to map a pointset from one domain to another. In registration, one computes mappings between pairs of domains. 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. Importantly, point mapping goes the opposite direction of image mapping, for both reasons of convention and engineering.

antsApplyTransformsToPoints(
  dim,
  points,
  transformlist = "",
  whichtoinvert = NA
)

Arguments

dim

dimensionality of the transformation.

points

moving point set with n-points in rows of at least dim columns - we maintain extra information in additional columns. this may be either a dataframe or a 2D antsImage - the latter may be better for large pointsets.

transformlist

character vector of transforms generated by antsRegistration where each transform is a filename.

whichtoinvert

vector of booleans, same length as transforms

Value

same type as input. 1 – Failure

See also

Author

Avants BB

Examples


fixed <- antsImageRead(getANTsRData("r16"), 2)
moving <- antsImageRead(getANTsRData("r64"), 2)
fixed <- resampleImage(fixed, c(64, 64), 1, 0)
moving <- resampleImage(moving, c(64, 64), 1, 0)
mytx <- antsRegistration(
  fixed = fixed, moving = moving,
  typeofTransform = c("SyN"), verbose = FALSE
)
pts <- data.frame(
  x = c(110.5, 120, 130), y = c(108.1, 121.0, 130),
  label = c(1, 2, 3)
)
wpts <- antsApplyTransformsToPoints(
  dim = 2, points = pts,
  transformlist = mytx$fwdtransforms
)
wptsi <- antsApplyTransformsToPoints(
  dim = 2, points = wpts,
  transformlist = mytx$invtransforms
) # close to pts

if (FALSE) { # \dontrun{
fixed <- antsImageRead(getANTsRData("r16"), 2)
moving <- antsImageRead(getANTsRData("r64"), 2)
fpts <- kmeansSegmentation(fixed, 3)$segmentation %>%
  thresholdImage(1, 1) %>%
  labelClusters(5) %>%
  getCentroids(5)
wpts <- antsApplyTransformsToPoints(
  dim = 2, points = fpts,
  transformlist = mytx$fwdtransforms
)
labimgf <- fixed * 0
labimgm <- moving * 0
for (p in 1:nrow(wpts))
{
  pt <- as.numeric(wpts[p, 1:2])
  idx <- round(antsTransformPhysicalPointToIndex(moving, pt))
  labimgm[idx[1], idx[2]] <- p
  pt <- as.numeric(fpts[p, 1:2])
  idx <- round(antsTransformPhysicalPointToIndex(fixed, pt))
  labimgf[idx[1], idx[2]] <- p
}
plot(fixed, labimgf %>% iMath("GD", 2))
plot(moving, labimgm %>% iMath("GD", 2))
} # }