Learn R Programming

neurobase (version 1.32.4)

check_nifti-methods: Check if nifti image or read in a nifti image

Description

Simple check to see if input is character or of class nifti

Usage

check_nifti(
  x,
  reorient = FALSE,
  allow.array = FALSE,
  fast = FALSE,
  need_header = TRUE,
  ...
)

# S4 method for nifti check_nifti( x, reorient = FALSE, allow.array = FALSE, fast = FALSE, need_header = TRUE, ... )

# S4 method for character check_nifti( x, reorient = FALSE, allow.array = FALSE, fast = FALSE, need_header = TRUE, ... )

# S4 method for factor check_nifti( x, reorient = FALSE, allow.array = FALSE, fast = FALSE, need_header = TRUE, ... )

# S4 method for list check_nifti( x, reorient = FALSE, allow.array = FALSE, fast = FALSE, need_header = TRUE, ... )

# S4 method for array check_nifti( x, reorient = FALSE, allow.array = FALSE, fast = FALSE, need_header = FALSE, ... )

# S4 method for anlz check_nifti( x, reorient = FALSE, allow.array = FALSE, fast = FALSE, need_header = TRUE, ... )

# S4 method for ANY check_nifti( x, reorient = FALSE, allow.array = FALSE, fast = FALSE, need_header = TRUE, ... )

Value

nifti object or array if allow.array=TRUE and x is an array

Arguments

x

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

reorient

(logical) passed to readnii if the image is to be re-oriented

allow.array

(logical) Are array types allowed (TRUE) or should there be an error if the object is not character or class nifti.

fast

if TRUE, then fast_readnii will be used versus readnii if the files need to be read in.

need_header

if TRUE, then an image type with header information will be returned. If not, then an array is fine. Used really only in conjunction with allow.array

...

additional arguments to pass to readnii if relevant

Author

John Muschelli muschellij2@gmail.com

See Also

readnii

Examples

Run this code
x = nifti()
check_nifti(x)
set.seed(5)
dims = rep(10, 4)
arr = array(rpois(prod(dims), lambda = 2), dim = dims)
nim = oro.nifti::nifti(arr)
check_nifti(nim)
check_nifti(as.anlz(nim))
testthat::expect_error(check_nifti(arr, allow.array = FALSE))
tfile = tempimg(nim)
check_nifti(c(tfile, tfile))
check_nifti(list(tfile, tfile))
check_nifti(factor(c(tfile, tfile)))
check_nifti(RNifti::readNifti(tfile))

Run the code above in your browser using DataLab