Skip to main content

MriNiftiIO

Namespace: MRILIB  ·  Library: MRI Library

#include <mri/mri_nifti_io.h>

class MRILIB::MriNiftiIO

Stateless decoder for NIfTI-1 single-file volumes (.nii and .nii.gz).

Parses the 348-byte fixed-size header, expands any voxel-type / endianness combination NIfTI-1 supports into the canonical 16-bit unsigned slice buffer produced by MriMghIO, and resolves voxel\u2192RAS via the sform/qform/pixdim priority chain. The class is a pure namespace of static methods so callers can use it without owning any state; the populated MriVolData carries the result.


Static Methods

read(niiFile, volData, verbose)

Reads a NIfTI-1 single-file volume.

For ``.nii.gz inputs the file is decompressed in memory via zlib (re-using the same MAX_WBITS+16 strategy as [MriMghIO](/docs/api/mri/mri-mgh-io)).

Parameters:

  • niiFile : const QString & Path to the .nii or .nii.gz file.

  • volData : MriVolData & Volume to populate.

  • verbose : bool Print header geometry on success.

Returns:

  • bool — True on success, false on parse / I/O error.

decompress(gzFile, rawData)

Decompresses a ``.nii.gz file into rawData.

Exposed for direct use by tests; read calls it transparently when the input path ends in ``.gz.

Parameters:

  • gzFile : const QString & Path to the gzip-compressed input.

  • rawData : QByteArray & Output buffer.

Returns:

  • bool — True on success.

Authors of this file