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

Arguments

nim

object of class nifti, passed to writeNIfTI

filename

path to save the NIfTI file. Suffix will be removed

dtype

Should datatyper be run before writing?

compression

compression level for gzipped files.

...

Additional arguments passed to writeNIfTI

drop_dim

Should drop_img_dim be run before writing?

warn

Should warnings from writeNIfTI be printed? If not, suppressWarnings is called

rm_extensions

should niftiExtensions be converted to simple nifti objects before writing?

Value

Nothing

Note

While writeNIfTI2 does not run datatyper as default, writenii does. Additional functionality will be added to writenii likely but will not to writeNIfTI2

Examples

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
timg = writeNIfTI2(nim, tfile, dtype = TRUE)
#> Warning: Assuming FLOAT32