v2.0.0
Loading...
Searching...
No Matches
FiffCoordTrans Class Reference

Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse. More...

#include <fiff_coord_trans.h>

Public Types

using SPtr = QSharedPointer<FiffCoordTrans>
using ConstSPtr = QSharedPointer<const FiffCoordTrans>
using UPtr = std::unique_ptr<FiffCoordTrans>
using ConstUPtr = std::unique_ptr<const FiffCoordTrans>

Public Member Functions

 FiffCoordTrans ()
 FiffCoordTrans (QIODevice &p_IODevice)
 FiffCoordTrans (const FiffCoordTrans &p_FiffCoordTrans)
 FiffCoordTrans (int from, int to, const Eigen::Matrix3f &rot, const Eigen::Vector3f &move)
 FiffCoordTrans (int from, int to, const Eigen::Matrix4f &matTrans, bool bStandard=false)
 ~FiffCoordTrans ()
void clear ()
bool invert_transform ()
bool isEmpty () const
Eigen::MatrixX3f apply_trans (const Eigen::MatrixX3f &rr, bool do_move=true) const
Eigen::MatrixX3f apply_inverse_trans (const Eigen::MatrixX3f &rr, bool do_move=true) const
FiffCoordTrans inverted () const
void print () const
void write (QIODevice &p_IODevice)
 Writes the transformation to file.
void writeToStream (FiffStream *p_pStream)
 Writes the transformation to a FIFF stream.
float angleTo (Eigen::MatrixX4f mTransDest)
float translationTo (Eigen::MatrixX4f mTransDest)
Rotation/Translation Accessors

Provide Matrix3f/Vector3f views into the 4×4 homogeneous matrices, matching the legacy FiffCoordTransOld member layout (rot, move, invrot, invmove). Mutable overloads allow direct modification of the underlying matrix blocks.

auto rot ()
auto rot () const
auto move ()
auto move () const
auto invrot ()
auto invrot () const
auto invmove ()
auto invmove () const

Static Public Member Functions

static bool read (QIODevice &p_IODevice, FiffCoordTrans &p_Trans)
static FiffCoordTrans readTransform (const QString &name, int from, int to)
static FiffCoordTrans readMriTransform (const QString &name)
static FiffCoordTrans readMeasTransform (const QString &name)
static FiffCoordTrans readTransformAscii (const QString &name, int from, int to)
static FiffCoordTrans readFShead2mriTransform (const QString &name)
static void apply_trans (float r[3], const FiffCoordTrans &t, bool do_move)
static void apply_inverse_trans (float r[3], const FiffCoordTrans &t, bool do_move)
static QString frame_name (int frame)
static FiffCoordTrans identity (int from, int to)
static FiffCoordTrans combine (int from, int to, const FiffCoordTrans &t1, const FiffCoordTrans &t2)
static FiffCoordTrans fromCardinalPoints (int from, int to, const float *rL, const float *rN, const float *rR)
static bool addInverse (FiffCoordTrans &t)
static qint32 storageSize ()
static FiffCoordTrans readFromTag (const std::unique_ptr< FiffTag > &tag)
static FiffCoordTrans readTransformFromNode (FiffStream::SPtr &stream, const FiffDirNode::SPtr &node, int from, int to)
static FiffCoordTrans procrustesAlign (int from_frame, int to_frame, const Eigen::MatrixXf &fromp, const Eigen::MatrixXf &top, const Eigen::VectorXf &w, float max_diff)

Public Attributes

fiff_int_t from
fiff_int_t to
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > trans
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > invtrans

Friends

bool operator== (const FiffCoordTrans &a, const FiffCoordTrans &b)

Detailed Description

Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.

Each transform carries its source (from) and destination (to) FIFFV_COORD_* frame identifiers so the inverse and any chained composition can be type-checked at runtime. The inverse is stored alongside the forward transform because both directions are routinely needed (device→head for head-position tracking, head→MRI for source space registration, etc.).

Definition at line 81 of file fiff_coord_trans.h.

Member Typedef Documentation

◆ ConstSPtr

using FIFFLIB::FiffCoordTrans::ConstSPtr = QSharedPointer<const FiffCoordTrans>

Const shared pointer type for FiffCoordTrans.

Definition at line 85 of file fiff_coord_trans.h.

◆ ConstUPtr

