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

Coordinate transformation description. More...

#include <fiff_coord_trans.h>

Public Types

typedef QSharedPointer< FiffCoordTransSPtr
typedef QSharedPointer< const FiffCoordTransConstSPtr
typedef std::unique_ptr< FiffCoordTransUPtr
typedef std::unique_ptr< const FiffCoordTransConstUPtr

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 QSharedPointer< 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, float **fromp, float **top, float *w, int np, 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

Coordinate transformation description.

Coordinate transformation description.

Definition at line 80 of file fiff_coord_trans.h.

Member Typedef Documentation

◆ ConstSPtr

typedef QSharedPointer<const FiffCoordTrans> FIFFLIB::FiffCoordTrans::ConstSPtr

Const shared pointer type for FiffCoordTrans.

Definition at line 84 of file fiff_coord_trans.h.

◆ ConstUPtr

typedef std::unique_ptr<const FiffCoordTrans> FIFFLIB::FiffCoordTrans::ConstUPtr

Const unique pointer type for FiffCoordTrans.

Definition at line 86 of file fiff_coord_trans.h.

◆ SPtr

Shared pointer type for FiffCoordTrans.

Definition at line 83 of file fiff_coord_trans.h.

◆ UPtr

Unique pointer type for FiffCoordTrans.

Definition at line 85 of file fiff_coord_trans.h.

Constructor & Destructor Documentation

◆ FiffCoordTrans() [1/5]

FiffCoordTrans::FiffCoordTrans ( )

Constructs the coordinate transformation descriptor.

Definition at line 72 of file fiff_coord_trans.cpp.

◆ FiffCoordTrans() [2/5]

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.

Definition at line 82 of file fiff_coord_trans.cpp.

◆ FiffCoordTrans() [3/5]

FiffCoordTrans::FiffCoordTrans ( const FiffCoordTrans & p_FiffCoordTrans)

Copy constructor.

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

Definition at line 97 of file fiff_coord_trans.cpp.

◆ 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()

FiffCoordTrans::~FiffCoordTrans ( )

Destroys the coordinate transformation descriptor.

Definition at line 107 of file fiff_coord_trans.cpp.

Member Function Documentation

◆ addInverse()

bool FiffCoordTrans::addInverse ( FiffCoordTrans & t)
static
Parameters
[in]tFiff coordinate transform to which the inverse should be added.
Returns
True when successful.

Definition at line 271 of file fiff_coord_trans.cpp.

◆ angleTo()

float 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.

Definition at line 291 of file fiff_coord_trans.cpp.

◆ 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 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.

Definition at line 339 of file fiff_coord_trans.cpp.

◆ 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 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.

Definition at line 325 of file fiff_coord_trans.cpp.

◆ clear()

void FiffCoordTrans::clear ( )

Initializes the coordinate transformation descriptor.

Definition at line 113 of file fiff_coord_trans.cpp.

◆ combine()

FiffCoordTrans 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.

Definition at line 376 of file fiff_coord_trans.cpp.

◆ frame_name()

QString 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.

Definition at line 215 of file fiff_coord_trans.cpp.

◆ fromCardinalPoints()

FiffCoordTrans 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.

Definition at line 413 of file fiff_coord_trans.cpp.

◆ identity()

FiffCoordTrans 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.

Definition at line 353 of file fiff_coord_trans.cpp.

◆ invert_transform()

bool FiffCoordTrans::invert_transform ( )

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

Returns
true if succeeded, false otherwise.

Definition at line 123 of file fiff_coord_trans.cpp.

◆ inverted()

FiffCoordTrans FiffCoordTrans::inverted ( ) const

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

Returns
The inverted transformation.

Definition at line 364 of file fiff_coord_trans.cpp.

◆ invmove() [1/2]

auto FIFFLIB::FiffCoordTrans::invmove ( )
inline

Inverse translation (column 3 of invtrans).

Definition at line 189 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 191 of file fiff_coord_trans.h.

◆ invrot() [1/2]

auto FIFFLIB::FiffCoordTrans::invrot ( )
inline

Inverse rotation (3×3 block of invtrans).

Definition at line 184 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 186 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 159 of file fiff_coord_trans.h.

◆ move() [1/2]

auto FIFFLIB::FiffCoordTrans::move ( )
inline

Forward translation (column 3 of trans).

Definition at line 179 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 181 of file fiff_coord_trans.h.

◆ print()

void FiffCoordTrans::print ( ) const

Prints the coordinate transform.

Definition at line 279 of file fiff_coord_trans.cpp.

◆ procrustesAlign()

FiffCoordTrans FiffCoordTrans::procrustesAlign ( int from_frame,
int to_frame,
float ** fromp,
float ** top,
float * w,
int np,
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 C matrix).
[in]topPoint locations in the destination frame (np×3 C matrix).
[in]wOptional weights (np elements), or nullptr for equal weight.
[in]npNumber of points.
[in]max_diffMaximum allowed difference between transformed and target.
Returns
The alignment transform, or an empty transform on failure.

Definition at line 621 of file fiff_coord_trans.cpp.

◆ read()

bool 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.

Definition at line 136 of file fiff_coord_trans.cpp.

◆ readFromTag()

FiffCoordTrans FiffCoordTrans::readFromTag ( const QSharedPointer< 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.

Definition at line 554 of file fiff_coord_trans.cpp.

◆ readFShead2mriTransform()

FiffCoordTrans FiffCoordTrans::readFShead2mriTransform ( const QString & name)
static

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.

Definition at line 547 of file fiff_coord_trans.cpp.

◆ readMeasTransform()

FiffCoordTrans FiffCoordTrans::readMeasTransform ( const QString & name)
static

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.

Definition at line 485 of file fiff_coord_trans.cpp.

◆ readMriTransform()

FiffCoordTrans FiffCoordTrans::readMriTransform ( const QString & name)
static

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.

Definition at line 478 of file fiff_coord_trans.cpp.

◆ readTransform()

FiffCoordTrans 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.

Definition at line 444 of file fiff_coord_trans.cpp.

◆ readTransformAscii()

FiffCoordTrans 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.

Definition at line 492 of file fiff_coord_trans.cpp.

◆ readTransformFromNode()

FiffCoordTrans 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.

Definition at line 591 of file fiff_coord_trans.cpp.

◆ rot() [1/2]

auto FIFFLIB::FiffCoordTrans::rot ( )
inline

Forward rotation (3×3 block of trans).

Definition at line 174 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 176 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 484 of file fiff_coord_trans.h.

◆ translationTo()

float 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.

Definition at line 314 of file fiff_coord_trans.cpp.

◆ write()

void FiffCoordTrans::write ( QIODevice & p_IODevice)

Writes the transformation to file.

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

Definition at line 168 of file fiff_coord_trans.cpp.

◆ writeToStream()

void FiffCoordTrans::writeToStream ( FiffStream * p_pStream)

Writes the transformation to a FIFF stream.

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

Definition at line 180 of file fiff_coord_trans.cpp.

◆ 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 493 of file fiff_coord_trans.h.

Member Data Documentation

◆ from

fiff_int_t FIFFLIB::FiffCoordTrans::from

Source coordinate system.

Definition at line 473 of file fiff_coord_trans.h.

◆ invtrans

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

The inverse transform.

Definition at line 476 of file fiff_coord_trans.h.

◆ to

fiff_int_t FIFFLIB::FiffCoordTrans::to

Destination coordinate system.

Definition at line 474 of file fiff_coord_trans.h.

◆ trans

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

The forward transform.

Definition at line 475 of file fiff_coord_trans.h.


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