FsAtlasLookup
Namespace: FSLIB · Library: FreeSurfer Library
#include <fs/fs_atlas_lookup.h>
class FSLIB::FsAtlasLookup
RAS-point → anatomical-region resolver backed by a FreeSurfer volumetric parcellation.
Owns the parcellation voxel grid, its inverse RAS-to-voxel affine, and a label-id → region-name map seeded from FreeSurferColorLUT. Designed for cheap per-point queries: a labelAtRas() call is an affine transform, three bound checks and an int → QString hash lookup.
QTemporaryDir dir;
const QString atlasPath = dir.filePath("atlas.mgh"); // normally aparc+aseg.mgz
writeAtlas(atlasPath);
FsAtlasLookup atlas;
atlas.load(atlasPath);
const QStringList regionsAt = atlas.labelsForPositions({Vector3f(-4.0f, -4.0f, -4.0f), Vector3f(2.0f, 0.0f, -2.0f), Vector3f(0.0f, 0.0f, 0.0f)});
Public Methods
FsAtlasLookup()
Constructs an empty atlas lookup.
load(sParcellationPath)
Load a FreeSurfer MGH/MGZ volume parcellation.
Parameters:
- sParcellationPath : const QString & Path to the volume file (e.g. aparc+aseg.mgz).
Returns:
- bool — true if loaded successfully.
labelAtRas(ras)
Look up the anatomical label at a RAS coordinate.
Parameters:
- ras : const Eigen::Vector3f & 3D position in RAS space (in mm).
Returns:
- QString — Label string, or "Unknown" if out of bounds or unlabeled.
labelsForPositions(positions)
Look up labels for multiple RAS positions.
Parameters:
- positions : const QVector< Eigen::Vector3f > & List of 3D RAS positions.
Returns:
- QStringList — List of label strings (one per position).
isLoaded()
Check whether a parcellation volume has been loaded.
Returns:
- bool — true if loaded.
Example
- Full source:
src/examples/ex_fs/main.cpp - Build target:
ex_fs(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_fs
FreeSurfer library: surfaces, curvature, parcellations, labels and an atlas volume.
QTemporaryDir dir;
const QString atlasPath = dir.filePath("atlas.mgh"); // normally aparc+aseg.mgz
writeAtlas(atlasPath);
FsAtlasLookup atlas;
atlas.load(atlasPath);
const QStringList regionsAt = atlas.labelsForPositions({Vector3f(-4.0f, -4.0f, -4.0f), Vector3f(2.0f, 0.0f, -2.0f), Vector3f(0.0f, 0.0f, 0.0f)});
// nibabel: inv(affine) maps (-4,-4,-4) to voxel (0,0,0) and (2,0,-2) to voxel (3,2,1)
ok &= expect(atlas.isLoaded() && regionsAt == QStringList({"Left-Hippocampus", "Right-Hippocampus", "Unknown"}),
QString("atlas lookup: %1").arg(regionsAt.join(", ")));
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>