Main Content

niftiinfo

Read metadata from NIfTI file

Description

info = niftiinfo(filename) returns metadata, info, from the Neuroimaging Informatics Technology Initiative (NIfTI) file specified by filename. The niftiinfo function supports both the NIfTI1 and NIfTI2 file formats.

example

Examples

collapse all

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

collapse all

Name of NIfTI file, specified as a string scalar or a character vector.

  • If you do not specify a file extension, then niftiinfo looks for a file with the extension .nii (or .nii.gz if the file is compressed).

  • If niftiinfo cannot find a file with the .nii or .nii.gz extension, then it looks for a file with the file extension .hdr (or .hdr.gz if the file is compressed). In the dual-file NIfTI format, the .hdr file holds the metadata associated with the volume.

Data Types: char | string

Output Arguments

collapse all

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 R2017b