41 m_pWorkerThread =
new QThread(
this);
42 m_pWorker->moveToThread(m_pWorkerThread);
45 connect(m_pWorkerThread, &QThread::finished, m_pWorker, &QObject::deleteLater);
54 m_pTimer =
new QTimer(
this);
55 m_pTimer->setTimerType(Qt::PreciseTimer);
59 m_pWorkerThread->start();
63 m_pInterpThread =
new QThread(
this);
64 m_pInterpWorker->moveToThread(m_pInterpThread);
66 connect(m_pInterpThread, &QThread::finished, m_pInterpWorker, &QObject::deleteLater);
70 this, &RtSourceDataController::onNewInterpolationMatrixLeft);
72 this, &RtSourceDataController::onNewInterpolationMatrixRight);
74 m_pInterpThread->start();
76 qDebug() <<
"RtSourceDataController: Initialized with" << m_iTimeInterval <<
"ms interval";
89 if (m_pWorkerThread) {
90 m_pWorkerThread->quit();
91 m_pWorkerThread->wait();
95 if (m_pInterpThread) {
96 m_pInterpThread->quit();
97 m_pInterpThread->wait();
107 m_pWorker->addData(data);
116 m_pWorker->setInterpolationMatrixLeft(mat);
125 m_pWorker->setInterpolationMatrixRight(mat);
133 m_bIsStreaming = state;
136 m_pTimer->start(m_iTimeInterval);
137 qDebug() <<
"RtSourceDataController: Streaming started at" << m_iTimeInterval <<
"ms interval";
140 qDebug() <<
"RtSourceDataController: Streaming stopped";
148 return m_bIsStreaming;
155 m_iTimeInterval = qMax(1, msec);
157 if (m_bIsStreaming) {
158 m_pTimer->setInterval(m_iTimeInterval);
161 qDebug() <<
"RtSourceDataController: Time interval set to" << m_iTimeInterval <<
"ms";
169 m_pWorker->setNumberAverages(numAvr);
178 m_pWorker->setColormapType(name);
187 m_pWorker->setThresholds(min, mid, max);
196 m_pWorker->setLoopState(enabled);
205 m_pWorker->setSFreq(sFreq);
221 const QVector<uint32_t>& baseColorsRh)
224 m_pWorker->setSurfaceColor(baseColorsLh, baseColorsRh);
233 m_pWorker->setStreamSmoothedData(bStreamSmoothedData);
241 if (m_pInterpWorker) {
242 m_pInterpWorker->setInterpolationFunction(sInterpolationFunction);
250 if (m_pInterpWorker) {
251 m_pInterpWorker->setCancelDistance(dCancelDist);
258 const std::vector<Eigen::VectorXi>& vecNeighborVertices,
259 const Eigen::VectorXi& vecSourceVertices)
261 if (m_pInterpWorker) {
262 m_pInterpWorker->setInterpolationInfoLeft(matVertices, vecNeighborVertices, vecSourceVertices);
269 const std::vector<Eigen::VectorXi>& vecNeighborVertices,
270 const Eigen::VectorXi& vecSourceVertices)
272 if (m_pInterpWorker) {
273 m_pInterpWorker->setInterpolationInfoRight(matVertices, vecNeighborVertices, vecSourceVertices);
281 if (m_pInterpWorker) {
282 QMetaObject::invokeMethod(m_pInterpWorker,
"computeInterpolationMatrix", Qt::QueuedConnection);
288void RtSourceDataController::onNewInterpolationMatrixLeft(QSharedPointer<Eigen::SparseMatrix<float>> interpMat)
300void RtSourceDataController::onNewInterpolationMatrixRight(QSharedPointer<Eigen::SparseMatrix<float>> interpMat)
304 m_pWorker->setInterpolationMatrixRight(interpMat);
314 if (m_pInterpWorker) {
315 m_pInterpWorker->setVisualizationType(iVisType);
322 const QList<FSLIB::FsLabel>& lLabels,
323 const Eigen::VectorXi& vecVertNo)
325 if (m_pInterpWorker) {
326 m_pInterpWorker->setAnnotationInfoLeft(vecLabelIds, lLabels, vecVertNo);
333 const QList<FSLIB::FsLabel>& lLabels,
334 const Eigen::VectorXi& vecVertNo)
336 if (m_pInterpWorker) {
337 m_pInterpWorker->setAnnotationInfoRight(vecLabelIds, lLabels, vecVertNo);
Background worker that converts streaming source vectors into smoothed per-vertex ABGR colour buffers...
Background worker that builds the sparse source-to-vertex interpolation matrix for one hemisphere.
Real-time source-estimate streaming controller that owns the data worker and the per-hemisphere inter...
Reader and in-memory representation of a FreeSurfer/MNE surface label (.label).
3-D brain visualisation using the Qt RHI rendering backend.
void setStreamingState(bool state)
void setAnnotationInfoLeft(const Eigen::VectorXi &vecLabelIds, const QList< FSLIB::FsLabel > &lLabels, const Eigen::VectorXi &vecVertNo)
void setNumberAverages(int numAvr)
void setLoopState(bool enabled)
void setCancelDistance(double dCancelDist)
void setInterpolationMatrixRight(QSharedPointer< Eigen::SparseMatrix< float > > mat)
~RtSourceDataController() override
void addData(const Eigen::VectorXd &data)
void recomputeInterpolation()
void setInterpolationMatrixLeft(QSharedPointer< Eigen::SparseMatrix< float > > mat)
void newRawDataAvailable(const Eigen::VectorXd &dataLh, const Eigen::VectorXd &dataRh)
void setColormapType(const QString &name)
RtSourceDataController(QObject *parent=nullptr)
void newInterpolationMatrixLeftAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
void setSFreq(double sFreq)
void setVisualizationType(int iVisType)
void setSurfaceColor(const QVector< uint32_t > &baseColorsLh, const QVector< uint32_t > &baseColorsRh)
void setStreamSmoothedData(bool bStreamSmoothedData)
void setThresholds(double min, double mid, double max)
void setInterpolationInfoRight(const Eigen::MatrixX3f &matVertices, const std::vector< Eigen::VectorXi > &vecNeighborVertices, const Eigen::VectorXi &vecSourceVertices)
void setInterpolationInfoLeft(const Eigen::MatrixX3f &matVertices, const std::vector< Eigen::VectorXi > &vecNeighborVertices, const Eigen::VectorXi &vecSourceVertices)
void newInterpolationMatrixRightAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
void setInterpolationFunction(const QString &sInterpolationFunction)
void setTimeInterval(int msec)
void newSmoothedDataAvailable(const QVector< uint32_t > &colorsLh, const QVector< uint32_t > &colorsRh)
void setAnnotationInfoRight(const Eigen::VectorXi &vecLabelIds, const QList< FSLIB::FsLabel > &lLabels, const Eigen::VectorXi &vecVertNo)
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)