This function calls the writeNIfTI function from the
oro.nifti package, but makes sure to remove .nii extension and
warnings can be suppressed.
writeNIfTI2(nim, filename, dtype = FALSE, compression = 9, ...)
writenii(
nim,
filename,
dtype = TRUE,
drop_dim = TRUE,
warn = FALSE,
compression = 9,
rm_extensions = TRUE,
...
)object of class nifti, passed to writeNIfTI
path to save the NIfTI file. Suffix will be removed
Should datatyper be run before writing?
compression level for gzipped files.
Additional arguments passed to writeNIfTI
Should drop_img_dim be run before writing?
Should warnings from writeNIfTI be
printed? If not, suppressWarnings is called
should niftiExtensions be converted to simple nifti objects before writing?
Nothing
While writeNIfTI2 does not run datatyper as default,
writenii does. Additional functionality will be added to writenii likely
but will not to writeNIfTI2
set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
nim = oro.nifti::nifti(arr)
rnifti = RNifti::asNifti(nim)
tfile = tempfile(fileext = ".nii.gz")
timg = writenii(nim, tfile, rm_extensions = TRUE, warn = TRUE)
#> Warning: Assuming FLOAT32 - changing @bitpix and @datatype in header
timg = writeNIfTI2(nim, tfile, dtype = TRUE)
#> Warning: Assuming FLOAT32 - changing @bitpix and @datatype in header