Controller for real-time sensor data streaming. More...
#include <rtsensordatacontroller.h>
Signals | |
| void | newSensorColorsAvailable (const QString &surfaceKey, const QVector< uint32_t > &colors) |
| void | newRawSensorDataAvailable (const Eigen::VectorXf &data) |
| void | newMegMappingAvailable (const QString &surfaceKey, QSharedPointer< Eigen::MatrixXf > mappingMat, const QVector< int > &pick) |
| void | newEegMappingAvailable (const QString &surfaceKey, QSharedPointer< Eigen::MatrixXf > mappingMat, const QVector< int > &pick) |
Public Member Functions | |
| RtSensorDataController (QObject *parent=nullptr) | |
| ~RtSensorDataController () override | |
| void | addData (const Eigen::VectorXf &data) |
| void | setMappingMatrix (QSharedPointer< Eigen::MatrixXf > mat) |
| void | setStreamingState (bool state) |
| bool | isStreaming () const |
| void | setTimeInterval (int msec) |
| void | setNumberAverages (int numAvr) |
| void | setColormapType (const QString &name) |
| void | setThresholds (double min, double max) |
| void | setLoopState (bool enabled) |
| void | setSFreq (double sFreq) |
| void | clearData () |
| void | setStreamSmoothedData (bool bStreamSmoothedData) |
| void | setEvoked (const FIFFLIB::FiffEvoked &evoked) |
| void | setTransform (const FIFFLIB::FiffCoordTrans &trans, bool applySensorTrans) |
| void | setMegFieldMapOnHead (bool onHead) |
| void | setMegSurface (const QString &surfaceKey, const Eigen::MatrixX3f &vertices, const Eigen::MatrixX3f &normals, const Eigen::MatrixX3i &triangles) |
| void | setEegSurface (const QString &surfaceKey, const Eigen::MatrixX3f &vertices) |
| void | setBadChannels (const QStringList &bads) |
| void | recomputeMapping () |
Controller for real-time sensor data streaming.
RtSensorDataController orchestrates real-time sensor data streaming. It manages a background data worker thread, a background interpolation matrix worker thread, and a timer that drives the data flow.
Unlike the source-estimate controller (which uses sparse interpolation matrices split by hemisphere), this controller uses a single dense mapping matrix produced by FieldMap::computeMeg/EegMapping() that maps sensor measurements directly to surface vertex values.
The controller can either accept a precomputed mapping matrix via setMappingMatrix(), or compute one on-the-fly in a background thread by providing evoked data, surface geometry, and transforms via the setInterpolationInfo() / setEvoked() / setTransform() methods. When parameters change, recomputeMapping() triggers an asynchronous recomputation; the new matrix is automatically forwarded to the data worker.
Usage:
Definition at line 93 of file rtsensordatacontroller.h.

