Skip to main content

MNESurfaceOrVolume

Namespace: MNELIB  ·  Library: MNE Library

#include <mne/mne_surface_or_volume.h>

class MNELIB::MNESurfaceOrVolume

Defines a source space or a surface.

Holds vertex positions, normals, triangulation, patch statistics, neighborhood connectivity, and optional volume-grid metadata for MEG/EEG source-space analysis.

Inheritance​


Public Methods​

MNESurfaceOrVolume()​

Constructs the MNE FsSurface or Volume.


~MNESurfaceOrVolume()​

Destroys the MNE FsSurface or Volume description.


MNESurfaceOrVolume()​


operator=()​


MNESurfaceOrVolume()​


operator=()​


add_uniform_curv()​

Set all vertex curvature values to 1.0 (uniform curvature), if not already present.


add_triangle_data()​

Populate the MNETriangle structures for both the full and in-use triangulations by computing edge vectors, normals, and areas.

Accumulates the total surface area into tot_area.


compute_surface_cm()​

Compute and store the center of mass of a surface's vertices.


calculate_vertex_distances()​

Compute the Euclidean distances from each vertex to its topological neighbors and store them in the vert_dist array.


add_vertex_normals()​

Compute vertex normals by area-weighted accumulation of triangle normals, then normalize to unit length.

Also calls add_triangle_data() and compute_surface_cm().

Returns:

  • int — OK on success, FAIL on error.

add_geometry_info(do_normals, check_too_many_neighbors)​

Build complete geometry information for a source space: triangle data, vertex normals, neighbor-triangle lists, neighbor-vertex lists, vertex distances, and center of mass.

Optionally checks for topological defects (excessive number of neighbors).

Parameters:

  • do_normals : bool If non-zero, compute vertex normals.

  • check_too_many_neighbors : bool If non-zero, fail on excessive neighbor count.

Returns:

  • int — OK on success, FAIL on error.

add_geometry_info(do_normals)​

Convenience overload that adds geometry information with border detection disabled and excess-neighbor checking enabled.

Parameters:

  • do_normals : bool If non-zero, compute vertex normals.

Returns:

  • int — OK on success, FAIL on error.

add_geometry_info2(do_normals)​

Add geometry information with excess-neighbor checking disabled (warns instead of failing when a vertex has too many neighbors).

Parameters:

  • do_normals : bool If non-zero, compute vertex normals.

Returns:

  • int — OK on success, FAIL on error.

nearestVertIdx()​

Extract the nearest in-use vertex indices from the nearest vector.

Equivalent to the old MNEHemisphere::nearest (VectorXi).

Returns:

  • Eigen::VectorXi — VectorXi where element i = nearest[i].nearest.

nearestDistVec()​

Extract the nearest distances from the nearest vector as doubles.

Equivalent to the old MNEHemisphere::nearest_dist (VectorXd).

Returns:

  • Eigen::VectorXd — VectorXd where element i = (double)nearest[i].dist.

setNearestData(nearestIdx, nearestDist)​

Populate the nearest vector from separate index and distance arrays.

Sets vert = i, patch = nullptr for each entry.

Parameters:

  • nearestIdx : const Eigen::VectorXi & Nearest in-use vertex index for each vertex.

  • nearestDist : const Eigen::VectorXd & Distance to nearest in-use vertex for each vertex.


point(k)​

Return a read-only map to the k-th vertex position (3 contiguous floats).

Parameters:

  • k : int Vertex index (0 to np - 1).

Returns:

  • Eigen::Map< const Eigen::Vector3f > — Read-only view of row k of rr, in m.

point(k)​

Return a mutable map to the k-th vertex position.

Parameters:

  • k : int Vertex index (0 to np - 1).

Returns:

  • Eigen::Map< Eigen::Vector3f > — Writable view of row k of rr, in m.

normal(k)​

Return a read-only map to the k-th vertex normal (3 contiguous floats).

Parameters:

  • k : int Vertex index (0 to np - 1).

Returns:

  • Eigen::Map< const Eigen::Vector3f > — Read-only view of row k of nn (unit normal).

Static Methods​

solid_angle(from, tri)​

Compute the solid angle subtended by a triangle as seen from a given point using van Oosterom's formula (scalar triple product of the edge vectors).

Parameters:

  • from : const Eigen::Vector3f & The observation point (3-element float array).

  • tri : const MNETriangle & The triangle whose solid angle is computed.

Returns:

  • double — The solid angle in steradians.

compute_cm(rr, np, cm)​

Compute the center of mass (mean position) of a set of points.

Parameters:

  • rr : const PointsT & Array of 3D point coordinates.

  • np : int Number of points.

  • cm : float(&) Receives the center of mass (3-element float array).


Example​

No example of its own: Common base of MNESurface, MNESourceSpace and MNEBemSurface; used through those.

It is exercised by:

src/examples/ex_mne_api/main.cpp
QFile bemFile(data + "/subjects/sample/bem/sample-5120-bem.fif");
MNEBem bem(bemFile); // one MNEBemSurface per BEM layer
const MNEBemSurface& innerSkull = bem[0];

From ex_mne_api.

src/examples/ex_mne_api/main.cpp
QFile srcFile(data + "/subjects/sample/bem/sample-oct-6-src.fif");
FiffStream::SPtr stream(new FiffStream(&srcFile));
MNESourceSpaces src;
stream->open();
MNESourceSpaces::readFromStream(stream, true, src); // add_geom: normals, triangle data and patches
stream->close();
const auto& lh = dynamic_cast<const MNEHemisphere&>(src[0]);
QList<VectorXi> vertno = src.get_vertno(); // used vertices per hemisphere

From ex_mne_api.

Authors of this file​