Main Content

niftiread

Read NIfTI image

Description

example

V= niftiread(filename)reads the NIfTI image file specified byfilenamein the current folder or on the path, and returns volumetric data inV. Theniftireadfunction supports both theNIfTI1andNIfTI2file formats.

V= niftiread(headerfile,imgfile)reads a NIfTI header file (.hdr) and image file (.img) pair.

example

V= niftiread(info)reads a NIfTI file described by the metadata structureinfo. To create aninfostructure, use theniftiinfofunction

Examples

collapse all

Load volumetric data from a NIfTI file. The file uses the NIfTI combined format—the image and metadata are in the same file. This type of NIfTI file has the.niifile extension.

V = niftiread('brain.nii');

View the variable in the workspace.

whosV
Name Size Bytes Class Attributes V 256x256x21 1376256 uint8

Read the metadata from a NIfTI file.

info = niftiinfo('brain.nii');

Read the volumetric image using the metadata structure returned byniftiinfo.

V = niftiread(info);

View the variable in the workspace.

whosV
Name Size Bytes Class Attributes V 256x256x21 1376256 uint8

Input Arguments

collapse all

Name of the NIfTI file, specified as a string scalar or character vector. The file can be in theNIfTI1orNIfTI2file format.

  • If you do not specify a file extension, thenniftireadlooks for a file with the.niiextension.

  • Ifniftireadcannot find a file with the.niiextension, then it looks for a gzipped version of the file, with extension.nii.gz.

  • Ifniftireadcannot find a file with the.nii.gzextension, then it looks for a file with the.hdr,.hdr.gz,.img, or.img.gzfile extension.

  • Ifniftireadcannot find a file that matches any of these options, then it returns an error.

Data Types:char|string

Name of the file containing metadata, specified as a string scalar or a character vector. The NIfTI header file (.hdr) holds the metadata associated with a NIfTI volume. If you do not specify a correspondingimgfile, thenniftireadlooks in the same folder for a file with the same name and extension.img.

Data Types:char|string

文件名包含体积,指定为一个string scalar or a character vector. The NIfTI image file (.img) holds the volume data. If you do not specify a corresponding header file, thenniftireadlooks in the same folder for a file with the same name and extension.hdr.

Data Types:char|string

NIfTI file metadata, specified as a structure returned byniftiinfo.

Data Types:struct

Output Arguments

collapse all

Volumetric data, returned as a numeric array.

More About

collapse all

NIfTI File Format

NIfTI (Neuroimaging Informatics Technology Initiative) is an NIH-sponsored working group to promote the interoperability of functional neuroimaging software tools. NIfTI uses a single or dual file storage format.

  • The dual file format stores data in a pair of files: a header file (.hdr) containing the metadata and a data file (.img) containing image data.

  • The single file format stores the data in a single file (.nii), which contains header information followed by image data.

References

[1]Cox, R. W., J. Ashburner, H. Breman, K. Fissell, C. Haselgrove, C. J. Holmes, J. L. Lancaster, D. E. Rex, S. M. Smith, J. B. Woodward, and S. C. Strother. "A (sort of) new image data format standard: NiFTI-1." 10th Annual Meeting of Organisation of Human Brain Mapping, Budapest, Hungary, June 2004.

Version History

Introduced in R2017b