38 m_pWorkerThread =
new QThread(
this);
39 m_pWorker->moveToThread(m_pWorkerThread);
42 connect(m_pWorkerThread, &QThread::finished, m_pWorker, &QObject::deleteLater);
51 m_pTimer =
new QTimer(
this);
52 m_pTimer->setTimerType(Qt::PreciseTimer);
56 m_pWorkerThread->start();
60 m_pInterpThread =
new QThread(
this);
61 m_pInterpWorker->moveToThread(m_pInterpThread);
63 connect(m_pInterpThread, &QThread::finished, m_pInterpWorker, &QObject::deleteLater);
67 this, &RtSourceDataController::onNewInterpolationMatrixLeft);
69 this, &RtSourceDataController::onNewInterpolationMatrixRight);
71 m_pInterpThread->start();
73 qDebug() <<
"RtSourceDataController: Initialized with" << m_iTimeInterval <<
"ms interval";
86 if (m_pWorkerThread) {
87 m_pWorkerThread->quit();
88 m_pWorkerThread->wait();
92 if (m_pInterpThread) {
93 m_pInterpThread->quit();
94 m_pInterpThread->wait();
104 m_pWorker->addData(data);
113 m_pWorker->setInterpolationMatrixLeft(mat);
122 m_pWorker->setInterpolationMatrixRight(mat);
130 m_bIsStreaming = state;
133 m_pTimer->start(m_iTimeInterval);
134 qDebug() <<
"RtSourceDataController: Streaming started at" << m_iTimeInterval <<
"ms interval";
137 qDebug() <<
"RtSourceDataController: Streaming stopped";
145 return m_bIsStreaming;
152 m_iTimeInterval = qMax(1, msec);
154 if (m_bIsStreaming) {
155 m_pTimer->setInterval(m_iTimeInterval);
158 qDebug() <<
"RtSourceDataController: Time interval set to" << m_iTimeInterval <<
"ms";
166 m_pWorker->setNumberAverages(numAvr);
175 m_pWorker->setColormapType(name);
184 m_pWorker->setThresholds(min, mid, max);
193 m_pWorker->setLoopState(enabled);
202 m_pWorker->setSFreq(sFreq);
218 const QVector<uint32_t> &baseColorsRh)
221 m_pWorker->setSurfaceColor(baseColorsLh, baseColorsRh);
230 m_pWorker->setStreamSmoothedData(bStreamSmoothedData);
238 if (m_pInterpWorker) {
239 m_pInterpWorker->setInterpolationFunction(sInterpolationFunction);
247 if (m_pInterpWorker) {
248 m_pInterpWorker->setCancelDistance(dCancelDist);
255 const std::vector<Eigen::VectorXi> &vecNeighborVertices,
256 const Eigen::VectorXi &vecSourceVertices)
258 if (m_pInterpWorker) {
259 m_pInterpWorker->setInterpolationInfoLeft(matVertices, vecNeighborVertices, vecSourceVertices);
266 const std::vector<Eigen::VectorXi> &vecNeighborVertices,
267 const Eigen::VectorXi &vecSourceVertices)
269 if (m_pInterpWorker) {
270 m_pInterpWorker->setInterpolationInfoRight(matVertices, vecNeighborVertices, vecSourceVertices);
278 if (m_pInterpWorker) {
279 QMetaObject::invokeMethod(m_pInterpWorker,
"computeInterpolationMatrix", Qt::QueuedConnection);
285void RtSourceDataController::onNewInterpolationMatrixLeft(QSharedPointer<Eigen::SparseMatrix<float>> interpMat)
297void RtSourceDataController::onNewInterpolationMatrixRight(QSharedPointer<Eigen::SparseMatrix<float>> interpMat)
301 m_pWorker->setInterpolationMatrixRight(interpMat);
311 if (m_pInterpWorker) {
312 m_pInterpWorker->setVisualizationType(iVisType);
319 const QList<FSLIB::FsLabel> &lLabels,
320 const Eigen::VectorXi &vecVertNo)
322 if (m_pInterpWorker) {
323 m_pInterpWorker->setAnnotationInfoLeft(vecLabelIds, lLabels, vecVertNo);
330 const QList<FSLIB::FsLabel> &lLabels,
331 const Eigen::VectorXi &vecVertNo)
333 if (m_pInterpWorker) {
334 m_pInterpWorker->setAnnotationInfoRight(vecLabelIds, lLabels, vecVertNo);
Real-time source-estimate streaming controller that owns the data worker and the per-hemisphere inter...
Background worker that builds the sparse source-to-vertex interpolation matrix for one hemisphere.
Background worker that converts streaming source vectors into smoothed per-vertex ABGR colour buffers...
Reader and in-memory representation of a FreeSurfer/MNE surface label (.label).
void setThresholds(double min, double mid, double max)
void setInterpolationMatrixLeft(QSharedPointer< Eigen::SparseMatrix< float > > mat)
void setSFreq(double sFreq)
~RtSourceDataController() override
void addData(const Eigen::VectorXd &data)
void setStreamingState(bool state)
void setStreamSmoothedData(bool bStreamSmoothedData)
void setAnnotationInfoLeft(const Eigen::VectorXi &vecLabelIds, const QList< FSLIB::FsLabel > &lLabels, const Eigen::VectorXi &vecVertNo)
void newInterpolationMatrixRightAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
void setSurfaceColor(const QVector< uint32_t > &baseColorsLh, const QVector< uint32_t > &baseColorsRh)
void setLoopState(bool enabled)
void setTimeInterval(int msec)
void setCancelDistance(double dCancelDist)
void setInterpolationInfoRight(const Eigen::MatrixX3f &matVertices, const std::vector< Eigen::VectorXi > &vecNeighborVertices, const Eigen::VectorXi &vecSourceVertices)
void recomputeInterpolation()
void setAnnotationInfoRight(const Eigen::VectorXi &vecLabelIds, const QList< FSLIB::FsLabel > &lLabels, const Eigen::VectorXi &vecVertNo)
void newRawDataAvailable(const Eigen::VectorXd &dataLh, const Eigen::VectorXd &dataRh)
void newSmoothedDataAvailable(const QVector< uint32_t > &colorsLh, const QVector< uint32_t > &colorsRh)
void setNumberAverages(int numAvr)
void setVisualizationType(int iVisType)
void setInterpolationFunction(const QString &sInterpolationFunction)
void setColormapType(const QString &name)
void newInterpolationMatrixLeftAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
RtSourceDataController(QObject *parent=nullptr)
void setInterpolationMatrixRight(QSharedPointer< Eigen::SparseMatrix< float > > mat)
void setInterpolationInfoLeft(const Eigen::MatrixX3f &matVertices, const std::vector< Eigen::VectorXi > &vecNeighborVertices, const Eigen::VectorXi &vecSourceVertices)
Background worker for real-time source estimate streaming.
void setInterpolationMatrixLeft(QSharedPointer< Eigen::SparseMatrix< float > > mat)
void newRtRawData(const Eigen::VectorXd &dataLh, const Eigen::VectorXd &dataRh)
void newRtSmoothedData(const QVector< uint32_t > &colorsLh, const QVector< uint32_t > &colorsRh)
Background worker for computing source interpolation matrices.
void newInterpolationMatrixRightAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
void newInterpolationMatrixLeftAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)