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

#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::FiffEvokedevoked () const
bool hasMappingFor (const FIFFLIB::FiffEvoked &newEvoked) const
const QVector< int > & megPick () const
const QVector< int > & eegPick () const
QSharedPointer< Eigen::MatrixXf > megMapping () const
QSharedPointer< 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

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 71 of file sensorfieldmapper.h.

Constructor & Destructor Documentation

◆ SensorFieldMapper()

SensorFieldMapper::SensorFieldMapper ( )
default

Construct an empty (unloaded) mapper.

Member Function Documentation

◆ apply()

void 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]surfacesSurface map (contour surfaces may be added).
[in]singleViewThe single-view SubView for visibility flags.
[in]subViewsThe four multi-view SubViews.

Definition at line 536 of file sensorfieldmapper.cpp.

◆ buildMapping()

bool 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 210 of file sensorfieldmapper.cpp.

◆ colormap()

const QString & SensorFieldMapper::colormap ( ) const
inline

Definition at line 128 of file sensorfieldmapper.h.

◆ computeNormRange()

void 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 477 of file sensorfieldmapper.cpp.

◆ contourStep()

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

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

Definition at line 188 of file sensorfieldmapper.cpp.

◆ eegMapping()

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

Definition at line 165 of file sensorfieldmapper.h.

◆ eegPick()

const QVector< int > & SensorFieldMapper::eegPick ( ) const
inline
Returns
Const reference to the EEG channel pick indices.

Definition at line 155 of file sensorfieldmapper.h.

◆ eegSurfaceKey()

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

Definition at line 208 of file sensorfieldmapper.h.

◆ evoked()

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

Definition at line 134 of file sensorfieldmapper.h.

◆ findHeadSurfaceKey()

QString 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.

Definition at line 159 of file sensorfieldmapper.cpp.

◆ findHelmetSurfaceKey()

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

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

Definition at line 178 of file sensorfieldmapper.cpp.

◆ fitSphereOrigin()

Eigen::Vector3f 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 392 of file sensorfieldmapper.cpp.

◆ hasMappingFor()

bool 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 126 of file sensorfieldmapper.cpp.

◆ isLoaded()

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

Definition at line 94 of file sensorfieldmapper.h.

◆ megFieldMapOnHead()

bool SensorFieldMapper::megFieldMapOnHead ( ) const
inline

Definition at line 118 of file sensorfieldmapper.h.

◆ megMapping()

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

Definition at line 160 of file sensorfieldmapper.h.

◆ megPick()

const QVector< int > & SensorFieldMapper::megPick ( ) const
inline
Returns
Const reference to the MEG channel pick indices.

Definition at line 150 of file sensorfieldmapper.h.

◆ megSurfaceKey()

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

Definition at line 203 of file sensorfieldmapper.h.

◆ setColormap()

void 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 126 of file sensorfieldmapper.h.

◆ setEvoked()

void 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 103 of file sensorfieldmapper.cpp.

◆ setMegFieldMapOnHead()

void 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 116 of file sensorfieldmapper.h.

◆ setTimePoint()

void 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 102 of file sensorfieldmapper.h.

◆ timePoint()

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

Definition at line 107 of file sensorfieldmapper.h.


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