43 #include "chinfomodel.h"
59 ChInfoModel::ChInfoModel(QObject *parent)
60 : QAbstractTableModel(parent)
79 int ChInfoModel::columnCount(
const QModelIndex & )
const
87 QVariant ChInfoModel::headerData(
int section, Qt::Orientation orientation,
int role)
const
89 if(role != Qt::DisplayRole && role != Qt::TextAlignmentRole)
93 case Qt::TextAlignmentRole:
94 return Qt::AlignHCenter + Qt::AlignVCenter;
96 case Qt::DisplayRole: {
98 if(orientation == Qt::Vertical)
100 return QString(
"Ch %1").arg(section);
103 if(orientation == Qt::Horizontal) {
106 return QString(
"%1").arg(
"Data number");
110 return QString(
"%1").arg(
"Original name");
114 return QString(
"%1").arg(
"Alias");
118 return QString(
"%1").arg(
"Mapped layout name");
122 return QString(
"%1").arg(
"Channel kind");
126 return QString(
"%1").arg(
"MEG type");
130 return QString(
"%1").arg(
"Unit");
134 return QString(
"%1").arg(
"2D loc (cm)");
138 return QString(
"%1").arg(
"3D loc (cm)");
142 return QString(
"%1").arg(
"Active filter");
146 return QString(
"%1").arg(
"Coil Type");
159 QVariant ChInfoModel::data(
const QModelIndex &index,
int role)
const
164 if (index.isValid()) {
166 if(index.column()==0) {
170 case Qt::DisplayRole:
171 v.setValue(index.row());
174 case ChInfoModelRoles::GetChNumber:
175 v.setValue(index.row());
178 case Qt::TextAlignmentRole:
179 return Qt::AlignHCenter + Qt::AlignVCenter;
184 if(index.column()==1) {
188 case Qt::DisplayRole:
189 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).ch_name));
192 case ChInfoModelRoles::GetOrigChName:
193 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).ch_name));
196 case Qt::TextAlignmentRole:
197 return Qt::AlignHCenter + Qt::AlignVCenter;
202 if(index.column()==2) {
206 case Qt::DisplayRole:
207 v.setValue(QString(
"%1").arg(
m_aliasNames.at(index.row())));
210 case ChInfoModelRoles::GetChAlias:
214 case Qt::TextAlignmentRole:
215 return Qt::AlignHCenter + Qt::AlignVCenter;
220 if(index.column()==3) {
224 case Qt::DisplayRole:
228 case ChInfoModelRoles::GetMappedLayoutChName:
232 case Qt::TextAlignmentRole:
233 return Qt::AlignHCenter + Qt::AlignVCenter;
238 if(index.column()==4) {
242 case Qt::DisplayRole:
243 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).kind));
246 case ChInfoModelRoles::GetChKind:
250 case Qt::TextAlignmentRole:
251 return Qt::AlignHCenter + Qt::AlignVCenter;
256 if(index.column()==5) {
259 v.setValue(QString(
"%1").arg(
"non_MEG"));
264 v.setValue(QString(
"MEG_grad"));
265 else if(unit == FIFF_UNIT_T)
266 v.setValue(QString(
"MEG_mag"));
269 if(
m_fiffInfo.
chs.at(index.row()).kind == FIFFV_REF_MEG_CH) {
272 v.setValue(QString(
"MEG_grad_ref"));
273 else if(unit == FIFF_UNIT_T)
274 v.setValue(QString(
"MEG_mag_ref"));
278 case Qt::DisplayRole:
281 case ChInfoModelRoles::GetMEGType:
284 case Qt::TextAlignmentRole:
285 return Qt::AlignHCenter + Qt::AlignVCenter;
290 if(index.column()==6) {
294 case Qt::DisplayRole:
295 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).unit));
298 case ChInfoModelRoles::GetChUnit:
302 case Qt::TextAlignmentRole:
303 return Qt::AlignHCenter + Qt::AlignVCenter;
308 if(index.column()==7) {
314 case Qt::DisplayRole:
315 v.setValue(QString(
"(%1|%2)").arg(point.x()).arg(point.y()));
318 case ChInfoModelRoles::GetChPosition:
322 case Qt::TextAlignmentRole:
323 return Qt::AlignHCenter + Qt::AlignVCenter;
328 if(index.column()==8) {
331 QVector3D point3D(
m_fiffInfo.
chs.at(index.row()).loc(0,0) * 100,
336 case Qt::DisplayRole:
337 v.setValue(QString(
"(%1|%2|%3)").arg(point3D.x()).arg(point3D.y()).arg(point3D.z()));
340 case ChInfoModelRoles::GetChDigitizer:
344 case Qt::TextAlignmentRole:
345 return Qt::AlignHCenter + Qt::AlignVCenter;
350 if(index.column()==9) {
355 QSharedPointer<FilterOperator> filterOperator;
358 case Qt::DisplayRole: {
359 if(operatorPtr->m_OperatorType == MNEOperator::FILTER) {
363 v.setValue(QString(
"%1").arg(
"none"));
367 switch(filterOperator->m_Type) {
368 case FilterOperator::LPF: {
369 v.setValue(QString(
"%1 | %2").arg(
"LP").arg(filterOperator->m_dCenterFreq*
m_fiffInfo.
sfreq/2));
373 case FilterOperator::HPF: {
374 v.setValue(QString(
"%1 | %2").arg(
"HP").arg(filterOperator->m_dCenterFreq*
m_fiffInfo.
sfreq/2));
378 case FilterOperator::BPF: {
380 double low = (filterOperator->m_dCenterFreq*fsample/2) - (filterOperator->m_dBandwidth*fsample/4);
381 double high = (filterOperator->m_dCenterFreq*fsample/2) + (filterOperator->m_dBandwidth*fsample/4);
382 v.setValue(QString(
"%1 | %2 | %3").arg(
"BP").arg(low).arg(high));
386 case FilterOperator::NOTCH: {
388 double low = (filterOperator->m_dCenterFreq*fsample/2) - (filterOperator->m_dBandwidth*fsample/4);
389 double high = (filterOperator->m_dCenterFreq*fsample/2) + (filterOperator->m_dBandwidth*fsample/4);
390 v.setValue(QString(
"%1 | %2 | %3").arg(
"NOTCH").arg(low).arg(high));
396 case ChInfoModelRoles::GetChActiveFilter: {
397 if(operatorPtr->m_OperatorType == MNEOperator::FILTER) {
401 v.setValue(QString(
"%1").arg(
"none"));
405 v.setValue(operatorPtr);
409 case Qt::TextAlignmentRole:
410 return Qt::AlignHCenter + Qt::AlignVCenter;
415 if(index.column()==10) {
419 case Qt::DisplayRole:
420 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).coil_type));
423 case ChInfoModelRoles::GetChCoilType:
427 case Qt::TextAlignmentRole:
428 return Qt::AlignHCenter + Qt::AlignVCenter;
439 bool ChInfoModel::insertRows(
int position,
int span,
const QModelIndex & parent)
451 bool ChInfoModel::removeRows(
int position,
int span,
const QModelIndex & parent)
463 Qt::ItemFlags ChInfoModel::flags(
const QModelIndex & index)
const
466 return Qt::ItemIsEnabled | Qt::ItemIsSelectable ;
472 bool ChInfoModel::setData(
const QModelIndex &index,
const QVariant &value,
int role)
496 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
510 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
528 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
564 for(
int i = 0; i<channelList.size(); i++) {
567 QString chName = chInfo.
ch_name;
568 QRegExp regExpRemove;
571 switch(chInfo.
kind) {
574 regExpRemove = QRegExp(
"(MEG|-|_|/|\| )");
575 chName.remove(regExpRemove);
583 case FIFFV_REF_MEG_CH:
585 regExpRemove = QRegExp(
"(MEG|-|_|/|\| )");
586 chName.remove(regExpRemove);
596 regExpRemove = QRegExp(
"(EEG|-|_|/|\| )");
597 chName.remove(regExpRemove);
625 qDebug(
"ChInfoModel cleared.");
void fiffInfoChanged(const FiffInfo &fiffInfo)
FIFF measurement file information.
QMap< int, QSharedPointer< MNEOperator > > m_assignedOperators
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
QMap< QString, QPointF > m_layoutMap
void layoutChanged(const QMap< QString, QPointF > &layoutMap)
void assignedOperatorsChanged(const QMap< int, QSharedPointer< MNEOperator > > &assignedOperators)
void mapLayoutToChannels()
const QStringList & getMappedChannelsList()
void channelsMappedToLayout(const QStringList &mappedLayoutChNames)
QStringList m_mappedLayoutChNames
int getIndexFromMappedChName(QString chName)
int getIndexFromOrigChName(QString chName)