56 using namespace DISPLIB;
57 using namespace FIFFLIB;
58 using namespace Eigen;
65 : QAbstractTableModel(parent)
69 , m_bInitialized(false)
80 if(!m_qMapIdxRowSelection.empty())
81 return m_qMapIdxRowSelection.size();
97 if(role != Qt::DisplayRole && role != Qt::BackgroundRole)
100 if (index.isValid()) {
101 qint32 r = m_qMapIdxRowSelection[index.row()];
104 if(index.column() == 0 && role == Qt::DisplayRole)
106 return QVariant(m_pFiffInfo->chs[r].ch_name);
109 if(index.column()==1) {
113 case Qt::DisplayRole: {
120 vec = m_dataCurrentFreeze.row(r);
126 vec = m_dataCurrent.row(r);
132 case Qt::BackgroundRole: {
157 if(role != Qt::DisplayRole && role != Qt::TextAlignmentRole)
160 if(orientation == Qt::Horizontal) {
166 case Qt::DisplayRole:
167 return QVariant(
"data plot");
168 case Qt::TextAlignmentRole:
169 return QVariant(Qt::AlignLeft);
171 return QVariant(
"data plot");
174 else if(orientation == Qt::Vertical) {
175 QModelIndex chname = createIndex(section,0);
177 case Qt::DisplayRole:
178 return QVariant(
data(chname).toString());
200 m_iScaleType = ScaleType;
207 m_dataCurrent =
data;
209 if(m_vecFreqScale.size() != m_dataCurrent.cols() && m_pFiffInfo)
211 double freqRes = (m_pFiffInfo->sfreq/2) / m_dataCurrent.cols();
213 m_vecFreqScale.resize(1,m_dataCurrent.cols());
216 for(qint32 i = 0; i < m_dataCurrent.cols(); ++i)
219 m_vecFreqScale[i] = log10(currFreq+
k);
221 m_vecFreqScale[i] = currFreq;
226 double max = m_vecFreqScale.maxCoeff();
227 m_vecFreqScale /= max;
229 m_vecFreqScaleBound = m_vecFreqScale;
231 m_iUpperFrqIdx = m_vecFreqScale.size()-1;
233 m_bInitialized =
true;
237 QModelIndex topLeft = this->index(0,1);
238 QModelIndex bottomRight = this->index(m_dataCurrent.rows()-1,1);
239 QVector<int> roles; roles << Qt::DisplayRole;
240 emit dataChanged(topLeft, bottomRight, roles);
249 m_qMapIdxRowSelection.clear();
252 for(qint32 i = 0; i < selection.size(); ++i)
254 if(selection[i] < m_pFiffInfo->chs.size())
256 m_qMapIdxRowSelection.insert(count,selection[i]);
272 m_qMapIdxRowSelection.clear();
274 for(qint32 i = 0; i < m_pFiffInfo->chs.size(); ++i)
275 m_qMapIdxRowSelection.insert(i,i);
286 m_bIsFreezed = !m_bIsFreezed;
289 m_dataCurrentFreeze = m_dataCurrent;
292 QModelIndex topLeft = this->index(0,1);
293 QModelIndex bottomRight = this->index(m_dataCurrent.rows()-1,1);
294 QVector<int> roles; roles << Qt::DisplayRole;
295 emit dataChanged(topLeft, bottomRight, roles);
302 if(!m_bInitialized) {
308 double nf = m_pFiffInfo->sfreq/2;
311 m_iUpperFrqIdx = m_vecFreqScale.size()-1;
314 for(qint32 i = 0; i < m_vecFreqScale.size(); ++i) {
315 float val = m_vecFreqScale[i]*nf;
316 if(val < fLowerFrqBound) {
320 if( val > fUpperFrqBound) {
327 m_vecFreqScaleBound = m_vecFreqScale;
328 for(qint32 i = 0; i < m_vecFreqScaleBound.size(); ++i) {
329 m_vecFreqScaleBound[i] = (m_vecFreqScaleBound[i] - m_vecFreqScale[m_iLowerFrqIdx]) / (m_vecFreqScale[m_iUpperFrqIdx] - m_vecFreqScale[m_iLowerFrqIdx]);