58 m_pWorkerThread =
new QThread(
this);
59 m_pWorker->moveToThread(m_pWorkerThread);
62 connect(m_pWorkerThread, &QThread::finished, m_pWorker, &QObject::deleteLater);
71 m_pTimer =
new QTimer(
this);
72 m_pTimer->setTimerType(Qt::PreciseTimer);
76 m_pWorkerThread->start();
80 m_pInterpThread =
new QThread(
this);
81 m_pInterpWorker->moveToThread(m_pInterpThread);
83 connect(m_pInterpThread, &QThread::finished, m_pInterpWorker, &QObject::deleteLater);
87 this, &RtSensorDataController::onNewMegMapping);
89 this, &RtSensorDataController::onNewEegMapping);
91 m_pInterpThread->start();
93 qDebug() <<
"RtSensorDataController: Initialized with" << m_iTimeInterval <<
"ms interval";
106 if (m_pWorkerThread) {
107 m_pWorkerThread->quit();
108 m_pWorkerThread->wait();
112 if (m_pInterpThread) {
113 m_pInterpThread->quit();
114 m_pInterpThread->wait();
124 m_pWorker->addData(data);
133 m_pWorker->setMappingMatrix(mat);
141 m_bIsStreaming = state;
144 m_pTimer->start(m_iTimeInterval);
145 qDebug() <<
"RtSensorDataController: Streaming started at" << m_iTimeInterval <<
"ms interval";
148 qDebug() <<
"RtSensorDataController: Streaming stopped";
156 return m_bIsStreaming;
163 m_iTimeInterval = qMax(1, msec);
165 if (m_bIsStreaming) {
166 m_pTimer->setInterval(m_iTimeInterval);
169 qDebug() <<
"RtSensorDataController: Time interval set to" << m_iTimeInterval <<
"ms";
177 m_pWorker->setNumberAverages(numAvr);
186 m_pWorker->setColormapType(name);
195 m_pWorker->setThresholds(min, max);
204 m_pWorker->setLoopState(enabled);
213 m_pWorker->setSFreq(sFreq);
231 m_pWorker->setStreamSmoothedData(bStreamSmoothedData);
241 if (m_pInterpWorker) {
242 m_pInterpWorker->setEvoked(evoked);
249 bool applySensorTrans)
251 if (m_pInterpWorker) {
252 m_pInterpWorker->setTransform(trans, applySensorTrans);
260 if (m_pInterpWorker) {
261 m_pInterpWorker->setMegFieldMapOnHead(onHead);
268 const Eigen::MatrixX3f &vertices,
269 const Eigen::MatrixX3f &normals,
270 const Eigen::MatrixX3i &triangles)
272 if (m_pInterpWorker) {
273 m_pInterpWorker->setMegSurface(surfaceKey, vertices, normals, triangles);
280 const Eigen::MatrixX3f &vertices)
282 if (m_pInterpWorker) {
283 m_pInterpWorker->setEegSurface(surfaceKey, vertices);
291 if (m_pInterpWorker) {
292 m_pInterpWorker->setBadChannels(bads);
300 if (m_pInterpWorker) {
303 QMetaObject::invokeMethod(m_pInterpWorker,
"computeMapping", Qt::QueuedConnection);
309void RtSensorDataController::onNewMegMapping(
const QString &surfaceKey,
310 QSharedPointer<Eigen::MatrixXf> mappingMat,
311 const QVector<int> &pick)
314 if (m_pWorker && mappingMat) {
321 qDebug() <<
"RtSensorDataController: New MEG mapping received and forwarded"
322 <<
"(" << mappingMat->rows() <<
"x" << mappingMat->cols() <<
")";
327void RtSensorDataController::onNewEegMapping(
const QString &surfaceKey,
328 QSharedPointer<Eigen::MatrixXf> mappingMat,
329 const QVector<int> &pick)
332 if (m_pWorker && mappingMat) {
333 m_pWorker->setMappingMatrix(mappingMat);
339 qDebug() <<
"RtSensorDataController: New EEG mapping received and forwarded"
340 <<
"(" << mappingMat->rows() <<
"x" << mappingMat->cols() <<
")";
RtSensorInterpolationMatWorker class declaration.
RtSensorDataWorker class declaration.
RtSensorDataController class declaration.
void setMegFieldMapOnHead(bool onHead)
void newSensorColorsAvailable(const QString &surfaceKey, const QVector< uint32_t > &colors)
void newMegMappingAvailable(const QString &surfaceKey, QSharedPointer< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
~RtSensorDataController() override
void setColormapType(const QString &name)
void setMegSurface(const QString &surfaceKey, const Eigen::MatrixX3f &vertices, const Eigen::MatrixX3f &normals, const Eigen::MatrixX3i &triangles)
void setBadChannels(const QStringList &bads)
void setTransform(const FIFFLIB::FiffCoordTrans &trans, bool applySensorTrans)
void setMappingMatrix(QSharedPointer< Eigen::MatrixXf > mat)
void setStreamingState(bool state)
void setEegSurface(const QString &surfaceKey, const Eigen::MatrixX3f &vertices)
void setLoopState(bool enabled)
void newRawSensorDataAvailable(const Eigen::VectorXf &data)
void addData(const Eigen::VectorXf &data)
void setEvoked(const FIFFLIB::FiffEvoked &evoked)
void setStreamSmoothedData(bool bStreamSmoothedData)
void setTimeInterval(int msec)
void setSFreq(double sFreq)
void newEegMappingAvailable(const QString &surfaceKey, QSharedPointer< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
RtSensorDataController(QObject *parent=nullptr)
void setNumberAverages(int numAvr)
void setThresholds(double min, double max)
Background worker for real-time sensor data streaming.
void setMappingMatrix(QSharedPointer< Eigen::MatrixXf > mat)
void newRtRawSensorData(const Eigen::VectorXf &data)
void newRtSensorColors(const QString &surfaceKey, const QVector< uint32_t > &colors)
Background worker for computing sensor field mapping matrices.
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)
Coordinate transformation description.