v2.0.0
Loading...
Searching...
No Matches
DISP3DLIB::SensorFieldMapper Class Reference

Sensor-to-surface field mapper that interpolates MEG/EEG measurements onto cortical meshes and generates iso-contour overlays. More...

#include <sensorfieldmapper.h>

Public Member Functions

 SensorFieldMapper ()=default
void setEvoked (const FIFFLIB::FiffEvoked &evoked)
bool isLoaded () const
void setTimePoint (int tp)
int timePoint () const
void setMegFieldMapOnHead (bool onHead)
bool megFieldMapOnHead () const
void setColormap (const QString &name)
const QString & colormap () const
const FIFFLIB::FiffEvoked & evoked () const
bool hasMappingFor (const FIFFLIB::FiffEvoked &newEvoked) const
const Eigen::VectorXi & megPick () const
const Eigen::VectorXi & eegPick () const
std::shared_ptr< Eigen::MatrixXf > megMapping () const
std::shared_ptr< Eigen::MatrixXf > eegMapping () const
bool buildMapping (const QMap< QString, std::shared_ptr< BrainSurface > > &surfaces, const FIFFLIB::FiffCoordTrans &headToMriTrans, bool applySensorTrans)
void apply (QMap< QString, std::shared_ptr< BrainSurface > > &surfaces, const SubView &singleView, const QVector< SubView > &subViews)
const QString & megSurfaceKey () const
const QString & eegSurfaceKey () const
void computeNormRange ()

Static Public Member Functions

static QString findHeadSurfaceKey (const QMap< QString, std::shared_ptr< BrainSurface > > &surfaces)
static QString findHelmetSurfaceKey (const QMap< QString, std::shared_ptr< BrainSurface > > &surfaces)
static float contourStep (float minVal, float maxVal, int targetTicks)
static Eigen::Vector3f fitSphereOrigin (const FIFFLIB::FiffInfo &info, float *radius=nullptr)

Detailed Description

Sensor-to-surface field mapper that interpolates MEG/EEG measurements onto cortical meshes and generates iso-contour overlays.

Encapsulates sensor-to-surface field mapping for MEG and EEG sensors.

This class owns the mapping state (evoked data, mapping matrices, channel picks, contour prefixes, surface key references) and provides methods to build mapping matrices and apply them to produce per-vertex field colours and iso-contour meshes.

The class operates on surface and contour surfaces stored in the caller's surface map. It reads from / writes to those surfaces but does not own them, keeping ownership in the BrainView.

Definition at line 69 of file sensorfieldmapper.h.

Constructor & Destructor Documentation

◆ SensorFieldMapper()

DISP3DLIB::SensorFieldMapper::SensorFieldMapper ( )
default

Construct an empty (unloaded) mapper.

Member Function Documentation

◆ apply()

void DISP3DLIB::SensorFieldMapper::apply ( QMap< QString, std::shared_ptr< BrainSurface > > & surfaces,
const SubView & singleView,
const QVector< SubView > & subViews )

Apply the precomputed mapping to the current time point.

Paints per-vertex colours onto the target surfaces and optionally generates iso-contour line meshes.

Parameters
[in,out]surfacesFsSurface map (contour surfaces may be added).
[in]singleViewThe single-view SubView for visibility flags.
[in]subViewsThe four multi-view SubViews.

Definition at line 526 of file sensorfieldmapper.cpp.

◆ buildMapping()

bool DISP3DLIB::SensorFieldMapper::buildMapping ( const QMap< QString, std::shared_ptr< BrainSurface > > & surfaces,
const FIFFLIB::FiffCoordTrans & headToMriTrans,
bool applySensorTrans )

Build the MEG/EEG sensor-to-surface mapping matrices.

Needs the caller's surface map to locate the helmet and/or head surface. Also needs the head-to-MRI transformation and whether sensor transforms should be applied.

