Skip to main content

FiffDigPointSet

Namespace: FIFFLIB  ·  Library: FIFF Library

#include <fiff/fiff_dig_point_set.h>

class FIFFLIB::FiffDigPointSet

Collection of FiffDigPoint records as parsed from a FIFFB_ISOTRAK block.

Indexed access plus convenience filters (cardinals only, HPI only, EEG only, extras only) so registration code can pick out the subset it needs without re-walking the underlying QList of dig points.

src/examples/ex_fiff_api/main.cpp
FiffDigPointSet digitizer(info.dig); // 146 points in head coordinates
FiffDigPointSet cardinal = digitizer.pickTypes({FIFFV_POINT_CARDINAL}); // LPA, nasion, RPA

Public Methods​

FiffDigPointSet()​

Constructs a FiffDigPointSet object.


FiffDigPointSet(p_FiffDigPointSet)​

Copy constructor.

Parameters:

  • p_FiffDigPointSet : const FiffDigPointSet & FiffDigPointSet which should be copied.

operator=(other)​

Copy assignment.

Every member has value semantics, so the compiler-generated member-wise assignment is correct. It is declared explicitly because declaring a copy constructor and/or a destructor deprecates the implicitly generated one.

Parameters:

Returns:


FiffDigPointSet(pointList)​

Construct FiffDigPointSet based on input pointList.

Parameters:

  • pointList : QList< FiffDigPoint > list of digitizer points

FiffDigPointSet(p_IODevice)​

Constructs a FiffDigPointSet by reading from a IO device.

Parameters:

  • p_IODevice : QIODevice & IO device to read the digitizer point set from.

~FiffDigPointSet()​

Destroys the FiffDigPointSet.


clear()​

Initializes FiffDigPointSet.


isEmpty()​

True if FiffDigPointSet is empty.

Returns:


size()​

Returns the number of stored FiffDigPoints.

Returns:

  • qint32 — number of stored FiffDigPoints.

write(p_IODevice)​

Writes the FiffDigPointSet to a FIFF file.

Parameters:

  • p_IODevice : QIODevice & IO device to write the digitizer point set to.

Returns:

  • bool — false if the device cannot be opened for writing.

write(filePath, errorMessage)​

Convenience overload: write the digitizer point set to a path on disk.

Verifies that the destination directory exists and that the file was actually produced. The file is opened in WriteOnly|Truncate mode.

Parameters:

  • filePath : const QString & Destination .fif file path.

  • errorMessage : *QString ** Optional, populated on failure.

Returns:

  • bool — true on success, false on error.

writeToStream(p_pStream)​

Writes the FiffDigPointSet to a FIFF stream.

Parameters:

  • p_pStream : *FiffStream ** Pointer to the FIFF stream to write to.

operator[](idx)​

Subscript operator [] to access FiffDigPoint by index.

Parameters:

Returns:


operator[](idx)​

Subscript operator [] to access FiffDigPoint by index.

Parameters:

Returns:


pickTypes(includeTypes)​

Pick the wanted types from this set and returns them.

Parameters:

  • includeTypes : QList< int > The include types (FIFFV_POINT_HPI, FIFFV_POINT_CARDINAL, FIFFV_POINT_EEG, FIFFV_POINT_ECG, FIFFV_POINT_EXTRA, FIFFV_POINT_LPA, FIFFV_POINT_NASION, FIFFV_POINT_RPA).

Returns:


operator<<(dig)​

Subscript operator << to add a new FiffDigPoint.

Parameters:

Returns:


operator<<(dig)​

Subscript operator << to add a new FiffDigPoint.

Parameters:

Returns:


applyTransform(coordTrans, bApplyInverse)​

Apply a transformation matrix on the 3D position of the digitized points.

Parameters:

  • coordTrans : const FiffCoordTrans & FiffCoordTrans which is to be applied.

  • bApplyInverse : bool Whether to apply the inverse. False by default.


transformToHead()​

Move every point that shares the frame of the LPA, nasion and RPA points into the Neuromag head frame defined by these fiducials (mne.channels.transform_to_head).

Returns:

  • bool — false if a fiducial is missing or the fiducials are in different frames.

getList()​

Returns list of digitizer point the set contains.

Returns:


Static Methods​

readFromStream(p_Stream, p_Dig)​

Reads FiffDigPointSet from a fif file.

Parameters:

Returns:

  • bool — true if succeeded, false otherwise.

readPolhemusIsotrak(path, dig, chNames, unit)​

Reads a Polhemus Isotrak digitizer file, as mne.channels.read_dig_polhemus_isotrak does.

The three fiducials become cardinal points (LPA, nasion, RPA). The remaining points become HPI coils for an .elp file and head shape points for .hsp/.eeg files, or EEG electrodes when chNames names them. Electrodes are numbered by the last three characters of their names when all of those are numbers, and 1..n otherwise. All points are in digitizer coordinates (FIFFV_COORD_UNKNOWN).

Parameters:

  • path : const QString & The .elp, .hsp or .eeg file.

  • dig : FiffDigPointSet & The digitizer points.

  • chNames : const QStringList & Electrode names, one per non-fiducial point, or empty.

  • unit : const QString & Unit of the file: "m", "cm" or "mm".