using FIFFLIB::FiffCoordTrans::ConstUPtr = std::unique_ptr<const FiffCoordTrans>

Const unique pointer type for FiffCoordTrans.

Definition at line 87 of file fiff_coord_trans.h.

◆ SPtr

Shared pointer type for FiffCoordTrans.

Definition at line 84 of file fiff_coord_trans.h.

◆ UPtr

Unique pointer type for FiffCoordTrans.

Definition at line 86 of file fiff_coord_trans.h.

Constructor & Destructor Documentation

◆ FiffCoordTrans() [1/5]

Constructs the coordinate transformation descriptor.

◆ FiffCoordTrans() [2/5]

FIFFLIB::FiffCoordTrans::FiffCoordTrans ( QIODevice & p_IODevice)

Constructs a coordinate transformation, by reading from a IO device.

Parameters
[in]p_IODeviceIO device to read from the coordinate transform.

◆ FiffCoordTrans() [3/5]

Copy constructor.

Parameters
[in]p_FiffCoordTransCoordinate transformation description which should be copied.

◆ FiffCoordTrans() [4/5]

FIFFLIB::FiffCoordTrans::FiffCoordTrans ( int from,
int to,
const Eigen::Matrix3f & rot,
const Eigen::Vector3f & move )

Constructs a coordinate transformation from a rotation matrix and translation vector.

Parameters
[in]fromSource coordinate system.
[in]toDestination coordinate system.
[in]rotThe forward transform (3×3 rotation matrix).
[in]moveThe forward transform (3×1 translation vector).

◆ FiffCoordTrans() [5/5]

FIFFLIB::FiffCoordTrans::FiffCoordTrans ( int from,
int to,
const Eigen::Matrix4f & matTrans,
bool bStandard = false )

Constructs a coordinate transformation from a 4×4 homogeneous matrix.

Parameters
[in]fromSource coordinate system.
[in]toDestination coordinate system.
[in]matTransThe 4×4 forward transform.
[in]bStandardWhen true, enforce standard transform (last row = [0,0,0,1]). Defaults to false.

◆ ~FiffCoordTrans()

Destroys the coordinate transformation descriptor.

Member Function Documentation

◆ addInverse()

Parameters
[in]tFiff coordinate transform to which the inverse should be added.
Returns
True when successful.

◆ angleTo()

float FIFFLIB::FiffCoordTrans::angleTo ( Eigen::MatrixX4f mTransDest)

Calculate rotation as angle between two rotation matrices

Parameters
[in]mTransDestThe destination transformation matrix.
Returns
The angle of rotation between two rotation matrices in degrees.

◆ apply_inverse_trans() [1/2]

Eigen::MatrixX3f FIFFLIB::FiffCoordTrans::apply_inverse_trans ( const Eigen::MatrixX3f & rr,
bool do_move = true ) const

Applies the inverse coordinate transform to given coordinates and returns the transformed coordinates

Parameters
[in]rrThe coordinates.
[in]do_movePerform translation next to rotation yes/no.
Returns
Transformed coordinates.

◆ apply_inverse_trans() [2/2]

void FIFFLIB::FiffCoordTrans::apply_inverse_trans ( float r[3],
const FiffCoordTrans & t,
bool do_move )
static

Applies the inverse coordinate transform to a single 3D point in place.

Parameters
[in,out]r3-element float array to transform in place.
[in]tThe coordinate transformation whose inverse to apply.
[in]do_moveIf true, apply translation; if false, rotation only.

◆ apply_trans() [1/2]

Eigen::MatrixX3f FIFFLIB::FiffCoordTrans::apply_trans ( const Eigen::MatrixX3f & rr,
bool do_move = true ) const

TODO: dest - The id of the destination coordinate system (FIFFV_COORD_...)

Applies the coordinate transform to given coordinates and returns the transformed coordinates

Parameters
[in]rrThe coordinates.
[in]do_movePerform translation next to rotation yes/no.
Returns
Transformed coordinates.

◆ apply_trans() [2/2]

void FIFFLIB::FiffCoordTrans::apply_trans ( float r[3],
const FiffCoordTrans & t,
bool do_move )
static

Applies the coordinate transform to a single 3D point in place.

Parameters
[in,out]r3-element float array to transform in place.
[in]tThe coordinate transformation to apply.
[in]do_moveIf true, apply translation; if false, rotation only.

◆ clear()

