This function calls the readNifti function from the RNifti package, and then converts the image to a nifti object

fast_readnii(fname, dtype = TRUE, drop_dim = TRUE)

Arguments

fname

file name of the NIfTI file.

dtype

Should datatyper be run after reading?

drop_dim

Should drop_img_dim be run after reading?

Value

A nifti object

Examples

set.seed(5)
dims = rep(10, 4)
arr = array(rpois(prod(dims), lambda = 2), dim = dims)
nim = oro.nifti::nifti(arr)
tfile = tempfile(fileext = ".nii.gz")
write_nifti(nim, tfile)
rimg = fast_readnii(tfile)