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

check_nifti-methodsR Documentation

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 signature 'nifti'
check_nifti(
  x,
  reorient = FALSE,
  allow.array = FALSE,
  fast = FALSE,
  need_header = TRUE,
  ...
)

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

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

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

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

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

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

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

Value

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

Author(s)

John Muschelli muschellij2@gmail.com

See Also

readnii

Examples

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))

neurobase documentation built on May 29, 2024, 2:17 a.m.