Parameters
[in]surfacesAll surfaces keyed by name.
[in]headToMriTransHead → MRI coordinate transform.
[in]applySensorTransWhether to apply the sensor → MRI transform.
Returns
true on success (at least one mapping built).

Definition at line 182 of file sensorfieldmapper.cpp.

◆ colormap()

const QString & DISP3DLIB::SensorFieldMapper::colormap ( ) const
inline

Definition at line 144 of file sensorfieldmapper.h.

◆ computeNormRange()

void DISP3DLIB::SensorFieldMapper::computeNormRange ( )

Compute the normalization range anchored at the peak-GFP time.

For each modality the Global Field Power (GFP = sqrt(mean(V_i^2))) is evaluated across all time samples and we pick the time of maximum GFP. vmax = max(|mapped|) is then computed at that peak time, giving the colour-map range [-vmax, +vmax].

This matches MNE-Python's plot_field behaviour, where the initial view shows the evoked peak, so the colour scale is anchored to it. The range stays fixed during time scrubbing until explicitly recomputed (e.g. by switching to a new evoked data set).

Must be called after building or reusing a mapping matrix with new evoked data. buildMapping() calls this automatically.

Definition at line 461 of file sensorfieldmapper.cpp.

◆ contourStep()

float DISP3DLIB::SensorFieldMapper::contourStep ( float minVal,
float maxVal,
int targetTicks )
static

Compute a "nice" iso-contour step given a value range and target number of ticks.

Parameters
[in]minValLower bound of the value range.
[in]maxValUpper bound of the value range.
[in]targetTicksDesired number of contour intervals.
Returns
Step of 1, 2, 5 or 10 times a power of ten, or 0 for an empty range or non-positive targetTicks.

Definition at line 154 of file sensorfieldmapper.cpp.

◆ eegMapping()

std::shared_ptr< Eigen::MatrixXf > DISP3DLIB::SensorFieldMapper::eegMapping ( ) const
inline
Returns
Shared pointer to the EEG mapping matrix (may be null).

Definition at line 196 of file sensorfieldmapper.h.

◆ eegPick()

const Eigen::VectorXi & DISP3DLIB::SensorFieldMapper::eegPick ( ) const
inline
Returns
Const reference to the EEG channel pick indices.

Definition at line 180 of file sensorfieldmapper.h.

◆ eegSurfaceKey()

const QString & DISP3DLIB::SensorFieldMapper::eegSurfaceKey ( ) const
inline
Returns
The surface key used for the EEG mapping target.

Definition at line 245 of file sensorfieldmapper.h.

◆ evoked()

const FIFFLIB::FiffEvoked & DISP3DLIB::SensorFieldMapper::evoked ( ) const
inline
Returns
Const reference to the loaded evoked data.

Definition at line 153 of file sensorfieldmapper.h.

◆ findHeadSurfaceKey()

QString DISP3DLIB::SensorFieldMapper::findHeadSurfaceKey ( const QMap< QString, std::shared_ptr< BrainSurface > > & surfaces)
static

Find a BEM head surface key in the given surface map.

Looks for "bem_head" first, then any BEM surface whose tissue type is BrainSurface::TissueSkin.

Parameters
[in]surfacesSurface map keyed by surface name.
Returns
Head surface key, else the first BEM key, or an empty string if no BEM surface exists.

Definition at line 124 of file sensorfieldmapper.cpp.

◆ findHelmetSurfaceKey()

QString DISP3DLIB::SensorFieldMapper::findHelmetSurfaceKey ( const QMap< QString, std::shared_ptr< BrainSurface > > & surfaces)
static

Find the MEG helmet surface key ("sens_surface_meg") if present.

Parameters
[in]surfacesSurface map keyed by surface name.
Returns
"sens_surface_meg" if present, otherwise an empty string.

Definition at line 144 of file sensorfieldmapper.cpp.

◆ fitSphereOrigin()

Eigen::Vector3f DISP3DLIB::SensorFieldMapper::fitSphereOrigin ( const FIFFLIB::FiffInfo & info,
float * radius = nullptr )
static

