60 m_pWorkerThread =
new QThread(
this);
61 m_pWorker->moveToThread(m_pWorkerThread);
64 connect(m_pWorkerThread, &QThread::finished, m_pWorker, &QObject::deleteLater);
73 m_pTimer =
new QTimer(
this);
74 m_pTimer->setTimerType(Qt::PreciseTimer);
78 m_pWorkerThread->start();
82 m_pInterpThread =
new QThread(
this);
83 m_pInterpWorker->moveToThread(m_pInterpThread);
85 connect(m_pInterpThread, &QThread::finished, m_pInterpWorker, &QObject::deleteLater);
89 this, &RtSourceDataController::onNewInterpolationMatrixLeft);
91 this, &RtSourceDataController::onNewInterpolationMatrixRight);
93 m_pInterpThread->start();
95 qDebug() <<
"RtSourceDataController: Initialized with" << m_iTimeInterval <<
"ms interval";
108 if (m_pWorkerThread) {
109 m_pWorkerThread->quit();
110 m_pWorkerThread->wait();
114 if (m_pInterpThread) {
115 m_pInterpThread->quit();
116 m_pInterpThread->wait();
126 m_pWorker->addData(data);
135 m_pWorker->setInterpolationMatrixLeft(mat);
144 m_pWorker->setInterpolationMatrixRight(mat);
152 m_bIsStreaming = state;
155 m_pTimer->start(m_iTimeInterval);
156 qDebug() <<
"RtSourceDataController: Streaming started at" << m_iTimeInterval <<
"ms interval";
159 qDebug() <<
"RtSourceDataController: Streaming stopped";
167 return m_bIsStreaming;
174 m_iTimeInterval = qMax(1, msec);
176 if (m_bIsStreaming) {
177 m_pTimer->setInterval(m_iTimeInterval);
180 qDebug() <<
"RtSourceDataController: Time interval set to" << m_iTimeInterval <<
"ms";
188 m_pWorker->setNumberAverages(numAvr);
197 m_pWorker->setColormapType(name);
206 m_pWorker->setThresholds(min, mid, max);
215 m_pWorker->setLoopState(enabled);
224 m_pWorker->setSFreq(sFreq);
240 const QVector<uint32_t> &baseColorsRh)
243 m_pWorker->setSurfaceColor(baseColorsLh, baseColorsRh);
252 m_pWorker->setStreamSmoothedData(bStreamSmoothedData);
260 if (m_pInterpWorker) {
261 m_pInterpWorker->setInterpolationFunction(sInterpolationFunction);
269 if (m_pInterpWorker) {
270 m_pInterpWorker->setCancelDistance(dCancelDist);
277 const std::vector<Eigen::VectorXi> &vecNeighborVertices,
278 const Eigen::VectorXi &vecSourceVertices)
280 if (m_pInterpWorker) {
281 m_pInterpWorker->setInterpolationInfoLeft(matVertices, vecNeighborVertices, vecSourceVertices);
288 const std::vector<Eigen::VectorXi> &vecNeighborVertices,
289 const Eigen::VectorXi &vecSourceVertices)
291 if (m_pInterpWorker) {
292 m_pInterpWorker->setInterpolationInfoRight(matVertices, vecNeighborVertices, vecSourceVertices);
300 if (m_pInterpWorker) {
301 QMetaObject::invokeMethod(m_pInterpWorker,
"computeInterpolationMatrix", Qt::QueuedConnection);
307void RtSourceDataController::onNewInterpolationMatrixLeft(QSharedPointer<Eigen::SparseMatrix<float>> interpMat)
319void RtSourceDataController::onNewInterpolationMatrixRight(QSharedPointer<Eigen::SparseMatrix<float>> interpMat)
323 m_pWorker->setInterpolationMatrixRight(interpMat);
333 if (m_pInterpWorker) {
334 m_pInterpWorker->setVisualizationType(iVisType);
341 const QList<FSLIB::Label> &lLabels,
342 const Eigen::VectorXi &vecVertNo)
344 if (m_pInterpWorker) {
345 m_pInterpWorker->setAnnotationInfoLeft(vecLabelIds, lLabels, vecVertNo);
352 const QList<FSLIB::Label> &lLabels,
353 const Eigen::VectorXi &vecVertNo)
355 if (m_pInterpWorker) {
356 m_pInterpWorker->setAnnotationInfoRight(vecLabelIds, lLabels, vecVertNo);
RtSourceDataController class declaration.
RtSourceDataWorker class declaration.
RtSourceInterpolationMatWorker class declaration.
void setAnnotationInfoRight(const Eigen::VectorXi &vecLabelIds, const QList< FSLIB::Label > &lLabels, const Eigen::VectorXi &vecVertNo)
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::Label > &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 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 newRtSmoothedData(const QVector< uint32_t > &colorsLh, const QVector< uint32_t > &colorsRh)
void setInterpolationMatrixLeft(QSharedPointer< Eigen::SparseMatrix< float > > mat)
void newRtRawData(const Eigen::VectorXd &dataLh, const Eigen::VectorXd &dataRh)
Background worker for computing source interpolation matrices.
void newInterpolationMatrixRightAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)
void newInterpolationMatrixLeftAvailable(QSharedPointer< Eigen::SparseMatrix< float > > interpMat)