38 #ifndef RTFIFFRAWVIEWMODEL_H
39 #define RTFIFFRAWVIEWMODEL_H
45 #include "../../disp_global.h"
58 #include <QAbstractTableModel>
59 #include <QSharedPointer>
67 #include <Eigen/SparseCore>
92 typedef QPair<const double*,qint32> RowVectorPair;
93 typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> MatrixXdR;
106 typedef QSharedPointer<RtFiffRawViewModel>
SPtr;
107 typedef QSharedPointer<const RtFiffRawViewModel>
ConstSPtr;
132 virtual int rowCount(
const QModelIndex &parent = QModelIndex())
const ;
142 virtual int columnCount(
const QModelIndex &parent = QModelIndex())
const;
153 virtual QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
165 virtual QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const;
173 void setFiffInfo(QSharedPointer<FIFFLIB::FiffInfo>& p_pFiffInfo);
183 void setSamplingInfo(
float sps,
int T,
bool bSetZero =
false);
191 Eigen::MatrixXd getLastBlock();
199 void addData(
const QList<Eigen::MatrixXd> &data);
209 FIFFLIB::fiff_int_t getKind(qint32 row)
const;
219 FIFFLIB::fiff_int_t getUnit(qint32 row)
const;
229 FIFFLIB::fiff_int_t getCoil(qint32 row)
const;
237 inline qint32 getMaxSamples()
const;
245 inline qint32 getCurrentSampleIndex()
const;
255 inline double getLastBlockFirstValue(
int row)
const;
263 inline const QMap<qint32,qint32>& getIdxSelMap()
const;
271 void selectRows(
const QList<qint32> &selection);
279 void hideRows(
const QList<qint32> &selection);
285 void resetSelection();
293 void toggleFreeze(
const QModelIndex &index);
301 void setScaling(
const QMap< qint32,float >& p_qMapChScaling);
309 void updateProjection(
const QList<FIFFLIB::FiffProj>& projs);
317 void updateCompensator(
int to);
325 void updateSpharaActivation(
bool state);
335 void updateSpharaOptions(
const QString& sSytemType,
int nBaseFctsFirst,
int nBaseFctsSecond);
343 void setFilter(QList<RTPROCESSINGLIB::FilterKernel> filterData);
351 void setFilterActive(
bool state);
359 void setBackgroundColor(
const QColor& color);
367 void setFilterChannelType(
const QString &channelType);
375 void createFilterChannelList(QStringList channelNames);
384 void markChBad(QModelIndex ch,
bool status);
393 void markChBad(QModelIndexList chlist,
bool status);
404 void triggerInfoChanged(
const QMap<double, QColor>& colorMap,
bool active, QString triggerCh,
double threshold);
412 void distanceTimeSpacerChanged(
int value);
418 void resetTriggerCounter();
426 inline qint32 numVLines()
const;
434 inline bool isFreezed()
const;
442 inline const QMap< qint32,float >& getScaling()
const;
450 inline QList<QPair<int,double> > getDetectedTriggers()
const;
458 inline QList<QPair<int, double> > getDetectedTriggersOld()
const;
466 inline QMap<double, QColor> getTriggerColor()
const;
474 inline int getNumberOfTimeSpacers()
const;
482 inline double getTriggerThreshold()
const;
490 inline QString getTriggerName()
const;
498 inline int getCurrentTriggerIndex()
const;
506 inline bool triggerDetectionActive()
const;
514 inline int getCurrentOverlapAddDelay()
const;
522 inline int getFirstSampleOffset()
const;
531 double getMaxValueFromRawViewModel(
int row)
const;
539 void addEvent(
int iSample);
550 std::unique_ptr<std::vector<EVENTSLIB::Event> > getEventsToDisplay(
int iBegin,
int iEnd)
const;
559 static void doFilterPerChannelRTMSA(QPair<QList<RTPROCESSINGLIB::FilterKernel>,QPair<int,Eigen::RowVectorXd> > &channelDataTime);
565 void filterDataBlock();
574 void filterDataBlock(
const Eigen::MatrixXd &data,
int iDataIndex);
582 bool m_bProjActivated;
583 bool m_bCompActivated;
584 bool m_bSpharaActivated;
586 bool m_bDrawFilterFront;
587 bool m_bPerformFiltering;
588 bool m_bTriggerDetectionActive;
590 double m_dTriggerThreshold;
592 qint32 m_iDownsampling;
593 qint32 m_iMaxSamples;
594 qint32 m_iCurrentSample;
595 qint32 m_iCurrentStartingSample;
596 qint32 m_iCurrentSampleFreeze;
597 qint32 m_iMaxFilterLength;
598 qint32 m_iCurrentBlockSize;
600 int m_iCurrentTriggerChIndex;
601 int m_iDistanceTimerSpacer;
602 int m_iDetectedTriggers;
604 QString m_sCurrentTriggerCh;
605 QString m_sFilterChannelType;
607 QSharedPointer<FIFFLIB::FiffInfo> m_pFiffInfo;
609 Eigen::RowVectorXi m_vecBadIdcs;
610 Eigen::VectorXd m_vecLastBlockFirstValuesFiltered;
611 Eigen::VectorXd m_vecLastBlockFirstValuesRaw;
613 MatrixXdR m_matDataRaw;
614 MatrixXdR m_matDataFiltered;
615 MatrixXdR m_matDataRawFreeze;
616 MatrixXdR m_matDataFilteredFreeze;
617 Eigen::MatrixXd m_matOverlap;
619 Eigen::VectorXi m_vecIndicesFirstVV;
620 Eigen::VectorXi m_vecIndicesSecondVV;
621 Eigen::VectorXi m_vecIndicesFirstBabyMEG;
622 Eigen::VectorXi m_vecIndicesSecondBabyMEG;
623 Eigen::VectorXi m_vecIndicesFirstEEG;
625 Eigen::SparseMatrix<double> m_matSparseSpharaMult;
626 Eigen::SparseMatrix<double> m_matSparseProjCompMult;
627 Eigen::SparseMatrix<double> m_matSparseProjMult;
628 Eigen::SparseMatrix<double> m_matSparseCompMult;
630 Eigen::MatrixXd m_matProj;
631 Eigen::MatrixXd m_matComp;
633 Eigen::MatrixXd m_matSpharaVVGradLoaded;
634 Eigen::MatrixXd m_matSpharaVVMagLoaded;
635 Eigen::MatrixXd m_matSpharaBabyMEGInnerLoaded;
636 Eigen::MatrixXd m_matSpharaBabyMEGOuterLoaded;
637 Eigen::MatrixXd m_matSpharaEEGLoaded;
639 QMap<double, QColor> m_qMapTriggerColor;
640 QMap<int,QList<QPair<int,double> > >m_qMapDetectedTrigger;
641 QList<int> m_lTriggerChannelIndices;
642 QMap<int,QList<QPair<int,double> > >m_qMapDetectedTriggerFreeze;
643 QMap<int,QList<QPair<int,double> > >m_qMapDetectedTriggerOld;
644 QMap<int,QList<QPair<int,double> > >m_qMapDetectedTriggerOldFreeze;
645 QMap<qint32,float> m_qMapChScaling;
646 QList<RTPROCESSINGLIB::FilterKernel>m_filterKernel;
647 QStringList m_filterChannelList;
648 QStringList m_visibleChannelList;
649 QMap<qint32,qint32> m_qMapIdxRowSelection;
651 QColor m_colBackground;
662 void newSelection(
const QList<qint32>& selection);
670 void windowSizeChanged(
int windowSize);
676 void triggerDetected(
int numberDetectedTriggers,
const QMap<
int,QList<QPair<int,double> > >& mapDetectedTriggers);
685 return m_iMaxSamples;
693 return m_iCurrentSampleFreeze;
696 if(!m_filterKernel.isEmpty() && m_bPerformFiltering) {
697 return m_iCurrentSample-m_iMaxFilterLength/2;
700 return m_iCurrentSample;
707 if(row>m_vecLastBlockFirstValuesFiltered.rows() || row>m_vecLastBlockFirstValuesRaw.rows())
710 if(!m_filterKernel.isEmpty())
711 return m_vecLastBlockFirstValuesFiltered[row];
713 return m_vecLastBlockFirstValuesRaw[row];
720 return m_qMapIdxRowSelection;
741 return m_qMapChScaling;
748 if(m_bTriggerDetectionActive) {
749 return m_qMapTriggerColor;
752 QMap<double, QColor> map;
760 QList<QPair<int,double> > triggerIndices;
763 return m_qMapDetectedTriggerFreeze[m_iCurrentTriggerChIndex];
765 if(m_bTriggerDetectionActive) {
766 return m_qMapDetectedTrigger[m_iCurrentTriggerChIndex];
769 return triggerIndices;
776 QList<QPair<int,double> > triggerIndices;
779 return m_qMapDetectedTriggerOldFreeze[m_iCurrentTriggerChIndex];
781 if(m_bTriggerDetectionActive) {
782 return m_qMapDetectedTriggerOld[m_iCurrentTriggerChIndex];
785 return triggerIndices;
793 return ((1000)/m_iDistanceTimerSpacer)-1;
800 return m_dTriggerThreshold;
807 return m_sCurrentTriggerCh;
814 return m_iCurrentTriggerChIndex;
821 return m_bTriggerDetectionActive;
828 if(!m_filterKernel.isEmpty())
829 return m_iMaxFilterLength/2;
838 return m_iCurrentStartingSample;
842 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
843 #ifndef metatype_rowvectorpair
844 #define metatype_rowvectorpair
849 #endif // RTFIFFRAWVIEWMODEL_H