v2.0.0
Loading...
Searching...
No Matches
MRILIB::MriVolData Class Reference

MRI volume data from FreeSurfer MGH/MGZ file. More...

#include <mri_vol_data.h>

Public Member Functions

 MriVolData ()
bool isValid () const
Eigen::Matrix4f computeVox2Ras () const

Public Attributes

QString fileName
int version
int width
int height
int depth
int nframes
int type
int dof
bool rasGood
float xsize
float ysize
float zsize
float x_ras [3]
float y_ras [3]
float z_ras [3]
float c_ras [3]
FIFFLIB::FiffCoordTrans voxelSurfRasT
float TR
float flipAngle
float TE
float TI
float FoV
QString talairachXfmPath
QVector< MriSliceslices

Detailed Description

MRI volume data from FreeSurfer MGH/MGZ file.

Holds a complete MRI volume loaded from a FreeSurfer MGH/MGZ file.

This class encapsulates all header geometry, coordinate transforms, scan parameters, and voxel data that describe a 3D MRI volume.

Based on the FreeSurfer MGH format specification: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat

Header structure (all big-endian):

  • version (int32): current value is 1
  • width (int32): first dimension (fastest-varying)
  • height (int32): second dimension
  • depth (int32): third dimension (slowest)
  • nframes (int32): number of scalar components per voxel
  • type (int32): voxel data type (MRI_UCHAR=0, MRI_INT=1, MRI_FLOAT=3, MRI_SHORT=4)
  • dof (int32): degrees of freedom
  • goodRASflag (int16): if true, direction cosines follow
  • spacingX/Y/Z (float32): voxel sizes in mm
  • Mdc (9×float32): direction cosine matrix (column-major)
  • c_ras (3×float32): center RAS coordinates
  • (padding to byte 284)

Image data starts at byte 284.

Footer (after data): optional scan parameters (TR, FlipAngle, TE, TI, FoV) and tags (Talairach transform path, provenance info).

Ported from mneMRIdataRec in MNE C (mne_types_mne-c.h) by Matti Hamalainen.

Definition at line 148 of file mri_vol_data.h.

Constructor & Destructor Documentation

◆ MriVolData()

MriVolData::MriVolData ( )

Default constructor.

Definition at line 52 of file mri_vol_data.cpp.

Member Function Documentation

◆ computeVox2Ras()

Matrix4f MriVolData::computeVox2Ras ( ) const

Builds the voxel-to-surface-RAS (MRI) 4×4 transform matrix.

Following FreeSurfer convention: M = Mdc * diag(xsize, ysize, zsize) P0 = c_ras - M * (dim/2) vox2ras = | M P0 | (in mm, converted to meters for FIFF) | 0 1 |

Returns
The 4×4 voxel-to-surface-RAS transform in meters.

Definition at line 87 of file mri_vol_data.cpp.

◆ isValid()

bool MriVolData::isValid ( ) const

Returns whether this volume contains valid data.

Returns
True if the volume has been loaded successfully.

Definition at line 80 of file mri_vol_data.cpp.

Member Data Documentation

◆ c_ras

float MRILIB::MriVolData::c_ras[3]

Center RAS coordinates (cr, ca, cs). Default: (0, 0, 0).

Definition at line 198 of file mri_vol_data.h.

◆ depth

int MRILIB::MriVolData::depth

Third dimension (slowest).

Definition at line 187 of file mri_vol_data.h.

◆ dof

int MRILIB::MriVolData::dof

Degrees of freedom.

Definition at line 190 of file mri_vol_data.h.

◆ fileName

QString MRILIB::MriVolData::fileName

Name of the source file.

Definition at line 183 of file mri_vol_data.h.

◆ flipAngle

float MRILIB::MriVolData::flipAngle

Flip angle (radians).

Definition at line 211 of file mri_vol_data.h.

◆ FoV

float MRILIB::MriVolData::FoV

Field of view (unreliable per FreeSurfer docs).

Definition at line 214 of file mri_vol_data.h.

◆ height

int MRILIB::MriVolData::height

Second dimension.

Definition at line 186 of file mri_vol_data.h.

◆ nframes

int MRILIB::MriVolData::nframes

Number of frames (scalar components per voxel).

Definition at line 188 of file mri_vol_data.h.

◆ rasGood

bool MRILIB::MriVolData::rasGood

Whether the direction cosines in the header are valid.

Definition at line 191 of file mri_vol_data.h.

◆ slices

QVector<MriSlice> MRILIB::MriVolData::slices

Per-slice data (for COR-equivalent representation).

Definition at line 226 of file mri_vol_data.h.

◆ talairachXfmPath

QString MRILIB::MriVolData::talairachXfmPath

Path to the Talairach .xfm file (from MGH footer tags).

Definition at line 220 of file mri_vol_data.h.

◆ TE

float MRILIB::MriVolData::TE

Echo time (ms).

Definition at line 212 of file mri_vol_data.h.

◆ TI

float MRILIB::MriVolData::TI

Inversion time (ms).

Definition at line 213 of file mri_vol_data.h.

◆ TR

float MRILIB::MriVolData::TR

Repetition time (ms).

Definition at line 210 of file mri_vol_data.h.

◆ type

int MRILIB::MriVolData::type

Voxel data type (MRI_UCHAR, MRI_INT, MRI_FLOAT, MRI_SHORT).

Definition at line 189 of file mri_vol_data.h.

◆ version

int MRILIB::MriVolData::version

MGH format version (should be 1).

Definition at line 184 of file mri_vol_data.h.

◆ voxelSurfRasT

FIFFLIB::FiffCoordTrans MRILIB::MriVolData::voxelSurfRasT

Voxel -> surface RAS (MRI) transform.

Definition at line 204 of file mri_vol_data.h.

◆ width

int MRILIB::MriVolData::width

First dimension of the image buffer (fastest).

Definition at line 185 of file mri_vol_data.h.

◆ x_ras

float MRILIB::MriVolData::x_ras[3]

X-direction cosines (xr, xa, xs). Default: (-1, 0, 0).

Definition at line 195 of file mri_vol_data.h.

◆ xsize

float MRILIB::MriVolData::xsize

Voxel spacing in X direction (mm).

Definition at line 192 of file mri_vol_data.h.

◆ y_ras

float MRILIB::MriVolData::y_ras[3]

Y-direction cosines (yr, ya, ys). Default: (0, 0, -1).

Definition at line 196 of file mri_vol_data.h.

◆ ysize

float MRILIB::MriVolData::ysize

Voxel spacing in Y direction (mm).

Definition at line 193 of file mri_vol_data.h.

◆ z_ras

float MRILIB::MriVolData::z_ras[3]

Z-direction cosines (zr, za, zs). Default: (0, 1, 0).

Definition at line 197 of file mri_vol_data.h.

◆ zsize

float MRILIB::MriVolData::zsize

Voxel spacing in Z direction (mm).

Definition at line 194 of file mri_vol_data.h.


The documentation for this class was generated from the following files: