GeometryInfo
Namespace: DISP3DLIB · Library: 3D Display Library
#include <disp3D/geometryinfo.h>
class DISP3DLIB::GeometryInfo
This class allows sensor-to-mesh mapping and calculation of surface constrained distances.
This class holds static methods for sensor-to-mesh mapping and surface constrained distance calculation on a mesh
MatrixX3f sensors(2, 3);
sensors << -0.2f, 0.1f, 0.5f, // above vertex 0
3.1f, 2.9f, 0.4f; // above vertex 15
VectorXi projected = GeometryInfo::projectSensors(vertices, sensors); // nearest vertex per sensor
QSharedPointer<MatrixXd> distances = GeometryInfo::scdc(vertices, neighbors, projected); // geodesic: n_vertices x n_sensors
Public Methods
GeometryInfo()
Static Methods
scdc(matVertices, vecNeighborVertices, vecVertSubset, dCancelDist)
scdc Calculates surface constrained distances on a mesh.
Parameters:
-
matVertices : const Eigen::MatrixX3f & Vertex positions (nVertices x 3).
-
vecNeighborVertices : const std::vector< Eigen::VectorXi > & Adjacency list for each vertex.
-
vecVertSubset : Eigen::VectorXi & Source vertex indices; if empty it is filled with all vertex indices.
-
dCancelDist : double Maximum geodesic distance to explore, in vertex coordinate units.
Returns:
- QSharedPointer<Eigen::MatrixXd> — Distance table (nVertices x nSubset); entries beyond dCancelDist stay infinite.
scdcInterpolationMat(matVertices, vecNeighborVertices, vecVertSubset, interpolationFunction, dCancelDist, progressCallback, cancelledFlag)
scdcInterpolationMat Computes geodesic distances (SCDC) and builds the sparse interpolation matrix in a single pass, without allocating a dense nVertices x nSources distance table.
Produces identical results to scdc() + Interpolation::createInterpolationMat() but uses dramatically less memory (sparse representation only stores entries within cancelDist).
Parameters:
-
matVertices : const Eigen::MatrixX3f & Vertex positions (nVertices x 3).
-
vecNeighborVertices : const std::vector< Eigen::VectorXi > & Adjacency list for each vertex.
-
vecVertSubset : const Eigen::VectorXi & Source vertex indices.
-
interpolationFunction : double()(double)* Weight function (e.g.
Interpolation::cubic). -
dCancelDist : double Maximum geodesic distance for interpolation.
-
progressCallback : std::function< void(int, int)> Optional callback reporting Dijkstra progress (current, total).
-
cancelledFlag : *const std::atomic< bool > ** Optional pointer to an atomic bool; when set to true the computation aborts early.
Returns:
- QSharedPointer< Eigen::SparseMatrix< float > > — Sparse interpolation matrix (nVertices x nSources), or empty matrix if cancelled.
projectSensors(matVertices, matSensorPositions)
projectSensors Calculates the nearest neighbor vertex to each sensor.
Parameters:
-
matVertices : const Eigen::MatrixX3f & Vertex positions (nVertices x 3).
-
matSensorPositions : const Eigen::MatrixX3f & Sensor positions (nSensors x 3) in the same coordinate frame.
Returns:
- Eigen::VectorXi — Index of the nearest mesh vertex for each sensor.
filterBadChannels(matDistanceTable, fiffInfo, iSensorType)
filterBadChannels Filters bad channels from distance table.
Parameters:
-
matDistanceTable : QSharedPointer<Eigen::MatrixXd> Distance table whose bad-channel columns are set to infinity.
-
fiffInfo : const FiffInfo & Measurement info providing channel list and bad channel names.
-
iSensorType : qint32 FIFF channel kind selecting the sensors that form the table columns.
Returns:
- Eigen::VectorXi — Column indices of the bad channels that were found.
Example
- Full source:
src/examples/ex_disp3d_scene/main.cpp - Build target:
ex_disp3d_scene(runs under CTest)
Used in examples
ex_disp3d_scene
Disp3D scene data: sensor-to-surface interpolation, electrodes, MRI slices, video overlay and layers.
MatrixX3f sensors(2, 3);
sensors << -0.2f, 0.1f, 0.5f, // above vertex 0
3.1f, 2.9f, 0.4f; // above vertex 15
VectorXi projected = GeometryInfo::projectSensors(vertices, sensors); // nearest vertex per sensor
QSharedPointer<MatrixXd> distances = GeometryInfo::scdc(vertices, neighbors, projected); // geodesic: n_vertices x n_sensors
// scipy.sparse.csgraph.dijkstra on the same graph: Manhattan distances to vertices 0 and 15
ok &= expect(projected == Vector2i(0, 15) && distances->rows() == 16 && (*distances)(5, 0) == 2.0 && (*distances)(5, 1) == 4.0 && (*distances)(3, 0) == 3.0 && (*distances)(3, 1) == 3.0,
"GeometryInfo projects the sensors onto vertices 0 and 15; geodesic distances match scipy");
ex_interpolation
Example of using the interpolation library and geometryInfo library.
//projecting with MEG
qint64 startTimeProjecting = QDateTime::currentMSecsSinceEpoch();
VectorXi mappedSubSet = GeometryInfo::projectSensors(t_sensorSurfaceVV[0].rr, megSensors);
std::cout << "Projecting duration: " << QDateTime::currentMSecsSinceEpoch() - startTimeProjecting << " ms " << std::endl;
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>