Initializes the coordinate transformation descriptor.

◆ combine()

FiffCoordTrans FIFFLIB::FiffCoordTrans::combine ( int from,
int to,
const FiffCoordTrans & t1,
const FiffCoordTrans & t2 )
static

Combines two coordinate transformations to yield a transform from from to to. Automatically handles inversion and ordering of the input transforms.

Parameters
[in]fromDesired source coordinate system.
[in]toDesired destination coordinate system.
[in]t1First transformation.
[in]t2Second transformation.
Returns
The combined transformation, or an empty transform on failure.

◆ frame_name()

QString FIFFLIB::FiffCoordTrans::frame_name ( int frame)
static

Map coordinate frame integers to human-readable names

Parameters
[in]frameThe coordinate frame integer.
Returns
Human readable form of the coordinate frame.

◆ fromCardinalPoints()

FiffCoordTrans FIFFLIB::FiffCoordTrans::fromCardinalPoints ( int from,
int to,
const float * rL,
const float * rN,
const float * rR )
static

Constructs a coordinate transformation from cardinal points (LPA, Nasion, RPA).

Parameters
[in]fromSource coordinate system.
[in]toDestination coordinate system (in which the points are expressed).
[in]rLLeft auricular point (3 floats).
[in]rNNasion point (3 floats).
[in]rRRight auricular point (3 floats).
Returns
The coordinate transformation.

◆ identity()

FiffCoordTrans FIFFLIB::FiffCoordTrans::identity ( int from,
int to )
static

Creates an identity transformation between two coordinate systems.

Parameters
[in]fromSource coordinate system.
[in]toDestination coordinate system.
Returns
An identity coordinate transformation.

◆ invert_transform()

Invert a coordinate transformation (actual obsolete - cause trans and inverse are both stored)

Returns
true if succeeded, false otherwise.

◆ inverted()

Returns a new inverted copy of this transformation (swaps from/to and trans/invtrans).

Returns
The inverted transformation.

◆ invmove() [1/2]

Inverse translation (column 3 of invtrans).

Definition at line 190 of file fiff_coord_trans.h.

◆ invmove() [2/2]

auto FIFFLIB::FiffCoordTrans::invmove ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 192 of file fiff_coord_trans.h.

◆ invrot() [1/2]

Inverse rotation (3×3 block of invtrans).

Definition at line 185 of file fiff_coord_trans.h.

◆ invrot() [2/2]

auto FIFFLIB::FiffCoordTrans::invrot ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 187 of file fiff_coord_trans.h.

◆ isEmpty()

bool FIFFLIB::FiffCoordTrans::isEmpty ( ) const
inline

Returns true if coordinate transform contains no data.

Returns
true if coordinate transform is empty.

Definition at line 160 of file fiff_coord_trans.h.

◆ move() [1/2]

Forward translation (column 3 of trans).

Definition at line 180 of file fiff_coord_trans.h.

◆ move() [2/2]

auto FIFFLIB::FiffCoordTrans::move ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 182 of file fiff_coord_trans.h.

◆ print()

Prints the coordinate transform.

◆ procrustesAlign()

FiffCoordTrans FIFFLIB::FiffCoordTrans::procrustesAlign ( int from_frame,
int to_frame,
const Eigen::MatrixXf & fromp,
const Eigen::MatrixXf & top,
const Eigen::VectorXf & w,
float max_diff )
static

Performs a Procrustes alignment between two sets of corresponding 3D points.

Parameters
[in]from_frameSource coordinate frame ID.
[in]to_frameDestination coordinate frame ID.
[in]frompPoint locations in the source frame (np×3 matrix).
[in]topPoint locations in the destination frame (np×3 matrix).
[in]wWeights (np elements), or empty vector for equal weight.
[in]max_diffMaximum allowed difference between transformed and target.
Returns
The alignment transform, or an empty transform on failure.

◆ read()

bool FIFFLIB::FiffCoordTrans::read ( QIODevice & p_IODevice,
FiffCoordTrans & p_Trans )
static

Reads a coordinate transform from a fif file

Parameters
[in]p_IODeviceA fiff IO device like a fiff QFile or QTCPSocket.
[out]p_TransA coordinate transform from a fif file.
Returns
true if succeeded, false otherwise.

◆ readFromTag()

FiffCoordTrans FIFFLIB::FiffCoordTrans::readFromTag ( const std::unique_ptr< FiffTag > & tag)
static

