50 #include <QRegularExpression>
60 using namespace DISPLIB;
61 using namespace Eigen;
62 using namespace FIFFLIB;
68 ChannelInfoModel::ChannelInfoModel(
FiffInfo::SPtr& pFiffInfo, QObject *parent)
69 : QAbstractTableModel(parent)
70 , m_pFiffInfo(pFiffInfo)
72 setFiffInfo(m_pFiffInfo);
77 ChannelInfoModel::ChannelInfoModel(QObject *parent)
78 : QAbstractTableModel(parent)
96 int ChannelInfoModel::columnCount(
const QModelIndex & )
const
103 QVariant ChannelInfoModel::headerData(
int section, Qt::Orientation orientation,
int role)
const
105 if(role != Qt::DisplayRole && role != Qt::TextAlignmentRole)
110 case Qt::TextAlignmentRole:
111 a = Qt::AlignHCenter | Qt::AlignVCenter;
114 case Qt::DisplayRole: {
116 if(orientation == Qt::Vertical)
117 if(section<m_pFiffInfo->chs.size())
118 return QString(
"Ch %1").arg(section);
121 if(orientation == Qt::Horizontal) {
124 return QString(
"%1").arg(
"Data number");
128 return QString(
"%1").arg(
"Original name");
132 return QString(
"%1").arg(
"Alias");
136 return QString(
"%1").arg(
"Mapped layout name");
140 return QString(
"%1").arg(
"Channel kind");
144 return QString(
"%1").arg(
"MEG type");
148 return QString(
"%1").arg(
"Unit");
152 return QString(
"%1").arg(
"Position");
156 return QString(
"%1").arg(
"Digitizer (cm)");
160 return QString(
"%1").arg(
"Active filter");
164 return QString(
"%1").arg(
"Coil Type");
168 return QString(
"%1").arg(
"Bad channel");
172 return QString(
"%1").arg(
"# of Compensators");
184 QVariant ChannelInfoModel::data(
const QModelIndex &index,
int role)
const
189 if (index.isValid()) {
191 if(index.column()==0) {
195 case Qt::DisplayRole:
196 v.setValue(index.row());
199 case ChannelInfoModelRoles::GetChNumber:
200 v.setValue(index.row());
203 case Qt::TextAlignmentRole:
204 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
210 if(index.column()==1) {
214 case Qt::DisplayRole:
215 v.setValue(QString(
"%1").arg(
m_pFiffInfo->chs.at(index.row()).ch_name));
218 case ChannelInfoModelRoles::GetOrigChName:
219 v.setValue(QString(
"%1").arg(
m_pFiffInfo->chs.at(index.row()).ch_name));
222 case Qt::TextAlignmentRole:
223 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
229 if(index.column()==2) {
233 case Qt::DisplayRole:
235 v.setValue(QString(
"%1").arg(
m_aliasNames.at(index.row())));
238 case ChannelInfoModelRoles::GetChAlias:
240 v.setValue(QString(
"%1").arg(
m_aliasNames.at(index.row())));
243 case Qt::TextAlignmentRole:
244 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
250 if(index.column()==3) {
254 case Qt::DisplayRole:
259 case ChannelInfoModelRoles::GetMappedLayoutChName:
264 case Qt::TextAlignmentRole:
265 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
271 if(index.column()==4) {
275 case Qt::DisplayRole:
276 v.setValue(QString(
"%1").arg(
m_pFiffInfo->chs.at(index.row()).kind));
279 case ChannelInfoModelRoles::GetChKind:
283 case Qt::TextAlignmentRole:
284 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
290 if(index.column()==5) {
293 v.setValue(QString(
"%1").arg(
"non_MEG"));
295 if(
m_pFiffInfo->chs.at(index.row()).kind == FIFFV_MEG_CH) {
296 qint32 unit =
m_pFiffInfo->chs.at(index.row()).unit;
297 if(unit == FIFF_UNIT_T_M)
298 v.setValue(QString(
"MEG_grad"));
299 else if(unit == FIFF_UNIT_T)
300 v.setValue(QString(
"MEG_mag"));
304 case Qt::DisplayRole:
307 case ChannelInfoModelRoles::GetMEGType:
310 case Qt::TextAlignmentRole:
311 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
317 if(index.column()==6) {
321 case Qt::DisplayRole:
322 v.setValue(QString(
"%1").arg(
m_pFiffInfo->chs.at(index.row()).unit));
325 case ChannelInfoModelRoles::GetChUnit:
329 case Qt::TextAlignmentRole:
330 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
336 if(index.column()==7) {
342 case Qt::DisplayRole:
343 v.setValue(QString(
"(%1|%2)").arg(point.x()).arg(point.y()));
346 case ChannelInfoModelRoles::GetChPosition:
350 case Qt::TextAlignmentRole:
351 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
357 if(index.column()==8) {
360 QVector3D point3D(
m_pFiffInfo->chs.at(index.row()).chpos.r0[0] * 100,
361 m_pFiffInfo->chs.at(index.row()).chpos.r0[1] * 100,
362 m_pFiffInfo->chs.at(index.row()).chpos.r0[2] * 100 );
365 case Qt::DisplayRole:
366 v.setValue(QString(
"(%1|%2|%3)").arg(point3D.x()).arg(point3D.y()).arg(point3D.z()));
369 case ChannelInfoModelRoles::GetChDigitizer:
373 case Qt::TextAlignmentRole:
374 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
380 if(index.column()==9) {
388 case Qt::DisplayRole: {
441 case Qt::TextAlignmentRole:
442 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
448 if(index.column()==10) {
452 case Qt::DisplayRole:
453 v.setValue(QString(
"%1").arg(
m_pFiffInfo->chs.at(index.row()).chpos.coil_type));
456 case ChannelInfoModelRoles::GetChCoilType:
457 v.setValue(
m_pFiffInfo->chs.at(index.row()).chpos.coil_type);
460 case Qt::TextAlignmentRole:
461 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
467 if(index.column()==11) {
470 QString chName =
m_pFiffInfo->chs.at(index.row()).ch_name;
473 case Qt::DisplayRole:
478 case ChannelInfoModelRoles::GetIsBad:
483 case Qt::TextAlignmentRole:
484 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
490 if(index.column()==12) {
494 case Qt::DisplayRole:
498 case Qt::TextAlignmentRole:
499 Qt::Alignment a = Qt::AlignHCenter | Qt::AlignVCenter;
510 bool ChannelInfoModel::insertRows(
int position,
int span,
const QModelIndex & parent)
521 bool ChannelInfoModel::removeRows(
int position,
int span,
const QModelIndex & parent)
532 Qt::ItemFlags ChannelInfoModel::flags(
const QModelIndex & index)
const
535 return Qt::ItemIsEnabled | Qt::ItemIsSelectable ;
540 bool ChannelInfoModel::setData(
const QModelIndex &index,
const QVariant &value,
int role)
563 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
576 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
593 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
631 for(
int i = 0; i<channelList.size(); i++) {
634 QString chName = chInfo.
ch_name;
635 QRegularExpression regExpRemove;
638 switch(chInfo.
kind) {
641 regExpRemove = QRegularExpression(
"(MEG|-|_|/|\| )");
642 chName.remove(regExpRemove);
652 regExpRemove = QRegularExpression(
"(EEG|-|_|/|\| )");
653 chName.remove(regExpRemove);
680 qDebug(
"ChannelInfoModel cleared.");