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

Controller for real-time source estimate streaming. More...

#include <rtsourcedatacontroller.h>

Signals

void newSmoothedDataAvailable (const QVector< uint32_t > &colorsLh, const QVector< uint32_t > &colorsRh)
void newRawDataAvailable (const Eigen::VectorXd &dataLh, const Eigen::VectorXd &dataRh)
void newInterpolationMatrixLeftAvailable (QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
void newInterpolationMatrixRightAvailable (QSharedPointer< Eigen::SparseMatrix< float > > interpMat)

Public Member Functions

 RtSourceDataController (QObject *parent=nullptr)
 ~RtSourceDataController () override
void addData (const Eigen::VectorXd &data)
void setInterpolationMatrixLeft (QSharedPointer< Eigen::SparseMatrix< float > > mat)
void setInterpolationMatrixRight (QSharedPointer< Eigen::SparseMatrix< float > > 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 mid, double max)
void setLoopState (bool enabled)
void setSFreq (double sFreq)
void clearData ()
void setSurfaceColor (const QVector< uint32_t > &baseColorsLh, const QVector< uint32_t > &baseColorsRh)
void setStreamSmoothedData (bool bStreamSmoothedData)
void setInterpolationFunction (const QString &sInterpolationFunction)
void setCancelDistance (double dCancelDist)
void setInterpolationInfoLeft (const Eigen::MatrixX3f &matVertices, const QVector< QVector< int > > &vecNeighborVertices, const QVector< int > &vecSourceVertices)
void setInterpolationInfoRight (const Eigen::MatrixX3f &matVertices, const QVector< QVector< int > > &vecNeighborVertices, const QVector< int > &vecSourceVertices)
void recomputeInterpolation ()
void setVisualizationType (int iVisType)
void setAnnotationInfoLeft (const Eigen::VectorXi &vecLabelIds, const QList< FSLIB::Label > &lLabels, const Eigen::VectorXi &vecVertNo)
void setAnnotationInfoRight (const Eigen::VectorXi &vecLabelIds, const QList< FSLIB::Label > &lLabels, const Eigen::VectorXi &vecVertNo)

Detailed Description

Controller for real-time source estimate streaming.

RtSourceDataController orchestrates real-time source estimate streaming. It manages a background data worker thread, an optional background interpolation matrix worker thread, and a timer that drives the data flow.

The controller provides a simple public API for:

  • Pushing new source estimate data
  • Setting interpolation matrices (LH/RH) directly or triggering on-the-fly recomputation when parameters change
  • Configuring streaming parameters (speed, looping, averaging)
  • Configuring visualization parameters (colormap, thresholds)
  • Starting/stopping the streaming

On-the-fly recomputation:

Usage:

  1. Create controller
  2. Set interpolation matrices via setInterpolationMatrixLeft/Right()
  3. Connect newSmoothedDataAvailable() to your rendering update slot
  4. Call addData() to push source estimate vectors
  5. Call setStreamingState(true) to start streaming

Definition at line 98 of file rtsourcedatacontroller.h.

Inheritance diagram for RtSourceDataController:
Inheritance graph

Constructor & Destructor Documentation

◆ RtSourceDataController()

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

Constructor. Creates the worker and background thread.

Parameters
[in]parentParent QObject.

Definition at line 53 of file rtsourcedatacontroller.cpp.

◆ ~RtSourceDataController()

RtSourceDataController::~RtSourceDataController ( )
override

Destructor. Stops the worker thread and cleans up.

Definition at line 100 of file rtsourcedatacontroller.cpp.

Member Function Documentation

◆ addData()

void RtSourceDataController::addData ( const Eigen::VectorXd & data)

Add a source estimate data vector to the streaming queue. The vector should contain source values for all sources (LH + RH concatenated).

Parameters
[in]dataSource activity vector (nSourcesLH + nSourcesRH).

Definition at line 122 of file rtsourcedatacontroller.cpp.

◆ clearData()

void RtSourceDataController::clearData ( )

Clear all queued data and reset the worker state.

Definition at line 230 of file rtsourcedatacontroller.cpp.

◆ isStreaming()

bool RtSourceDataController::isStreaming ( ) const

Check if streaming is active.

Returns
True if streaming is running.

Definition at line 165 of file rtsourcedatacontroller.cpp.

◆ newInterpolationMatrixLeftAvailable

void RtSourceDataController::newInterpolationMatrixLeftAvailable ( QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
signal

Emitted when a new left hemisphere interpolation matrix has been computed.

Parameters
[in]interpMatSparse interpolation matrix (nVertices x nSources).

◆ newInterpolationMatrixRightAvailable

void RtSourceDataController::newInterpolationMatrixRightAvailable ( QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
signal

Emitted when a new right hemisphere interpolation matrix has been computed.

Parameters
[in]interpMatSparse interpolation matrix (nVertices x nSources).

◆ newRawDataAvailable

void RtSourceDataController::newRawDataAvailable ( const Eigen::VectorXd & dataLh,
const Eigen::VectorXd & dataRh )
signal

Emitted when raw (non-interpolated) data is available.

Parameters
[in]dataLhSource values for left hemisphere.
[in]dataRhSource values for right hemisphere.

◆ newSmoothedDataAvailable

void RtSourceDataController::newSmoothedDataAvailable ( const QVector< uint32_t > & colorsLh,
const QVector< uint32_t > & colorsRh )
signal

Emitted when new interpolated per-vertex color data is available for rendering.

Parameters
[in]colorsLhPer-vertex ABGR color array for the left hemisphere.
[in]colorsRhPer-vertex ABGR color array for the right hemisphere.

◆ recomputeInterpolation()

void RtSourceDataController::recomputeInterpolation ( )

Trigger an asynchronous recomputation of the interpolation matrices. The new matrices will be automatically forwarded to the data worker.

Definition at line 298 of file rtsourcedatacontroller.cpp.

◆ setAnnotationInfoLeft()

void RtSourceDataController::setAnnotationInfoLeft ( const Eigen::VectorXi & vecLabelIds,
const QList< FSLIB::Label > & lLabels,
const Eigen::VectorXi & vecVertNo )

Set annotation info for the left hemisphere.

Parameters
[in]vecLabelIdsPer-vertex label IDs.
[in]lLabelsFreeSurfer Labels.
[in]vecVertNoSource vertex numbers.

Definition at line 340 of file rtsourcedatacontroller.cpp.

◆ setAnnotationInfoRight()

void RtSourceDataController::setAnnotationInfoRight ( const Eigen::VectorXi & vecLabelIds,
const QList< FSLIB::Label > & lLabels,
const Eigen::VectorXi & vecVertNo )

Set annotation info for the right hemisphere.

Parameters
[in]vecLabelIdsPer-vertex label IDs.
[in]lLabelsFreeSurfer Labels.
[in]vecVertNoSource vertex numbers.

Definition at line 351 of file rtsourcedatacontroller.cpp.

◆ setCancelDistance()

void RtSourceDataController::setCancelDistance ( double dCancelDist)

Set the cancel distance for on-the-fly matrix computation. Distances larger than this are ignored in the interpolation.

Parameters
[in]dCancelDistCancel distance in meters.

Definition at line 267 of file rtsourcedatacontroller.cpp.

◆ setColormapType()

void RtSourceDataController::setColormapType ( const QString & name)

Set the colormap type.

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

Definition at line 194 of file rtsourcedatacontroller.cpp.

◆ setInterpolationFunction()

void RtSourceDataController::setInterpolationFunction ( const QString & sInterpolationFunction)

Set the interpolation function for on-the-fly matrix computation.

Parameters
[in]sInterpolationFunctionFunction name ("linear", "gaussian", "square", "cubic").

Definition at line 258 of file rtsourcedatacontroller.cpp.

◆ setInterpolationInfoLeft()

void RtSourceDataController::setInterpolationInfoLeft ( const Eigen::MatrixX3f & matVertices,
const QVector< QVector< int > > & vecNeighborVertices,
const QVector< int > & vecSourceVertices )

Set the surface and source geometry for the left hemisphere. Used for on-the-fly interpolation matrix computation.

Parameters
[in]matVerticesVertex positions (nVerts x 3).
[in]vecNeighborVerticesPer-vertex neighbor index lists.
[in]vecSourceVerticesSource vertex indices into the surface.

Definition at line 276 of file rtsourcedatacontroller.cpp.

◆ setInterpolationInfoRight()

void RtSourceDataController::setInterpolationInfoRight ( const Eigen::MatrixX3f & matVertices,
const QVector< QVector< int > > & vecNeighborVertices,
const QVector< int > & vecSourceVertices )

Set the surface and source geometry for the right hemisphere. Used for on-the-fly interpolation matrix computation.

Parameters
[in]matVerticesVertex positions (nVerts x 3).
[in]vecNeighborVerticesPer-vertex neighbor index lists.
[in]vecSourceVerticesSource vertex indices into the surface.

Definition at line 287 of file rtsourcedatacontroller.cpp.

◆ setInterpolationMatrixLeft()

void RtSourceDataController::setInterpolationMatrixLeft ( QSharedPointer< Eigen::SparseMatrix< float > > mat)

Set the interpolation matrix for the left hemisphere.

Parameters
[in]matSparse interpolation matrix (nVerticesLH x nSourcesLH).

Definition at line 132 of file rtsourcedatacontroller.cpp.

◆ setInterpolationMatrixRight()

void RtSourceDataController::setInterpolationMatrixRight ( QSharedPointer< Eigen::SparseMatrix< float > > mat)

Set the interpolation matrix for the right hemisphere.

Parameters
[in]matSparse interpolation matrix (nVerticesRH x nSourcesRH).

Definition at line 141 of file rtsourcedatacontroller.cpp.

◆ setLoopState()

void RtSourceDataController::setLoopState ( bool enabled)

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

Parameters
[in]enabledTrue to enable looping.

Definition at line 212 of file rtsourcedatacontroller.cpp.

◆ setNumberAverages()

void RtSourceDataController::setNumberAverages ( int numAvr)

Set the number of samples to average before emitting.

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

Definition at line 185 of file rtsourcedatacontroller.cpp.

◆ setSFreq()

void RtSourceDataController::setSFreq ( double sFreq)

Set the sampling frequency of the incoming data.

Parameters
[in]sFreqSampling frequency in Hz.

Definition at line 221 of file rtsourcedatacontroller.cpp.

◆ setStreamingState()

void RtSourceDataController::setStreamingState ( bool state)

Start or stop the streaming.

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

Definition at line 150 of file rtsourcedatacontroller.cpp.

◆ setStreamSmoothedData()

void RtSourceDataController::setStreamSmoothedData ( bool bStreamSmoothedData)

Toggle between emitting interpolated color data (smoothed) and raw source values split by hemisphere.

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

Definition at line 249 of file rtsourcedatacontroller.cpp.

◆ setSurfaceColor()

void RtSourceDataController::setSurfaceColor ( const QVector< uint32_t > & baseColorsLh,
const QVector< uint32_t > & baseColorsRh )

Set the base surface colors for both hemispheres. Sub-threshold vertices will display these colors (e.g., curvature or annotation coloring) instead of being transparent.

Parameters
[in]baseColorsLhPer-vertex ABGR colors for the left hemisphere.
[in]baseColorsRhPer-vertex ABGR colors for the right hemisphere.

Definition at line 239 of file rtsourcedatacontroller.cpp.

◆ setThresholds()

void RtSourceDataController::setThresholds ( double min,
double mid,
double max )

Set the normalization thresholds.

Parameters
[in]minLower threshold.
[in]midMid-point threshold.
[in]maxUpper threshold.

Definition at line 203 of file rtsourcedatacontroller.cpp.

◆ setTimeInterval()

void RtSourceDataController::setTimeInterval ( int msec)

Set the streaming interval (time between frames).

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

Definition at line 172 of file rtsourcedatacontroller.cpp.

◆ setVisualizationType()

void RtSourceDataController::setVisualizationType ( int iVisType)

Set the visualization type (interpolation-based or annotation-based).

Parameters
[in]iVisType0 = InterpolationBased, 1 = AnnotationBased.

Definition at line 331 of file rtsourcedatacontroller.cpp.


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