Reads a coordinate transform from a FIFF tag.

Parameters
[in]tagThe FIFF tag to read from.
Returns
The coordinate transform, or an empty transform if the tag is invalid.

◆ readFShead2mriTransform()

Reads the FreeSurfer head → MRI transform from an ASCII file.

Parameters
[in]nameASCII file path.
Returns
The head→MRI transform, or an empty transform on failure.

◆ readMeasTransform()

Reads the MEG device → head coordinate transform from a FIFF file.

Parameters
[in]nameFIFF file path.
Returns
The device→head transform, or an empty transform if not found.

◆ readMriTransform()

Reads the MRI → head coordinate transform from a FIFF file.

Parameters
[in]nameFIFF file path.
Returns
The MRI→head transform, or an empty transform if not found.

◆ readTransform()

FiffCoordTrans FIFFLIB::FiffCoordTrans::readTransform ( const QString & name,
int from,
int to )
static

Reads a specified coordinate transform from a FIFF file.

Parameters
[in]nameFIFF file path.
[in]fromExpected source coordinate system.
[in]toExpected destination coordinate system.
Returns
The coordinate transform, or an empty transform if not found.

◆ readTransformAscii()

FiffCoordTrans FIFFLIB::FiffCoordTrans::readTransformAscii ( const QString & name,
int from,
int to )
static

Reads a coordinate transform from an ASCII 4×3 matrix file (mm-to-m conversion applied).

Parameters
[in]nameASCII file path.
[in]fromSource coordinate system.
[in]toDestination coordinate system.
Returns
The coordinate transform, or an empty transform on failure.

◆ readTransformFromNode()

FiffCoordTrans FIFFLIB::FiffCoordTrans::readTransformFromNode ( FiffStream::SPtr & stream,
const FiffDirNode::SPtr & node,
int from,
int to )
static

Reads a coordinate transform from a FIFF stream node.

Parameters
[in]streamThe FIFF stream.
[in]nodeThe directory node to search.
[in]fromExpected source coordinate system.
[in]toExpected destination coordinate system.
Returns
The coordinate transform, or an empty transform if not found.

◆ rot() [1/2]

Forward rotation (3×3 block of trans).

Definition at line 175 of file fiff_coord_trans.h.

◆ rot() [2/2]

auto FIFFLIB::FiffCoordTrans::rot ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 177 of file fiff_coord_trans.h.

◆ storageSize()

qint32 FIFFLIB::FiffCoordTrans::storageSize ( )
inlinestatic

Size of the old struct (fiffCoordTransRec) 26*int = 26*4 = 104

Returns
the size of the old struct fiffCoordTransRec.

Definition at line 485 of file fiff_coord_trans.h.

◆ translationTo()

float FIFFLIB::FiffCoordTrans::translationTo ( Eigen::MatrixX4f mTransDest)

Calculate translation between two rotation matrices in meter

Parameters
[in]mTransDestThe destination transformation matrix.
Returns
The translation between two rotation matrices in m.

◆ write()

void FIFFLIB::FiffCoordTrans::write ( QIODevice & p_IODevice)

Writes the transformation to file.

Parameters
[in]p_IODeviceIO device to write the transformation to.

◆ writeToStream()

Writes the transformation to a FIFF stream.

Parameters
[in]p_pStreamPointer to the FIFF stream to write to.

◆ operator==

bool operator== ( const FiffCoordTrans & a,
const FiffCoordTrans & b )
friend

Overloaded == operator to compare an object to this instance.

Parameters
[in]objectThe object which should be compared to.
Returns
true if equal, false otherwise.

Definition at line 494 of file fiff_coord_trans.h.

Member Data Documentation

◆ from

Source coordinate system.

Definition at line 474 of file fiff_coord_trans.h.

◆ invtrans

Eigen::Matrix<float, 4,4, Eigen::DontAlign> FIFFLIB::FiffCoordTrans::invtrans

The inverse transform.

Definition at line 477 of file fiff_coord_trans.h.

◆ to

Destination coordinate system.

Definition at line 475 of file fiff_coord_trans.h.

◆ trans

Eigen::Matrix<float, 4,4, Eigen::DontAlign> FIFFLIB::FiffCoordTrans::trans

The forward transform.

Definition at line 476 of file fiff_coord_trans.h.


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