motion_correction: Simple motion_correction function.

.motion_correctionR Documentation

Simple motion_correction function.

Description

motion corrects 4D time series imaging data

Usage

.motion_correction(
  img,
  fixed = NULL,
  moreaccurate = 1,
  txtype = "Affine",
  verbose = FALSE,
  num_threads = 1,
  seed = NULL
)

Arguments

img

4D antsImage

fixed

target fixed image

moreaccurate

0, 1 or 2 with higher values being more accurte (use 2 for real applications, 0 for testing)

txtype

Transformation type

verbose

verbosity boolean

num_threads

will execute Sys.setenv(ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS = num_threads) before running to attempt a more reproducible result. See https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues for discussion. If NULL, will not set anything.

seed

will execute Sys.setenv(ANTS_RANDOM_SEED = seed) before running to attempt a more reproducible result. See https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues for discussion. If NULL, will not set anything.

Value

list of outputs

Note

This function may give different results on multiple runs.

Author(s)

Avants BB

Examples

set.seed(1000)
testimg <- makeImage(c(10, 10, 10, 5), rnorm(5000))
testimg <- iMath(testimg, "PadImage", 5)
mocorr <- .motion_correction(testimg, num_threads = 1, seed = 10)
aimg_to_array <- function(x) {
  if (is.antsImage(x)) {
    x <- as.array(x)
  }
  x
}
amocorr <- lapply(mocorr, aimg_to_array)
mocorr2 <- .motion_correction(testimg, num_threads = 1, seed = 10)
amocorr2 <- lapply(mocorr2, aimg_to_array)

# This function may give different results on multiple runs
# without setting the seed

stnava/ANTsR documentation built on April 16, 2024, 12:17 a.m.