|
explicit |
Constructor. Creates the worker and background thread.
| [in] | parent | Parent QObject. |
Definition at line 51 of file rtsensordatacontroller.cpp.
|
override |
Destructor. Stops the worker thread and cleans up.
Definition at line 98 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::addData | ( | const Eigen::VectorXf & | data | ) |
Add a sensor measurement vector to the streaming queue. The vector should contain one value per picked sensor channel (matching the mapping matrix column count).
| [in] | data | Sensor measurement vector (nChannels x 1). |
Definition at line 120 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::clearData | ( | ) |
Clear all queued data and reset the worker state.
Definition at line 219 of file rtsensordatacontroller.cpp.
| bool RtSensorDataController::isStreaming | ( | ) | const |
Check if streaming is active.
Definition at line 154 of file rtsensordatacontroller.cpp.
|
signal |
Emitted when a new EEG mapping matrix has been computed by the background worker.
| [in] | surfaceKey | Target surface key. |
| [in] | mappingMat | Dense mapping matrix (nVerts x nChannels). |
| [in] | pick | Channel indices picked for this mapping. |
|
signal |
Emitted when a new MEG mapping matrix has been computed by the background worker.
| [in] | surfaceKey | Target surface key. |
| [in] | mappingMat | Dense mapping matrix (nVerts x nChannels). |
| [in] | pick | Channel indices picked for this mapping. |
|
signal |
Emitted when raw (non-mapped) sensor data is available.
| [in] | data | Raw sensor measurement vector. |
|
signal |
Emitted when new per-vertex color data for a sensor surface is available.
| [in] | surfaceKey | Key identifying the target surface. |
| [in] | colors | Per-vertex ABGR color array. |
| void RtSensorDataController::recomputeMapping | ( | ) |
Trigger an asynchronous recomputation of the mapping matrix. The new matrix will be automatically forwarded to the data worker when ready.
Definition at line 298 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setBadChannels | ( | const QStringList & | bads | ) |
Set bad channels for the interpolation worker.
| [in] | bads | List of bad channel names. |
Definition at line 289 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setColormapType | ( | const QString & | name | ) |
Set the colormap type.
| [in] | name | Colormap name ("MNE", "Hot", "Jet", "Viridis", "Cool", "RedBlue"). |
Definition at line 183 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setEegSurface | ( | const QString & | surfaceKey, |
| const Eigen::MatrixX3f & | vertices ) |
Set the EEG target surface geometry for on-the-fly mapping.
| [in] | surfaceKey | The key identifying the surface. |
| [in] | vertices | Vertex positions (nVerts x 3). |
Definition at line 279 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setEvoked | ( | const FIFFLIB::FiffEvoked & | evoked | ) |
Set the evoked data that contains channel info and sensor definitions. This configures the interpolation worker for on-the-fly recomputation.
| [in] | evoked | The evoked dataset. |
Definition at line 239 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setLoopState | ( | bool | enabled | ) |
Enable or disable looping (replay data when queue is exhausted).
| [in] | enabled | True to enable looping. |
Definition at line 201 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setMappingMatrix | ( | QSharedPointer< Eigen::MatrixXf > | mat | ) |
Set the dense mapping matrix (sensor → surface vertices). Size: (nVertices × nChannels).
| [in] | mat | Dense mapping matrix. |
Definition at line 130 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setMegFieldMapOnHead | ( | bool | onHead | ) |
Set whether the MEG field should be mapped onto the head (BEM) surface rather than the helmet surface.
| [in] | onHead | True to map onto head. |
Definition at line 258 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setMegSurface | ( | const QString & | surfaceKey, |
| const Eigen::MatrixX3f & | vertices, | ||
| const Eigen::MatrixX3f & | normals, | ||
| const Eigen::MatrixX3i & | triangles ) |
Set the MEG target surface geometry for on-the-fly mapping.
| [in] | surfaceKey | The key identifying the surface. |
| [in] | vertices | Vertex positions (nVerts x 3). |
| [in] | normals | Vertex normals (nVerts x 3). |
| [in] | triangles | Triangle indices (nTris x 3). |
Definition at line 267 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setNumberAverages | ( | int | numAvr | ) |
Set the number of samples to average before emitting.
| [in] | numAvr | Number of averages (1 = no averaging). |
Definition at line 174 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setSFreq | ( | double | sFreq | ) |
Set the sampling frequency of the incoming data.
| [in] | sFreq | Sampling frequency in Hz. |
Definition at line 210 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setStreamingState | ( | bool | state | ) |
Start or stop the streaming.
| [in] | state | True to start, false to stop. |
Definition at line 139 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setStreamSmoothedData | ( | bool | bStreamSmoothedData | ) |
Toggle between emitting per-vertex color data (smoothed) and raw sensor values.
| [in] | bStreamSmoothedData | True for smoothed colors (default), false for raw. |
Definition at line 228 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setThresholds | ( | double | min, |
| double | max ) |
Set explicit normalization thresholds for sensor data. Pass min == 0 and max == 0 to re-enable symmetric auto-normalization.
| [in] | min | Lower threshold. |
| [in] | max | Upper threshold. |
Definition at line 192 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setTimeInterval | ( | int | msec | ) |
Set the streaming interval (time between frames).
| [in] | msec | Interval in milliseconds (default: 17ms ≈ 60fps). |
Definition at line 161 of file rtsensordatacontroller.cpp.
| void RtSensorDataController::setTransform | ( | const FIFFLIB::FiffCoordTrans & | trans, |
| bool | applySensorTrans ) |
Set the head-to-MRI coordinate transform for the interpolation worker.
| [in] | trans | The transform. |
| [in] | applySensorTrans | Whether to apply the transform. |
Definition at line 248 of file rtsensordatacontroller.cpp.