36 m_pWorkerThread =
new QThread(
this);
37 m_pWorker->moveToThread(m_pWorkerThread);
40 connect(m_pWorkerThread, &QThread::finished, m_pWorker, &QObject::deleteLater);
49 m_pTimer =
new QTimer(
this);
50 m_pTimer->setTimerType(Qt::PreciseTimer);
54 m_pWorkerThread->start();
58 m_pInterpThread =
new QThread(
this);
59 m_pInterpWorker->moveToThread(m_pInterpThread);
61 connect(m_pInterpThread, &QThread::finished, m_pInterpWorker, &QObject::deleteLater);
65 this, &RtSensorDataController::onNewMegMapping);
67 this, &RtSensorDataController::onNewEegMapping);
69 m_pInterpThread->start();
71 qDebug() <<
"RtSensorDataController: Initialized with" << m_iTimeInterval <<
"ms interval";
84 if (m_pWorkerThread) {
85 m_pWorkerThread->quit();
86 m_pWorkerThread->wait();
90 if (m_pInterpThread) {
91 m_pInterpThread->quit();
92 m_pInterpThread->wait();
102 m_pWorker->addData(data);
111 m_pWorker->setMappingMatrix(mat);
119 m_bIsStreaming = state;
122 m_pTimer->start(m_iTimeInterval);
123 qDebug() <<
"RtSensorDataController: Streaming started at" << m_iTimeInterval <<
"ms interval";
126 qDebug() <<
"RtSensorDataController: Streaming stopped";
134 return m_bIsStreaming;
141 m_iTimeInterval = qMax(1, msec);
143 if (m_bIsStreaming) {
144 m_pTimer->setInterval(m_iTimeInterval);
147 qDebug() <<
"RtSensorDataController: Time interval set to" << m_iTimeInterval <<
"ms";
155 m_pWorker->setNumberAverages(numAvr);
164 m_pWorker->setColormapType(name);
173 m_pWorker->setThresholds(min, max);
182 m_pWorker->setLoopState(enabled);
191 m_pWorker->setSFreq(sFreq);
209 m_pWorker->setStreamSmoothedData(bStreamSmoothedData);
219 if (m_pInterpWorker) {
220 m_pInterpWorker->setEvoked(evoked);
227 bool applySensorTrans)
229 if (m_pInterpWorker) {
230 m_pInterpWorker->setTransform(trans, applySensorTrans);
238 if (m_pInterpWorker) {
239 m_pInterpWorker->setMegFieldMapOnHead(onHead);
246 const Eigen::MatrixX3f &vertices,
247 const Eigen::MatrixX3f &normals,
248 const Eigen::MatrixX3i &triangles)
250 if (m_pInterpWorker) {
251 m_pInterpWorker->setMegSurface(surfaceKey, vertices, normals, triangles);
258 const Eigen::MatrixX3f &vertices)
260 if (m_pInterpWorker) {
261 m_pInterpWorker->setEegSurface(surfaceKey, vertices);
269 if (m_pInterpWorker) {
270 m_pInterpWorker->setBadChannels(bads);
278 if (m_pInterpWorker) {
281 QMetaObject::invokeMethod(m_pInterpWorker,
"computeMapping", Qt::QueuedConnection);
287void RtSensorDataController::onNewMegMapping(
const QString &surfaceKey,
288 std::shared_ptr<Eigen::MatrixXf> mappingMat,
289 const QVector<int> &pick)
292 if (m_pWorker && mappingMat) {
299 qDebug() <<
"RtSensorDataController: New MEG mapping received and forwarded"
300 <<
"(" << mappingMat->rows() <<
"x" << mappingMat->cols() <<
")";
305void RtSensorDataController::onNewEegMapping(
const QString &surfaceKey,
306 std::shared_ptr<Eigen::MatrixXf> mappingMat,
307 const QVector<int> &pick)
310 if (m_pWorker && mappingMat) {
311 m_pWorker->setMappingMatrix(mappingMat);
317 qDebug() <<
"RtSensorDataController: New EEG mapping received and forwarded"
318 <<
"(" << 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...
void setMegFieldMapOnHead(bool onHead)
void newSensorColorsAvailable(const QString &surfaceKey, const QVector< uint32_t > &colors)
~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 setStreamingState(bool state)
void setEegSurface(const QString &surfaceKey, const Eigen::MatrixX3f &vertices)
void newMegMappingAvailable(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
void setMappingMatrix(std::shared_ptr< Eigen::MatrixXf > mat)
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 newEegMappingAvailable(const QString &surfaceKey, std::shared_ptr< Eigen::MatrixXf > mappingMat, const QVector< int > &pick)
void setTimeInterval(int msec)
void setSFreq(double sFreq)
RtSensorDataController(QObject *parent=nullptr)
void setNumberAverages(int numAvr)
void setThresholds(double min, double max)
Background worker for real-time sensor data streaming.
void newRtSensorColors(const QString &surfaceKey, const QVector< uint32_t > &colors)
void setMappingMatrix(std::shared_ptr< Eigen::MatrixXf > mat)
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.