Returns:

  • bool — false if the file cannot be read, the extension or unit is unknown, or the number of names does not match the number of points.

readPolhemusFastscan(path, points, unit, requireHeader)​

Reads the points of a Polhemus FastSCAN .txt file in metres, as mne.channels.read_polhemus_fastscan does.

Parameters:

  • path : const QString & The .txt file.

  • points : Eigen::MatrixX3d & The points, one per row, in digitizer coordinates.

  • unit : const QString & Unit of the file: "m", "cm" or "mm".

  • requireHeader : bool Reject files whose "%" header does not name FastSCAN.

Returns:

  • bool — false if the file cannot be read, the extension, unit or header is wrong, or a row does not hold three numbers.

readCaptrak(path, dig, chNames)​

Reads a BrainVision CapTrak .bvct file, as mne.channels.read_dig_captrak does.

The electrodes named Nasion, LPA and RPA become the cardinal points, every other electrode an EEG point; millimetres are converted to metres. The points are in digitizer coordinates (FIFFV_COORD_UNKNOWN), numbered as by readPolhemusIsotrak; a repeated name keeps its first place and its last position.

Parameters:

  • path : const QString & The .bvct file.

  • dig : FiffDigPointSet & The digitizer points.

  • chNames : *QStringList ** If not null, the electrode names in the order of the EEG points.

Returns:

  • bool — false if the file cannot be parsed or lacks one of the fiducials.

readEgi(path, dig, chNames)​

Reads the coordinates.xml of an EGI MFF recording, as mne.channels.read_dig_egi does.

Sensors of type 0 become EEG points named "EEG <number>", the reference (type 1) is numbered after the electrodes before it, and the nasion and periauricular points (type 2) become the cardinal points. Unlike mne.channels.read_dig_egi, which keeps the file's centimetres as if they were metres, the positions are converted to metres (as mne.io.read_raw_egi does).

Parameters:

  • path : const QString & The coordinates.xml file.

  • dig : FiffDigPointSet & The digitizer points, in digitizer coordinates.

  • chNames : *QStringList ** If not null, the electrode names in the order of the EEG points.

Returns:

  • bool — false if the file cannot be parsed or lacks one of the fiducials.

readLocalite(path, dig, chNames, nasion, lpa, rpa)​

Reads a Localite .csv file ("#,name,x,y,z" in millimetres after a header row), as mne.channels.read_dig_localite does.

Parameters:

  • path : const QString & The .csv file.

  • dig : FiffDigPointSet & The digitizer points, in digitizer coordinates.

  • chNames : *QStringList ** If not null, the electrode names in the order of the EEG points.

  • nasion : const QString & Name of the point that is the nasion, or empty.

  • lpa : const QString & Name of the point that is the left preauricular point, or empty.

  • rpa : const QString & Name of the point that is the right preauricular point, or empty.

Returns:

  • bool — false if the file cannot be read, a row is malformed or a named fiducial is missing.

readNeuroscanDat(path, dig, chNames)​

Reads a Neuroscan .dat electrode file ("name number x y z" per line), as mne.channels.read_dig_dat does: point numbers 78, 76 and 82 are the nasion, LPA and RPA, 67 (the centroid) is skipped, and the coordinates are kept as they are.

Parameters:

  • path : const QString & The .dat file.

  • dig : FiffDigPointSet & The digitizer points, in digitizer coordinates.

  • chNames : *QStringList ** If not null, the electrode names in the order of the EEG points.

Returns:

  • bool — false if the file cannot be read or a line does not hold five entries.

Example​

Used in examples​

ex_fiff_api​

FIFF library: measurement info, channels, digitizer, transforms, projectors, covariance, events,.

src/examples/ex_fiff_api/main.cpp, line 123
FiffDigPointSet digitizer(info.dig); // 146 points in head coordinates
FiffDigPointSet cardinal = digitizer.pickTypes({FIFFV_POINT_CARDINAL}); // LPA, nasion, RPA
// mne: 146 points; dig[0] = LPA at (-0.0713766, 0, 5.1e-9)
ok &= expect(digitizer.size() == 146 && cardinal.size() == 3 && cardinal[0].ident == FIFFV_POINT_LPA && std::fabs(cardinal[0].r[0] + 0.07137661f) < 1e-7f,
"FiffDigPointSet/FiffDigPoint: 146 points, LPA at x = -71.38 mm");

ex_disp_3D​

Example of using the MNE-CPP Disp3D library.

src/examples/ex_disp_3D/main.cpp, line 264
// Read and show digitizer points
QFile t_fileDig(QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-ave.fif");
FiffDigPointSet t_Dig(t_fileDig);

ex_hpiFit​

Example for cHPI fitting on raw data with SSP. The result is written to a .txt file for comparison with MaxFilter's .pos file.

src/examples/ex_hpiFit/main.cpp, line 155
QVector<double> vecError(lFreqs.size());
VectorXd vecGoF;
FiffDigPointSet fittedPointSet;

Authors of this file​