Ensures the output to be a character filename (or vector) from an input image or nifti, but not gzipped and has .nii extension

checknii(file, ...)

# S4 method for nifti
checknii(file, ...)

# S4 method for factor
checknii(file, ...)

# S4 method for character
checknii(file, ...)

# S4 method for list
checknii(file, ...)

# S4 method for ANY
checknii(file, ...)

ensure_nii(file, ...)

Arguments

file

character or nifti object

...

options passed to checkimg

Value

character filename of image or temporary nii, with .nii extension

Author

John Muschelli muschellij2@gmail.com

Examples

set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)
rnifti = RNifti::asNifti(nim)
timg = tempimg(nim)
limg = list(factor(timg), factor(timg))
func = checknii
func(nim)
#> [1] "/tmp/RtmpBb1B9G/file16b737988d668.nii"
func(rnifti)
#> [1] "/tmp/RtmpBb1B9G/file16b7357214b05.nii"
func(timg)
#> [1] "/tmp/RtmpBb1B9G/file16b73dccf771.nii"
#> attr(,"nbrOfBytes")
#> [1] 4352
func(limg)
#> [1] "/tmp/RtmpBb1B9G/file16b73dccf771.nii"
#> [2] "/tmp/RtmpBb1B9G/file16b73dccf771.nii"