Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

niftiread

Read NIfTI image

Syntax

V = niftiread(filename)
V = niftiread(headerfile,imgfile)
V = niftiread(info)

Description

example

V = niftiread(filename) reads the NIfTI image file specified by filename, in the current folder or on the path, and returns volumetric data in V.

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 format stores data in a pair of files: a header file (.hdr) containing the metadata and a data file (.img). The single file format stores the data in a single file (.nii), which contains header information followed by data.

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 structure info. To create an info structure, use the niftiinfo function

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 .nii file extension.

V = niftiread('brain.nii');

View the variable in the workspace.

whos V
  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 by niftiinfo.

V = niftiread(info);

View the variable in the workspace.

whos V
  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. If you do not specify a file extension, niftiread looks for a file with the .nii extension. If niftiread cannot find a file with that extension, it looks for a gzipped version of the file, with extension .nii.gz. If niftiread cannot find a file with that extension, it looks for a file with the .hdr, .hdr.gz, .img, or .img.gz file extension. If niftiread cannot find a file that matches any of these options, 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 corresponding imgfile, then niftiread looks in the same folder for a file with the same name and extension .img.

Data Types: char | string

Name of the file containing volume, specified as a string scalar or a character vector. The NIfTI image file (.img) holds the volume data. If you do not specify a corresponding header file, niftiread looks 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 by niftiinfo.

Data Types: struct

Output Arguments

collapse all

Volumetric data, returned as a numeric array.

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. " Neuroimage, Vol. 22(Suppl 1):e1440, 2004.

Introduced in R2017b

Was this topic helpful?