resample_to_target-methods: Resample an Image to a Target Image

resample_to_target-methodsR Documentation

Resample an Image to a Target Image

Description

Resamples an antsImage or nifti object to a target

Usage

resample_to_target(
  img,
  target,
  interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline",
    "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc",
    "lanczosWindowedSinc", "genericLabel"),
  copy_origin = FALSE,
  ...
)

## S4 method for signature 'character'
resample_to_target(
  img,
  target,
  interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline",
    "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc",
    "lanczosWindowedSinc", "genericLabel"),
  copy_origin = FALSE,
  ...
)

## S4 method for signature 'nifti'
resample_to_target(
  img,
  target,
  interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline",
    "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc",
    "lanczosWindowedSinc", "genericLabel"),
  copy_origin = FALSE,
  ...
)

## S4 method for signature 'antsImage'
resample_to_target(
  img,
  target,
  interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline",
    "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc",
    "lanczosWindowedSinc", "genericLabel"),
  copy_origin = FALSE,
  ...
)

.resample_to_target(
  img,
  target,
  interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline",
    "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc",
    "lanczosWindowedSinc", "genericLabel"),
  copy_origin = FALSE,
  ...
)

Arguments

img

character path of image or an object of class nifti, or antsImage

target

image of reference, the output will be in this space. Will be coerced using check_ants

interpolator

what type of interpolation should be done

copy_origin

Copy image origin from target, using antsCopyOrigin

...

additional arguments to pass to resampleImageToTarget

Value

An antsImage or nifti depending on input

Examples

library(oro.nifti)
library(extrantsr)
n = 30
x = nifti(array(rnorm(n^3*10), dim = c(n, n, n)))
new_pixdim = c(0.5, 0.5, 0.5)
res = resample_image(x, parameters = new_pixdim)
x2 = resample_to_target(x, res)
pixdim(x2)[2:4]
stopifnot(all(pixdim(x2)[2:4] == new_pixdim))

muschellij2/extrantsr documentation built on June 3, 2024, 7:04 p.m.