Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

writeNifti

Write a NIfTI or ANALYZE format file


Description

These functions write an image to NIfTI-1, NIfTI-2 or ANALYZE-7.5 format, using the standard NIfTI C library.

Usage

writeNifti(image, file, template = NULL, datatype = "auto", version = 1)

writeAnalyze(image, file, template = NULL, datatype = "auto")

Arguments

image

An image, in any acceptable form (see asNifti).

file

A character string containing a file name.

template

An optional template object to derive NIfTI-1 properties from. Passed to asNifti if image is an array.

datatype

The NIfTI datatype to use when writing the data out. The default, "auto" uses the R type or, for internal images, the original datatype. Other possibilities are "float", "int16", etc., which may be preferred to reduce file size. However, no checks are done to ensure that the coercion maintains precision.

version

An integer (1 or 2) giving the NIfTI file format version to use. Version 2 is usually only needed for very large images or where metadata needs to be stored with high precision. The types available for storing the pixel data are the same in both cases.

Value

An invisible, named character vector giving the image and header file names written to.

Note

The ANALYZE-7.5 file format is a legacy format and use of it is not recommended, except for compatibility. In particular, the format does not reliably specify the spatial orientation of the image.

Author(s)

Jon Clayden <code@clayden.org>

References

See Also

Examples

## Not run: writeNifti(im, "image.nii.gz", datatype="float")

RNifti

Fast R and C++ Access to NIfTI Images

v1.3.0
GPL-2
Authors
Jon Clayden [cre, aut] (<https://orcid.org/0000-0002-6608-0619>), Bob Cox [aut], Mark Jenkinson [aut], Matt Hall [ctb], Rick Reynolds [ctb], Kate Fissell [ctb], Jean-loup Gailly [cph], Mark Adler [cph]
Initial release
2020-12-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.