v2.0.0
Loading...
Searching...
No Matches
mri_nifti_io.cpp File Reference

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>
Include dependency graph for mri_nifti_io.cpp:

Go to the source code of this file.

Detailed Description

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

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.2.1
Date
May 2026

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.