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