51 #include <QtCore/QtPlugin>
52 #include <QtConcurrent>
73 , m_bReceiveData(false)
74 , m_bProcessData(false)
75 , m_bFinishedClustering(false)
76 , m_qFileFwdSolution(
"./MNE-sample-data/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif")
77 , m_sAtlasDir(
"./MNE-sample-data/subjects/sample/label")
78 , m_sSurfaceDir(
"./MNE-sample-data/subjects/sample/surf")
97 QSharedPointer<IPlugin> MNE::clone()
const
99 QSharedPointer<MNE> pMNEClone(
new MNE());
118 connect(m_pRTEInput.data(), &PluginInputConnector::notify,
this, &MNE::updateRTE, Qt::DirectConnection);
119 m_inputConnectors.append(m_pRTEInput);
122 connect(m_pRTCInput.data(), &PluginInputConnector::notify,
this, &MNE::updateRTC, Qt::DirectConnection);
123 m_inputConnectors.append(m_pRTCInput);
127 m_outputConnectors.append(m_pRTSEOutput);
128 m_pRTSEOutput->data()->setName(this->getName());
130 m_pRTSEOutput->data()->setAnnotSet(m_pAnnotationSet);
131 m_pRTSEOutput->data()->setSurfSet(m_pSurfaceSet);
134 QFuture<void> future = QtConcurrent::run(
this, &MNE::doClustering);
149 void MNE::calcFiffInfo()
151 QMutexLocker locker(&m_qMutex);
152 if(m_qListCovChNames.size() > 0 && m_pFiffInfoEvoked && m_pFiffInfoForward)
154 qDebug() <<
"Fiff Infos available";
156 QStringList tmp_pick_ch_names;
157 foreach (
const QString &ch, m_pFiffInfoForward->ch_names)
159 if(m_pFiffInfoEvoked->ch_names.contains(ch))
160 tmp_pick_ch_names << ch;
163 m_qListPickChannels.clear();
165 foreach (
const QString &ch, tmp_pick_ch_names)
167 if(m_qListCovChNames.contains(ch))
168 m_qListPickChannels << ch;
171 RowVectorXi sel = m_pFiffInfoEvoked->pick_channels(m_qListPickChannels);
173 m_pFiffInfo = QSharedPointer<FiffInfo>(
new FiffInfo(m_pFiffInfoEvoked->pick_info(sel)));
181 void MNE::doClustering()
183 emit clusteringStarted();
186 m_bFinishedClustering =
false;
190 finishedClustering();
196 void MNE::finishedClustering()
199 m_bFinishedClustering =
true;
200 m_pFiffInfoForward = QSharedPointer<FiffInfoBase>(
new FiffInfoBase(m_pClusteredFwd->info));
203 emit clusteringFinished();
212 if(this->isRunning())
215 if(m_bFinishedClustering)
230 m_bIsRunning =
false;
232 if(m_pRtInvOp->isRunning())
237 m_qVecFiffEvoked.clear();
238 m_qVecFiffCov.clear();
241 m_qListCovChNames.clear();
244 m_bProcessData =
false;
246 m_bReceiveData =
false;
262 QString MNE::getName()
const
270 QWidget* MNE::setupWidget()
274 if(!m_bFinishedClustering)
277 connect(
this, &MNE::clusteringStarted, setupWidget, &MNESetupWidget::setClusteringState);
278 connect(
this, &MNE::clusteringFinished, setupWidget, &MNESetupWidget::setSetupState);
288 QSharedPointer<RealTimeCov> pRTC = pMeasurement.dynamicCast<
RealTimeCov>();
291 if(pRTC && m_bReceiveData)
294 if(m_qListCovChNames.size() != pRTC->getValue()->names.size())
295 m_qListCovChNames = pRTC->
getValue()->names;
300 m_qVecFiffCov.push_back(pRTC->getValue()->pick_channels(m_qListPickChannels));
312 QSharedPointer<RealTimeEvoked> pRTE = pMeasurement.dynamicCast<
RealTimeEvoked>();
314 QMutexLocker locker(&m_qMutex);
316 if(pRTE && m_bReceiveData)
319 if(!m_pFiffInfoEvoked)
320 m_pFiffInfoEvoked = QSharedPointer<FiffInfo>(
new FiffInfo(pRTE->getValue()->info));
323 m_qVecFiffEvoked.push_back(pRTE->getValue()->pick_channels(m_qListPickChannels));
335 double lambda2 = 1.0 / pow(snr, 2);
337 QString method(
"dSPM");
344 m_pMinimumNorm->doInverseSetup(m_iNumAverages,
false);
357 m_bReceiveData =
true;
366 QMutexLocker locker(&m_qMutex);
378 connect(m_pRtInvOp.data(), &RtInvOp::invOperatorCalculated,
this, &MNE::updateInvOp);
380 m_pMinimumNorm.reset();
390 m_bProcessData =
true;
392 qint32 skip_count = 0;
397 qint32 t_covSize = m_qVecFiffCov.size();
402 m_pRtInvOp->appendNoiseCov(m_qVecFiffCov[0]);
403 m_qVecFiffCov.pop_front();
408 qint32 t_evokedSize = m_qVecFiffEvoked.size();
412 if(m_pMinimumNorm && ((skip_count % 4) == 0))
415 FiffEvoked t_fiffEvoked = m_qVecFiffEvoked[0];
416 m_qVecFiffEvoked.pop_front();
419 float tmin = ((float)t_fiffEvoked.
first) / t_fiffEvoked.
info.
sfreq;
426 m_pRTSEOutput->
data()->setValue(sourceEstimate);
431 m_qVecFiffEvoked.pop_front();
The RealTimeMultiSampleArrayNew class is the base class of every RealTimeMultiSampleArrayNew Measurem...
FIFF measurement file information.
Real-time inverse operator estimation.
QSharedPointer< MinimumNorm > SPtr
QSharedPointer< MNEForwardSolution > SPtr
virtual FiffCov::SPtr & getValue()
QSharedPointer< SurfaceSet > SPtr
PluginOutputConnector with specified Measurement.
QSharedPointer< NewMeasurement > SPtr
QSharedPointer< AnnotationSet > SPtr
The RealTimeMultiSampleArrayNew class is the base class of every RealTimeMultiSampleArrayNew Measurem...
The MNE class provides wrapper functions to stay consistent with mne matlab toolbox.
A hemisphere set of surfaces.
QSharedPointer< MNEInverseOperator > SPtr
QSharedPointer< RtInvOp > SPtr