v2.0.0
Loading...
Searching...
No Matches
mri_types.h File Reference

Numeric type codes, layout constants, and sentinel values shared by every MRI reader. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  MRILIB
 Volume I/O, voxel geometry and slice resampling for structural MRI data inside mne-cpp.

Variables

MGH Format Version
constexpr int MRILIB::MRI_MGH_VERSION = 1
MGH Voxel Data Types

Data type codes for voxels in MGH/MGZ files. From FreeSurfer mri.h and MNE C mne_types_mne-c.h.

See: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat "type: data type of the image buffer; can be one of the following: UCHAR, SHORT, INT, or FLOAT (specified as 0, 4, 1, or 3, respectively)"

constexpr int MRILIB::MRI_UCHAR = 0
constexpr int MRILIB::MRI_INT = 1
constexpr int MRILIB::MRI_LONG = 2
constexpr int MRILIB::MRI_FLOAT = 3
constexpr int MRILIB::MRI_SHORT = 4
constexpr int MRILIB::MRI_BITMAP = 5
constexpr int MRILIB::MRI_TENSOR = 6
Frame Loading Constants
constexpr int MRILIB::MRI_ALL_FRAMES = -1
constexpr int MRILIB::MRI_NO_FRAMES = -2
MGH Header Constants

Fixed offsets and sizes in the MGH file header. See: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat

constexpr int MRILIB::MRI_MGH_DATA_OFFSET = 284
constexpr int MRILIB::MRI_MGH_HEADER_FIXED_SIZE = 30
MGH Footer Tag Types

Tag identifiers found in the MGH footer after the voxel data. From FreeSurfer tags.h.

constexpr int MRILIB::MGH_TAG_OLD_SURF_GEOM = 20
constexpr int MRILIB::MGH_TAG_OLD_MGH_XFORM = 30
constexpr int MRILIB::MGH_TAG_MGH_XFORM = 31
COR Slice Constants

Fixed dimensions for FreeSurfer COR slice files. COR files contain 256 coronal slices of 256×256 unsigned chars at 1mm isotropic.

constexpr int MRILIB::COR_NSLICE = 256
constexpr int MRILIB::COR_WIDTH = 256
constexpr int MRILIB::COR_HEIGHT = 256
constexpr float MRILIB::COR_PIXEL_SIZE = 1e-3f

Detailed Description

Numeric type codes, layout constants, and sentinel values shared by every MRI reader.

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.0.0
Date
February 2026

Centralises the four magic-number families that show up in every MGH/MGZ, COR and (indirectly) NIfTI reader so that the I/O classes themselves stay free of stray integer literals:

  • voxel-type codes (MRI_UCHAR, MRI_INT, MRI_FLOAT, MRI_SHORT) used to decode the type field of the MGH header and to dispatch the corresponding QVector storage on the consumer side;
  • frame-selection sentinels (MRI_ALL_FRAMES, MRI_NO_FRAMES) used by the MGH reader API to distinguish "read everything" from "header-only" without overloading the parameter type;
  • format-version (MRI_MGH_VERSION = 1, the only value any FreeSurfer-produced MGH file should ever carry) used as a sanity gate when a candidate file is opened;
  • COR geometry constants (slice size, isotropic 1 mm voxel edge) used to materialise the per-slice coordinate transforms.

Format reference: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat These constants originate from FreeSurfer's mri.h and were ported via MNE C's mne_types_mne-c.h by Matti Hamalainen.

Definition in file mri_types.h.