50 #include <QtCore/QtPlugin>
53 #include <QtConcurrent/QtConcurrentMap>
76 , m_bReceiveData(false)
77 , m_bProcessData(false)
93 QSharedPointer<IPlugin> RtSss::clone()
const
95 QSharedPointer<RtSss> pRtSssClone(
new RtSss);
107 qDebug() <<
"*********** Initialization ************";
110 if(!m_pRtSssBuffer.isNull())
115 connect(m_pRTMSAInput.data(), &PluginInputConnector::notify,
this, &RtSss::update, Qt::DirectConnection);
148 qDebug() <<
"*********** Start ************";
159 qDebug() <<
"*********** Stop *************";
161 m_bIsRunning =
false;
164 QThread::terminate();
168 m_pRtSssBuffer->
clear();
170 m_bReceiveData =
false;
186 QString RtSss::getName()
const
188 return "RtSss Toolbox";
194 QWidget* RtSss::setupWidget()
196 qDebug() <<
"*********** SetUpWidget ************";
200 connect(widget, &RtSssSetupWidget::signalNewLinRR,
this, &RtSss::setLinRR);
201 connect(widget, &RtSssSetupWidget::signalNewLoutRR,
this, &RtSss::setLoutRR);
202 connect(widget, &RtSssSetupWidget::signalNewLin,
this, &RtSss::setLin);
203 connect(widget, &RtSssSetupWidget::signalNewLout,
this, &RtSss::setLout);
205 LinRR = widget->getLinRR();
206 LoutRR = widget->getLoutRR();
207 Lin = widget->getLin();
208 Lout = widget->getLout();
214 void RtSss::setLinRR(
int val)
220 void RtSss::setLoutRR(
int val)
226 void RtSss::setLin(
int val)
232 void RtSss::setLout(
int val)
246 if(pRTMSA && m_bReceiveData)
254 m_pFiffInfo = pRTMSA->info();
259 for(
unsigned char i = 0; i < pRTMSA->getMultiArraySize(); ++i)
261 in_mat = pRTMSA->getMultiSampleArray()[i];
262 m_pRtSssBuffer->
push(&in_mat);
272 MatrixXd rt_sss(
const MatrixXd &p_mat)
275 out = rsss.getSSSRR(p_mat);
291 m_bReceiveData =
true;
299 m_pRTMSAOutput->data()->initFromFiffInfo(m_pFiffInfo);
300 m_pRTMSAOutput->data()->setMultiArraySize(100);
302 m_pRTMSAOutput->data()->setVisibility(
true);
305 rsss.setMEGInfo(m_pFiffInfo);
308 qint32 nmegchan = rsss.getNumMEGChan();
309 qint32 nmegchanused = rsss.getNumMEGChanUsed();
310 qDebug() <<
"number of meg channels(run): " << nmegchan;
311 VectorXi badch = rsss.getBadChan();
314 qDebug() <<
"LinRR (run): " << LinRR <<
", LoutRR (run): " << LoutRR <<
", Lin (run): " << Lin <<
", Lout (run): " << Lout;
316 expOrder << LinRR << LoutRR << Lin << Lout;
317 rsss.setSSSParameter(expOrder);
339 qint32 startID_MEGch = 0;
340 for(qint32 i = 0; i < m_pFiffInfo->nchan; ++i)
341 if(m_pFiffInfo->chs[i].kind == FIFFV_MEG_CH)
349 qDebug() <<
"building SSS linear equation .....";
350 lineqn = rsss.buildLinearEqn();
352 qDebug() <<
"..finished !!";
355 m_bProcessData =
true;
356 qint32 HEADMOV_COR_cnt = 15 ;
358 qDebug() <<
"rtSSS started.....";
360 bool m_bIsHeadMov =
true;
366 lineqn = rsss.buildLinearEqn();
367 qDebug() <<
"rebuilt SSS linear equation .....";
375 qint16 nrows = m_pRtSssBuffer->
rows();
380 MatrixXd in_mat = m_pRtSssBuffer->
pop();
384 MatrixXd in_mat_used(nmegchanused, in_mat.cols());
386 for(qint32 i = 0, k = 0; i < nmegchan; ++i)
389 in_mat_used.row(k) = in_mat.row(i);
396 QList<MatrixXd> list_in_mat;
397 qint32 nSubSample = 20;
398 qint32 nThread = in_mat.cols() / nSubSample;
400 for(qint32 ith = 0; ith < nThread; ++ ith)
401 list_in_mat.append(in_mat_used.block(0,ith*nSubSample,nmegchanused,nSubSample));
403 QFuture<MatrixXd> res = QtConcurrent::mapped(list_in_mat, rt_sss);
404 res.waitForFinished();
406 for(qint32 ith = 0; ith < nThread; ++ ith)
407 in_mat_used.block(0,ith*nSubSample,nmegchanused,nSubSample)= res.resultAt(ith);
410 for(qint32 i = 0, k = 0; i < nmegchan; ++i)
413 in_mat.row(i) = in_mat_used.row(k);
418 for(qint32 i = 0; i <in_mat.cols(); ++i)
419 m_pRTMSAOutput->data()->setValue(1e7 * in_mat.col(i));
427 m_bProcessData =
false;
428 m_bReceiveData =
false;
429 qDebug() <<
"rtSSS stopped.";
OutputConnectorList m_outputConnectors
Contains the declaration of the RtSssAlgo class.
The RtSss class provides a rtsss algorithm structure.
QSharedPointer< CircularMatrixBuffer > SPtr
The circular matrix buffer.
void push(const Matrix< _Tp, Dynamic, Dynamic > *pMatrix)
Matrix< _Tp, Dynamic, Dynamic > pop()
QSharedPointer< NewMeasurement > SPtr
Contains the declaration of the RTSSS class.
static QSharedPointer< PluginOutputData< T > > create(IPlugin *parent, const QString &name, const QString &descr)
InputConnectorList m_inputConnectors
The RealTimeMultiSampleArrayNew class is the base class of every RealTimeMultiSampleArrayNew Measurem...