MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
fsannotationtreeitem.cpp
Go to the documentation of this file.
1//=============================================================================================================
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
40#include "../common/metatreeitem.h"
41
42#include <fs/label.h>
43#include <fs/surface.h>
44#include <fs/annotation.h>
45
46//=============================================================================================================
47// QT INCLUDES
48//=============================================================================================================
49
50//=============================================================================================================
51// EIGEN INCLUDES
52//=============================================================================================================
53
54//=============================================================================================================
55// USED NAMESPACES
56//=============================================================================================================
57
58using namespace DISP3DLIB;
59using namespace FSLIB;
60using namespace Eigen;
61
62//=============================================================================================================
63// DEFINE MEMBER METHODS
64//=============================================================================================================
65
66FsAnnotationTreeItem::FsAnnotationTreeItem(int iType, const QString & text)
67: AbstractTreeItem(iType, text)
68{
69 initItem();
70}
71
72//=============================================================================================================
73
75{
76 this->setEditable(false);
77 this->setCheckable(true);
78 this->setCheckState(Qt::Unchecked);
79 this->setToolTip("Freesurfer annotation item");
80}
81
82//=============================================================================================================
83
84void FsAnnotationTreeItem::addData(const Surface& tSurface, const Annotation& tAnnotation)
85{
86 //Create color from annotation data if annotation is not empty
87 if(!tAnnotation.isEmpty()) {
88 MatrixX4f matAnnotColors(tAnnotation.getVertices().rows(), 4);
89
90 QList<FSLIB::Label> qListLabels;
91 QList<RowVector4i> qListLabelRGBAs;
92
93 tAnnotation.toLabels(tSurface, qListLabels, qListLabelRGBAs);
94
95 for(int i = 0; i < qListLabels.size(); ++i) {
96 FSLIB::Label label = qListLabels.at(i);
97 for(int j = 0; j<label.vertices.rows(); j++) {
98 QColor patchColor;
99 patchColor.setRed(qListLabelRGBAs.at(i)(0));
100 patchColor.setGreen(qListLabelRGBAs.at(i)(1));
101 patchColor.setBlue(qListLabelRGBAs.at(i)(2));
102
103 patchColor = patchColor.darker(200);
104
105 if(label.vertices(j) < matAnnotColors.rows()) {
106 matAnnotColors(label.vertices(j),0) = patchColor.redF();
107 matAnnotColors(label.vertices(j),1) = patchColor.greenF();
108 matAnnotColors(label.vertices(j),2) = patchColor.blueF();
109 matAnnotColors(label.vertices(j),3) = patchColor.alphaF();
110 }
111 }
112 }
113
114 //Add data which is held by this FsAnnotationTreeItem
115 QVariant data;
116 data.setValue(matAnnotColors);
117 this->setData(data, Data3DTreeModelItemRoles::AnnotColors);
118
119 //Add annotation meta information as item children
120 QList<QStandardItem*> list;
121
122 MetaTreeItem *itemAnnotFileName = new MetaTreeItem(MetaTreeItemTypes::FileName, tAnnotation.fileName());
123 itemAnnotFileName->setEditable(false);
124 list << itemAnnotFileName;
125 list << new QStandardItem(itemAnnotFileName->toolTip());
126 this->appendRow(list);
127 data.setValue(tAnnotation.fileName());
128 itemAnnotFileName->setData(data, Data3DTreeModelItemRoles::FileName);
129
130 list.clear();
131 MetaTreeItem *itemAnnotPath = new MetaTreeItem(MetaTreeItemTypes::FilePath, tAnnotation.filePath());
132 itemAnnotPath->setEditable(false);
133 list << itemAnnotPath;
134 list << new QStandardItem(itemAnnotPath->toolTip());
135 this->appendRow(list);
136 data.setValue(tAnnotation.filePath());
137 itemAnnotFileName->setData(data, Data3DTreeModelItemRoles::FilePath);
138 }
139}
140
141//=============================================================================================================
142
143void FsAnnotationTreeItem::onCheckStateChanged(const Qt::CheckState& checkState)
144{
145 emit annotationVisibiltyChanged(checkState==Qt::Unchecked ? false : true);
146}
147
Label class declaration.
Annotation class declaration.
Surface class declaration.
FsAnnotationTreeItem class declaration.
Provides the basic tree item.
void setData(const QVariant &value, int role=Qt::UserRole+1)
Provides a generic brain tree item.
void setData(const QVariant &value, int role=Qt::UserRole+1)
virtual void onCheckStateChanged(const Qt::CheckState &checkState)
FsAnnotationTreeItem(int iType=Data3DTreeModelItemTypes::AnnotationItem, const QString &text="Annotation")
void annotationVisibiltyChanged(bool isVisible)
void addData(const FSLIB::Surface &tSurface, const FSLIB::Annotation &tAnnotation)
Free surfer annotation.
Definition annotation.h:81
bool toLabels(const Surface &p_surf, QList< Label > &p_qListLabels, QList< Eigen::RowVector4i > &p_qListLabelRGBAs, const QStringList &lLabelPicks=QStringList()) const
QString filePath() const
Definition annotation.h:343
Eigen::VectorXi & getVertices()
Definition annotation.h:301
bool isEmpty() const
Definition annotation.h:294
QString fileName() const
Definition annotation.h:350
Freesurfer/MNE label.
Definition label.h:81
Eigen::VectorXi vertices
Definition label.h:166
FreeSurfer surface mesh.
Definition surface.h:76