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

readNifti

Read NIfTI or ANALYZE format files


Description

This function reads one or more NIfTI-1, NIfTI-2 or ANALYZE-7.5 files into R, using the standard NIfTI C library.

Usage

readNifti(file, internal = FALSE, volumes = NULL)

Arguments

file

A character vector of file names.

internal

Logical value. If FALSE (the default), an array of class "niftiImage", containing the image pixel or voxel values, will be returned. If TRUE, the return value will be an object of class "internalImage", which contains only minimal metadata about the image. Either way, the return value has an attribute which points to a C data structure containing the full image.

volumes

An integer vector giving the volumes to read (counting along all dimensions beyond the third jointly), or NULL, the default, in which case every volume is read. This cannot currently be set differently for each file read.

Value

An array or internal image, with class "niftiImage" (and possibly also "internalImage"), or a list of such objects if file has length greater than one.

Note

If the internal argument is FALSE (the default), the data type of the image pointer will be set to match one of R's native numeric data types, i.e., 32-bit signed integer or 64-bit double-precision floating-point. In these circumstances the data type reported by the niftiHeader function will therefore not, in general, match the storage type used in the file. See also the datatype argument to writeNifti.

Author(s)

Jon Clayden <code@clayden.org>

References

See Also

Examples

path <- system.file("extdata", "example.nii.gz", package="RNifti")
readNifti(path)
readNifti(path, internal=TRUE)

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.