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 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) |
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 73 of file sensorfieldmapper.h.
|
default |
Construct an empty (unloaded) mapper.
| 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.
| [in,out] | surfaces | Surface map (contour surfaces may be added). |
| [in] | singleView | The single-view SubView for visibility flags. |
| [in] | subViews | The four multi-view SubViews. |
Definition at line 516 of file sensorfieldmapper.cpp.
| 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.
| [in] | surfaces | All surfaces keyed by name. |
| [in] | headToMriTrans | Head → MRI coordinate transform. |
| [in] | applySensorTrans | Whether to apply the sensor → MRI transform. |
true on success (at least one mapping built). Definition at line 193 of file sensorfieldmapper.cpp.
|
inline |
Definition at line 130 of file sensorfieldmapper.h.
| 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 457 of file sensorfieldmapper.cpp.
|
static |
Compute a "nice" iso-contour step given a value range and target number of ticks.
Definition at line 171 of file sensorfieldmapper.cpp.
|
inline |
Definition at line 167 of file sensorfieldmapper.h.
|
inline |
Definition at line 157 of file sensorfieldmapper.h.
|
inline |
Definition at line 210 of file sensorfieldmapper.h.
|
inline |
Definition at line 136 of file sensorfieldmapper.h.
|
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 142 of file sensorfieldmapper.cpp.
|
static |
Find the MEG helmet surface key ("sens_surface_meg") if present.
Definition at line 161 of file sensorfieldmapper.cpp.
|
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.
| [in] | info | FiffInfo containing the digitization points. |
| [out] | radius | Fitted sphere radius (metres). May be nullptr. |
Definition at line 377 of file sensorfieldmapper.cpp.
| 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).
| [in] | newEvoked | The candidate new evoked data. |
true if the existing mapping is compatible, false if rebuild is needed. Definition at line 109 of file sensorfieldmapper.cpp.
|
inline |
true if evoked data has been loaded and is non-empty. Definition at line 96 of file sensorfieldmapper.h.
|
inline |
Definition at line 120 of file sensorfieldmapper.h.
|
inline |
Definition at line 162 of file sensorfieldmapper.h.
|
inline |
Definition at line 152 of file sensorfieldmapper.h.
|
inline |
Definition at line 205 of file sensorfieldmapper.h.
|
inline |
Set the colormap name used when painting field values.
| [in] | name | Colormap identifier (e.g. "MNE", "hot", "RdBu_r"). |
Definition at line 128 of file sensorfieldmapper.h.
| 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.
| [in] | evoked | The evoked dataset (contains info + data matrix). |
Definition at line 86 of file sensorfieldmapper.cpp.
|
inline |
Whether the MEG field should be mapped onto the head (BEM) surface rather than the helmet surface.
| [in] | onHead | true to map onto head, false for helmet. |
Definition at line 118 of file sensorfieldmapper.h.
|
inline |
Set the active time point index into the evoked data matrix.
| [in] | tp | Zero-based time index. |
Definition at line 104 of file sensorfieldmapper.h.
|
inline |
Definition at line 109 of file sensorfieldmapper.h.