MNEProjectToSurface
Namespace: MNELIB · Library: MNE Library
#include <mne/mne_project_to_surface.h>
class MNELIB::MNEProjectToSurface
Description of what this class is intended to do (in detail).
Projects 3-D points onto a triangulated surface mesh and returns nearest vertices and distances
MNEProjectToSurface projector(innerSkull);
MatrixXf points(2, 3);
points << 0.0f, 0.0f, 0.12f, 0.05f, 0.01f, 0.03f; // one point outside, one inside the skull
MatrixXf onSurface;
VectorXi triangle;
VectorXf distance;
projector.find_closest_on_surface(points, points.rows(), onSurface, triangle, distance);
Public Methods
MNEProjectToSurface()
Constructs a MNEProjectToSurface object.
MNEProjectToSurface(p_MNEBemSurf)
Constructs a MNEProjectToSurface with the data of a MNEBemSurface object.
Build a projector that snaps points onto the triangulation of p_MNEBemSurf.
Parameters:
- p_MNEBemSurf : const MNEBemSurface &
The
MNEBemSurfaceto which is to be projected.
find_closest_on_surface(r, np, rTri, nearest, dist)
Projects a set of points r on the FsSurface.
Project a set of points onto the surface and return the nearest triangle and signed distance per point.
Parameters:
-
r : const Eigen::MatrixXf & Set of pionts, which are to be projectied.
-
np : const int number of points.
-
rTri : Eigen::MatrixXf & set of points on the surface.
-
nearest : Eigen::VectorXi & Triangle of the new point.
-
dist : Eigen::VectorXf & Distance between r and rTri.
Returns:
- bool — true if succeeded, false otherwise.
Example
- Full source:
src/examples/ex_mne_api/main.cpp - Build target:
ex_mne_api(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_mne_api
MNE library: BEM surfaces, surface projection, ICP, source spaces and epochs.
MNEProjectToSurface projector(innerSkull);
MatrixXf points(2, 3);
points << 0.0f, 0.0f, 0.12f, 0.05f, 0.01f, 0.03f; // one point outside, one inside the skull
MatrixXf onSurface;
VectorXi triangle;
VectorXf distance;
projector.find_closest_on_surface(points, points.rows(), onSurface, triangle, distance);
// Exact point-to-triangle distance over all 5120 triangles (numpy on mne.read_bem_surfaces):
// triangle 1037 at 14.6163 mm, and 11.5561 mm on the edge shared by triangles 3143 and 3172.
// For the first point mne's _project_onto_surface returns a point on the plane of triangle 1038
// but outside the triangle (barycentric weights 1.2 and -0.39), so it is not on the surface.
ok &= expect(triangle(0) == 1037 && (triangle(1) == 3143 || triangle(1) == 3172) && (onSurface.row(0) - RowVector3f(-5.97378269e-05f, 1.14249234e-03f, 0.105428493f)).norm() < 1e-6f && (onSurface.row(1) - RowVector3f(0.060674f, 0.01416721f, 0.02850214f)).norm() < 1e-6f && near(distance(0), 0.014616349831736736, 1e-5) && near(distance(1), 0.011556106943744577, 1e-5),
"MNEProjectToSurface: closest triangles, points and distances match an exhaustive search");
Authors of this file
- Jana Kiesel <jana.kiesel@tu-ilmenau.de>
- Christoph Dinh <christoph.dinh@mne-cpp.org>
- Lorenz Esch <lorenz.esch@tu-ilmenau.de>
- Juan GPC <jgarciaprieto@mgh.harvard.edu>
- Gabriel Motta <gabrielbenmotta@gmail.com>