niftiinfo
R2026bRead metadata from NIfTI file
Description
Examples
Load metadata from the NIfTI file brain.nii.
info = niftiinfo('brain.nii');Display the version of the file.
info.Version
ans = 'NIfTI1'
Display the pixel dimensions of the file.
info.PixelDimensions
ans = 1×3
1 1 1
Display the raw header content.
info.raw
ans = struct with fields:
sizeof_hdr: 348
dim_info: ' '
dim: [3 256 256 21 1 1 1 1]
intent_p1: 0
intent_p2: 0
intent_p3: 0
intent_code: 0
datatype: 2
bitpix: 8
slice_start: 0
pixdim: [1 1 1 1 0 0 0 0]
vox_offset: 352
scl_slope: 0
scl_inter: 0
slice_end: 0
slice_code: 0
xyzt_units: 0
cal_max: 0
cal_min: 0
slice_duration: 0
toffset: 0
descrip: ''
aux_file: ''
qform_code: 0
sform_code: 0
quatern_b: 0
quatern_c: 0
quatern_d: 0
qoffset_x: 0
qoffset_y: 0
qoffset_z: 0
srow_x: [0 0 0 0]
srow_y: [0 0 0 0]
srow_z: [0 0 0 0]
intent_name: ''
magic: 'n+1 '
Display the intent code from the raw structure.
info.raw.intent_code
ans = 0
Input Arguments
Name of NIfTI file, specified as a string scalar or a character vector.
If you do not specify a file extension, then
niftiinfolooks for a file with the extension.nii(or.nii.gzif the file is compressed).If
niftiinfocannot find a file with the.niior.nii.gzextension, then it looks for a file with the file extension.hdr(or.hdr.gzif the file is compressed). In the dual-file NIfTI format, the.hdrfile holds the metadata associated with the volume.
You can import valid data from URLs and remote locations, such as cloud
services, for easier collaboration and data management. Depending on the
location of your file, filename can take one of these
forms.
Location | Form | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Current folder or folder on the MATLAB® path | Specify the name of the file in
Example:
| ||||||||
File in a folder | If the file is not in the current folder or in a folder on the MATLAB path, then specify the full or relative path name. Example:
Example:
| ||||||||
| Uniform resource locator (URL) | If you specify the file as an internet URL,
then Example:
| ||||||||
Remote location | If the file is stored at a remote location,
then
Based on the remote
location,
For more information, see Work with Remote Data. Example:
|
The function downloads each new remote file only once per session to a temporary directory. If you access the same remote data again during the same MATLAB session, the function uses the downloaded file from the temporary directory.
Data Types: char | string
Output Arguments
Metadata associated with a NIfTI volume, returned as a structure.
niftiinfo returns the metadata from the header in
simplified form. The function renames, reorders, and packages fields into
easier to read MATLAB structures. For example, niftiinfo creates
the DisplayIntensityRange field from the
cal_max and cal_min fields of the
file metadata. To view the metadata as it appears in the file, see the
raw field of the structure returned.
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 R2017bFor easier collaboration and data management, you can import valid NIfTI data from URLs and remote locations such as cloud services.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)