MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
mne_cluster_info.cpp
Go to the documentation of this file.
1//=============================================================================================================
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "mne_cluster_info.h"
43
44//=============================================================================================================
45// QT INCLUDES
46//=============================================================================================================
47
48#include <QFile>
49#include <QTextStream>
50
51//=============================================================================================================
52// USED NAMESPACES
53//=============================================================================================================
54
55using namespace MNELIB;
56
57//=============================================================================================================
58// DEFINE MEMBER METHODS
59//=============================================================================================================
60
64
65//=============================================================================================================
66
68{
69 clusterLabelNames.clear();
70 clusterLabelIds.clear();
71 centroidVertno.clear();
72 centroidSource_rr.clear();
73 clusterVertnos.clear();
74 clusterSource_rr.clear();
75 clusterDistances.clear();
76}
77
78//=============================================================================================================
79
80void MNEClusterInfo::write(QString p_sFileName) const
81{
82 QFile file("./"+p_sFileName);
83 if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
84 qDebug("Unable to open file.");
85 return;
86 }
87 QTextStream out(&file);
88 out << "MNE Cluster Info\n";
89
90 for(qint32 i = 0; i < clusterLabelIds.size(); ++i)
91 {
92 out << "\nLabel : " << clusterLabelNames[i] << "\n";
93 out << "Label ID : " << clusterLabelIds[i] << "\n";
94 out << "Centroid Vertno : " << centroidVertno[i] << "\n";
95 out << "Centroid rr : " << centroidSource_rr[i](0) << ", " << clusterSource_rr[i](1) << ", " << clusterSource_rr[i](2) << "\n";
96 out << "Vertnos :\n";
97 for(qint32 j = 0; j < clusterVertnos[i].size(); ++j)
98 out << clusterVertnos[i][j] << ", ";
99 out << "\nDistances :\n";
100 for(qint32 j = 0; j < clusterDistances[i].size(); ++j)
101 out << clusterDistances[i][j] << ", ";
102 out << "\nrr :\n";
103 for(qint32 j = 0; j < clusterSource_rr[i].rows(); ++j)
104 out << clusterSource_rr[i](j,0) << ", " << clusterSource_rr[i](j,1) << ", " << clusterSource_rr[i](j,2) << "\n";
105
106 out << "\n";
107 }
108
109 // optional, as QFile destructor will already do it:
110 file.close();
111
112 QFile file_centroids("./centroids_"+p_sFileName);
113
114 if(file_centroids.open(QIODevice::WriteOnly | QIODevice::Text)) {
115 QTextStream out_centroids(&file_centroids);
116
117 for(qint32 i = 0; i < clusterLabelIds.size(); ++i)
118 out_centroids << centroidVertno[i] << ", ";
119
120 // optional, as QFile destructor will already do it:
121 file_centroids.close();
122 }
123}
MNEClusterInfo class declaration, which provides cluster information.
QList< Eigen::VectorXd > clusterDistances
QList< QString > clusterLabelNames
QList< qint32 > clusterLabelIds
QList< Eigen::MatrixX3f > clusterSource_rr
QList< Eigen::VectorXi > clusterVertnos
void write(QString p_sFileName) const
QList< qint32 > centroidVertno
QList< Eigen::Vector3f > centroidSource_rr