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

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 ()

Detailed Description

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:

  1. Create controller
  2. Either set mapping matrix via setMappingMatrix(), or configure interpolation parameters and call recomputeMapping()
  3. Connect newSensorColorsAvailable() to your rendering update slot
  4. Call addData() to push sensor measurement vectors
  5. Call setStreamingState(true) to start streaming

Definition at line 93 of file rtsensordatacontroller.h.

Inheritance diagram for RtSensorDataController:
Inheritance graph

Constructor & Destructor Documentation

◆ RtSensorDataController()

RtSensorDataController::RtSensorDataController ( QObject * parent = nullptr)
explicit

Constructor. Creates the worker and background thread.

Parameters
[in]parentParent QObject.

Definition at line 51 of file rtsensordatacontroller.cpp.

◆ ~RtSensorDataController()

RtSensorDataController::~RtSensorDataController ( )
override

Destructor. Stops the worker thread and cleans up.

Definition at line 98 of file rtsensordatacontroller.cpp.

Member Function Documentation

◆ addData()

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

Parameters
[in]dataSensor measurement vector (nChannels x 1).

Definition at line 120 of file rtsensordatacontroller.cpp.

◆ clearData()

void RtSensorDataController::clearData ( )

Clear all queued data and reset the worker state.

Definition at line 219 of file rtsensordatacontroller.cpp.

◆ isStreaming()

bool RtSensorDataController::isStreaming ( ) const

Check if streaming is active.

Returns
True if streaming is running.

Definition at line 154 of file rtsensordatacontroller.cpp.

◆ newEegMappingAvailable

void RtSensorDataController::newEegMappingAvailable ( const QString & surfaceKey,
QSharedPointer< Eigen::MatrixXf > mappingMat,
const QVector< int > & pick )
signal

Emitted when a new EEG mapping matrix has been computed by the background worker.

Parameters
[in]surfaceKeyTarget surface key.
[in]mappingMatDense mapping matrix (nVerts x nChannels).
[in]pickChannel indices picked for this mapping.

◆ newMegMappingAvailable

void RtSensorDataController::newMegMappingAvailable ( const QString & surfaceKey,
QSharedPointer< Eigen::MatrixXf > mappingMat,
const QVector< int > & pick )
signal

Emitted when a new MEG mapping matrix has been computed by the background worker.

Parameters
[in]surfaceKeyTarget surface key.
[in]mappingMatDense mapping matrix (nVerts x nChannels).
[in]pickChannel indices picked for this mapping.

◆ newRawSensorDataAvailable

void RtSensorDataController::newRawSensorDataAvailable ( const Eigen::VectorXf & data)
signal

Emitted when raw (non-mapped) sensor data is available.

Parameters
[in]dataRaw sensor measurement vector.

◆ newSensorColorsAvailable

void RtSensorDataController::newSensorColorsAvailable ( const QString & surfaceKey,
const QVector< uint32_t > & colors )
signal

Emitted when new per-vertex color data for a sensor surface is available.

Parameters
[in]surfaceKeyKey identifying the target surface.
[in]colorsPer-vertex ABGR color array.

◆ recomputeMapping()

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.

◆ setBadChannels()

void RtSensorDataController::setBadChannels ( const QStringList & bads)

Set bad channels for the interpolation worker.

Parameters
[in]badsList of bad channel names.

Definition at line 289 of file rtsensordatacontroller.cpp.

◆ setColormapType()

void RtSensorDataController::setColormapType ( const QString & name)

Set the colormap type.

Parameters
[in]nameColormap name ("MNE", "Hot", "Jet", "Viridis", "Cool", "RedBlue").

Definition at line 183 of file rtsensordatacontroller.cpp.

◆ setEegSurface()

void RtSensorDataController::setEegSurface ( const QString & surfaceKey,
const Eigen::MatrixX3f & vertices )

Set the EEG target surface geometry for on-the-fly mapping.

Parameters
[in]surfaceKeyThe key identifying the surface.
[in]verticesVertex positions (nVerts x 3).

Definition at line 279 of file rtsensordatacontroller.cpp.

◆ setEvoked()

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.

Parameters
[in]evokedThe evoked dataset.

Definition at line 239 of file rtsensordatacontroller.cpp.

◆ setLoopState()

void RtSensorDataController::setLoopState ( bool enabled)

Enable or disable looping (replay data when queue is exhausted).

Parameters
[in]enabledTrue to enable looping.

Definition at line 201 of file rtsensordatacontroller.cpp.

◆ setMappingMatrix()

void RtSensorDataController::setMappingMatrix ( QSharedPointer< Eigen::MatrixXf > mat)

Set the dense mapping matrix (sensor → surface vertices). Size: (nVertices × nChannels).

Parameters
[in]matDense mapping matrix.

Definition at line 130 of file rtsensordatacontroller.cpp.

◆ setMegFieldMapOnHead()

void RtSensorDataController::setMegFieldMapOnHead ( bool onHead)

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

Parameters
[in]onHeadTrue to map onto head.

Definition at line 258 of file rtsensordatacontroller.cpp.

◆ setMegSurface()

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.

Parameters
[in]surfaceKeyThe key identifying the surface.
[in]verticesVertex positions (nVerts x 3).
[in]normalsVertex normals (nVerts x 3).
[in]trianglesTriangle indices (nTris x 3).

Definition at line 267 of file rtsensordatacontroller.cpp.

◆ setNumberAverages()

void RtSensorDataController::setNumberAverages ( int numAvr)

Set the number of samples to average before emitting.

Parameters
[in]numAvrNumber of averages (1 = no averaging).

Definition at line 174 of file rtsensordatacontroller.cpp.

◆ setSFreq()

void RtSensorDataController::setSFreq ( double sFreq)

Set the sampling frequency of the incoming data.

Parameters
[in]sFreqSampling frequency in Hz.

Definition at line 210 of file rtsensordatacontroller.cpp.

◆ setStreamingState()

void RtSensorDataController::setStreamingState ( bool state)

Start or stop the streaming.

Parameters
[in]stateTrue to start, false to stop.

Definition at line 139 of file rtsensordatacontroller.cpp.

◆ setStreamSmoothedData()

void RtSensorDataController::setStreamSmoothedData ( bool bStreamSmoothedData)

Toggle between emitting per-vertex color data (smoothed) and raw sensor values.

Parameters
[in]bStreamSmoothedDataTrue for smoothed colors (default), false for raw.

Definition at line 228 of file rtsensordatacontroller.cpp.

◆ setThresholds()

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.

Parameters
[in]minLower threshold.
[in]maxUpper threshold.

Definition at line 192 of file rtsensordatacontroller.cpp.

◆ setTimeInterval()

void RtSensorDataController::setTimeInterval ( int msec)

Set the streaming interval (time between frames).

Parameters
[in]msecInterval in milliseconds (default: 17ms ≈ 60fps).

Definition at line 161 of file rtsensordatacontroller.cpp.

◆ setTransform()

void RtSensorDataController::setTransform ( const FIFFLIB::FiffCoordTrans & trans,
bool applySensorTrans )

Set the head-to-MRI coordinate transform for the interpolation worker.

Parameters
[in]transThe transform.
[in]applySensorTransWhether to apply the transform.

Definition at line 248 of file rtsensordatacontroller.cpp.


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