FiffCoordTransSet
Namespace: FIFFLIB · Library: FIFF Library
#include <fiff/fiff_coord_trans_set.h>
class FIFFLIB::FiffCoordTransSet
The chain of transforms from MEG head coordinates to MNI and FreeSurfer Talairach coordinates.
Head -> surface RAS (the FreeSurfer MRI frame) comes from the coregistration, surface RAS -> scanner RAS from the centre (c_ras) of the subject's MRI, scanner RAS -> MNI Talairach from mri/transforms/talairach.xfm, and MNI -> FreeSurfer Talairach from the fixed Brett approximations MNE-C uses (one matrix above and one below the AC-PC plane). Empty transforms mark links that are not known.
// Head -> MRI -> RAS -> MNI Talairach -> Talairach, as mne_analyze reports a picked location
FiffCoordTransSet chain;
chain.read(dir + "/../../subjects/sample/mri/brain-neuromag/sets/COR.fif"); // surface RAS -> RAS of the MRI set
chain.read(dir + "/all-trans.fif"); // the coregistration, head -> MRI
chain.addTalairach(QStringLiteral(MNE_TALAIRACH_XFM)); // the subject's mri/transforms/talairach.xfm
MatrixX3f headPoints(1, 3);
headPoints << 0.03f, -0.02f, 0.12f;
const MatrixX3f mni = chain.headToMni(headPoints);
const MatrixX3f talairach = chain.mniToTalairach(mni);
Public Methods
addTalairach(xfmPath)
Sets the RAS -> MNI transform from a .xfm file and the two MNI -> FreeSurfer Talairach transforms (MNE-C mne_mri_add_talairach_transforms).
Parameters:
- xfmPath : const QString &
Path to the
talairach.xfmfile.
Returns:
- bool — True if the .xfm file could be read.
read(path)
Takes every transform of the chain stored in a FIFF file, such as a -trans.fif file or a COR.fif MRI set (MNE-C mne_collect_transforms).
Transforms already in the set are replaced, so read the MRI set first and the coregistration last.
Parameters:
- path : const QString & FIFF file path.
Returns:
- int — The number of transforms taken from the file, or -1 if the file cannot be opened.
write(stream)
Writes every non-empty transform, head -> MRI first.
Parameters:
- stream : FiffStream & An open FIFF stream.
headToMni(rr)
Maps MEG head coordinates to MNI Talairach coordinates, as mne.head_to_mni does.
Parameters:
- rr : const Eigen::MatrixX3f & Points in head coordinates (metres), one per row.
Returns:
- Eigen::MatrixX3f — The points in MNI Talairach coordinates (metres), or an empty matrix if a link of the chain is missing.
mniToTalairach(rr)
Maps MNI Talairach coordinates to FreeSurfer Talairach coordinates, using the transform for points above or below the AC-PC plane (MNI z > 0 or not).
Parameters:
- rr : const Eigen::MatrixX3f & Points in MNI Talairach coordinates (metres), one per row.
Returns:
- Eigen::MatrixX3f — The points in FreeSurfer Talairach coordinates (metres), or an empty matrix if the transforms are missing.
Static Methods
readMniTransform(path)
Reads the scanner RAS -> MNI Talairach transform of a FreeSurfer/MNI .xfm file (MNE-C read_mni_coord_transform_file).
Parameters:
- path : const QString &
Path to the .xfm file, usually
mri/transforms/talairach.xfmin the subject directory.
Returns:
- FiffCoordTrans — The transform in metres, or an empty transform if the file holds no linear transform.
Example
- Full source:
src/examples/ex_fiff_api/main.cpp - Build target:
ex_fiff_api(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_fiff_api
FIFF library: measurement info, channels, digitizer, transforms, projectors, covariance, events,.
// Head -> MRI -> RAS -> MNI Talairach -> Talairach, as mne_analyze reports a picked location
FiffCoordTransSet chain;
chain.read(dir + "/../../subjects/sample/mri/brain-neuromag/sets/COR.fif"); // surface RAS -> RAS of the MRI set
chain.read(dir + "/all-trans.fif"); // the coregistration, head -> MRI
chain.addTalairach(QStringLiteral(MNE_TALAIRACH_XFM)); // the subject's mri/transforms/talairach.xfm
MatrixX3f headPoints(1, 3);
headPoints << 0.03f, -0.02f, 0.12f;
const MatrixX3f mni = chain.headToMni(headPoints);
const MatrixX3f talairach = chain.mniToTalairach(mni);
// mne.head_to_mni([0.03, -0.02, 0.12], "sample", mri_head_t): (36.47, -65.50, 57.83) mm
ok &= expect(mni.rows() == 1 && (mni.row(0) - RowVector3f(0.036469229f, -0.065504959f, 0.057827104f)).norm() < 1e-6f && (talairach.row(0) - RowVector3f(0.036104536f, -0.060801158f, 0.056314317f)).norm() < 1e-6f,
"FiffCoordTransSet: head point at (36.47, -65.50, 57.83) mm MNI like mne.head_to_mni");
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>