39 m_pWorkerThread =
new QThread(
this);
40 m_pWorker->moveToThread(m_pWorkerThread);
43 connect(m_pWorkerThread, &QThread::finished, m_pWorker, &QObject::deleteLater);
52 m_pTimer =
new QTimer(
this);
53 m_pTimer->setTimerType(Qt::PreciseTimer);
57 m_pWorkerThread->start();
61 m_pInterpThread =
new QThread(
this);
62 m_pInterpWorker->moveToThread(m_pInterpThread);
64 connect(m_pInterpThread, &QThread::finished, m_pInterpWorker, &QObject::deleteLater);
68 this, &RtSensorDataController::onNewMegMapping);
70 this, &RtSensorDataController::onNewEegMapping);
72 m_pInterpThread->start();
74 qDebug() <<
"RtSensorDataController: Initialized with" << m_iTimeInterval <<
"ms interval";
87 if (m_pWorkerThread) {
88 m_pWorkerThread->quit();
89 m_pWorkerThread->wait();
93 if (m_pInterpThread) {
94 m_pInterpThread->quit();
95 m_pInterpThread->wait();
105 m_pWorker->addData(data);
114 m_pWorker->setMappingMatrix(surfaceKey, mat);
122 m_bIsStreaming = state;
125 m_pTimer->start(m_iTimeInterval);
126 qDebug() <<
"RtSensorDataController: Streaming started at" << m_iTimeInterval <<
"ms interval";
129 qDebug() <<
"RtSensorDataController: Streaming stopped";
137 return m_bIsStreaming;
144 m_iTimeInterval = qMax(1, msec);
146 if (m_bIsStreaming) {
147 m_pTimer->setInterval(m_iTimeInterval);
150 qDebug() <<
"RtSensorDataController: Time interval set to" << m_iTimeInterval <<
"ms";
158 m_pWorker->setNumberAverages(numAvr);
167 m_pWorker->setColormapType(name);
176 m_pWorker->setThresholds(min, max);
185 m_pWorker->setLoopState(enabled);
194 m_pWorker->setSFreq(sFreq);
212 m_pWorker->setStreamSmoothedData(bStreamSmoothedData);
222 if (m_pInterpWorker) {
223 m_pInterpWorker->setEvoked(evoked);
230 bool applySensorTrans)
232 if (m_pInterpWorker) {
233 m_pInterpWorker->setTransform(trans, applySensorTrans);
241 if (m_pInterpWorker) {
242 m_pInterpWorker->setMegFieldMapOnHead(onHead);
249 const Eigen::MatrixX3f& vertices,
250 const Eigen::MatrixX3f& normals,
251 const Eigen::MatrixX3i& triangles)
253 if (m_pInterpWorker) {
254 m_pInterpWorker->setMegSurface(surfaceKey, vertices, normals, triangles);
261 const Eigen::MatrixX3f& vertices)
263 if (m_pInterpWorker) {
264 m_pInterpWorker->setEegSurface(surfaceKey, vertices);
272 if (m_pInterpWorker) {
273 m_pInterpWorker->setBadChannels(bads);
281 if (m_pInterpWorker) {
284 QMetaObject::invokeMethod(m_pInterpWorker,
"computeMapping", Qt::QueuedConnection);
290void RtSensorDataController::onNewMegMapping(
const QString& surfaceKey,
291 std::shared_ptr<Eigen::MatrixXf> mappingMat,
292 const QVector<int>& pick)
295 if (m_pWorker && mappingMat) {
302 qDebug() <<
"RtSensorDataController: New MEG mapping received and forwarded"
303 <<
"(" << mappingMat->rows() <<
"x" << mappingMat->cols() <<
")";
308void RtSensorDataController::onNewEegMapping(
const QString& surfaceKey,
309 std::shared_ptr<Eigen::MatrixXf> mappingMat,
310 const QVector<int>& pick)
313 if (m_pWorker && mappingMat) {
314 m_pWorker->setMappingMatrix(surfaceKey, mappingMat);
320 qDebug() <<
"RtSensorDataController: New EEG mapping received and forwarded"
321 <<
"(" << mappingMat->rows() <<
"x" << mappingMat->cols() <<
")";
Background worker that recomputes the dense MEG / EEG sensor-to-surface mapping matrix off the GUI th...
Real-time MEG / EEG sensor streaming controller that orchestrates the data and field-mapping workers.
Background worker that turns queued sensor packets into per-vertex ABGR colour buffers via a dense ma...
3-D brain visualisation using the Qt RHI rendering backend.
void newSensorColorsAvailable(const QString &surfaceKey, const QVector< uint32_t > &colors)
void setTransform(const FIFFLIB::FiffCoordTrans &trans, bool applySensorTrans)
void setEegSurface(const QString &surfaceKey, const Eigen::MatrixX3f &vertices)
~RtSensorDataController() override
void setEvoked(const FIFFLIB::FiffEvoked &evoked)
void newEegMappingAvailable(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
void setColormapType(const QString &name)
void newRawSensorDataAvailable(const Eigen::VectorXf &data)
void setMappingMatrix(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mat)
void setMegFieldMapOnHead(bool onHead)
void setStreamSmoothedData(bool bStreamSmoothedData)
RtSensorDataController(QObject *parent=nullptr)
void newMegMappingAvailable(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
void setNumberAverages(int numAvr)
void setTimeInterval(int msec)
void addData(const Eigen::VectorXf &data)
void setSFreq(double sFreq)
void setMegSurface(const QString &surfaceKey, const Eigen::MatrixX3f &vertices, const Eigen::MatrixX3f &normals, const Eigen::MatrixX3i &triangles)
void setStreamingState(bool state)
void setLoopState(bool enabled)
void setBadChannels(const QStringList &bads)
void setThresholds(double min, double max)
Background worker for real-time sensor data streaming.
void setMappingMatrix(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mat)
void newRtSensorColors(const QString &surfaceKey, const QVector< uint32_t > &colors)
void newRtRawSensorData(const Eigen::VectorXf &data)
Background worker for computing sensor field mapping matrices.
void newEegMappingAvailable(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
void newMegMappingAvailable(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
Single averaged evoked response: time axis, data, baseline, channel info and averaging metadata.