Fit a sphere to the digitization headshape points.

Replicates MNE-Python's fit_sphere_to_headshape (linear least- squares sphere fit). Uses FIFFV_POINT_EXTRA digitization points by default; falls back to EXTRA + EEG if fewer than 4 extra points exist. Nose/face points (z < 0 && y > 0) are excluded.

Parameters
[in]infoFiffInfo containing the digitization points.
[out]radiusFitted sphere radius (metres). May be nullptr.
Returns
The sphere centre in head coordinates (metres). Returns (0, 0, 0.04) if the fit cannot be performed.

Definition at line 381 of file sensorfieldmapper.cpp.

◆ hasMappingFor()

bool DISP3DLIB::SensorFieldMapper::hasMappingFor ( const FIFFLIB::FiffEvoked & newEvoked) const

Check whether the current mapping matrices can be reused for a new evoked data set (i.e., same sensor configuration: same channels, same SSP projectors, same bad channels).

Parameters
[in]newEvokedThe candidate new evoked data.
Returns
true if the existing mapping is compatible, false if rebuild is needed.

Definition at line 91 of file sensorfieldmapper.cpp.

◆ isLoaded()

bool DISP3DLIB::SensorFieldMapper::isLoaded ( ) const
inline
Returns
true if evoked data has been loaded and is non-empty.

Definition at line 92 of file sensorfieldmapper.h.

◆ megFieldMapOnHead()

bool DISP3DLIB::SensorFieldMapper::megFieldMapOnHead ( ) const
inline

Definition at line 128 of file sensorfieldmapper.h.

◆ megMapping()

std::shared_ptr< Eigen::MatrixXf > DISP3DLIB::SensorFieldMapper::megMapping ( ) const
inline
Returns
Shared pointer to the MEG mapping matrix (may be null).

Definition at line 188 of file sensorfieldmapper.h.

◆ megPick()

const Eigen::VectorXi & DISP3DLIB::SensorFieldMapper::megPick ( ) const
inline
Returns
Const reference to the MEG channel pick indices.

Definition at line 172 of file sensorfieldmapper.h.

◆ megSurfaceKey()

const QString & DISP3DLIB::SensorFieldMapper::megSurfaceKey ( ) const
inline
Returns
The surface key used for the MEG mapping target.

Definition at line 237 of file sensorfieldmapper.h.

◆ setColormap()

void DISP3DLIB::SensorFieldMapper::setColormap ( const QString & name)
inline

Set the colormap name used when painting field values.

Parameters
[in]nameColormap identifier (e.g. "MNE", "hot", "RdBu_r").

Definition at line 139 of file sensorfieldmapper.h.

◆ setEvoked()

void DISP3DLIB::SensorFieldMapper::setEvoked ( const FIFFLIB::FiffEvoked & evoked)

Set the evoked data that supplies measurements and channel info.

After calling this, isLoaded() returns true when non-empty.

Parameters
[in]evokedThe evoked dataset (contains info + data matrix).

Definition at line 68 of file sensorfieldmapper.cpp.

◆ setMegFieldMapOnHead()

void DISP3DLIB::SensorFieldMapper::setMegFieldMapOnHead ( bool onHead)
inline

Whether the MEG field should be mapped onto the head (BEM) surface rather than the helmet surface.

Parameters
[in]onHeadtrue to map onto head, false for helmet.

Definition at line 123 of file sensorfieldmapper.h.

◆ setTimePoint()

void DISP3DLIB::SensorFieldMapper::setTimePoint ( int tp)
inline

Set the active time point index into the evoked data matrix.

Parameters
[in]tpZero-based time index.

Definition at line 103 of file sensorfieldmapper.h.

◆ timePoint()

int DISP3DLIB::SensorFieldMapper::timePoint ( ) const
inline
Returns
Current time point index.

Definition at line 111 of file sensorfieldmapper.h.


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