Implementation of MRILIB::MriNiftiIO: 348-byte header parse, byte-order auto-detect, sform/qform/pixdim transform reconstruction. More...
#include "mri_nifti_io.h"#include "mri_types.h"#include "mri_vol_data.h"#include <fiff/fiff_file.h>#include <QByteArray>#include <QDataStream>#include <QDebug>#include <QFile>#include <QtEndian>#include <Eigen/Core>#include <zlib.h>#include <cmath>#include <cstring>
Go to the source code of this file.
Implementation of MRILIB::MriNiftiIO: 348-byte header parse, byte-order auto-detect, sform/qform/pixdim transform reconstruction.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors
Implements the three pieces the header documents: (1) a little-endian-by-default 348-byte header parse that flips to big-endian when sizeof_hdr fails its magic check and applies the swap uniformly to every multi-byte field; (2) the voxel reader, which respects datatype (UINT8 / INT16 / INT32 / FLOAT32, the four types we actually encounter in practice) and promotes to the matching MriSlice pixel buffer so round-tripping through MriCorFifIO stays lossless; (3) the sform \u2192 qform \u2192 pixdim transform fallback chain (the same ordering nibabel and FSL use) that produces a single canonical voxel\u2192RAS affine regardless of how the source file was authored. The .nii.gz path shares the MGZ zlib decoder so both compressed formats route through the same code.
Definition in file mri_nifti_io.cpp.