v2.0.0
Loading...
Searching...
No Matches
fwd_eeg_sphere_model_set.cpp
Go to the documentation of this file.
1//=============================================================================================================
15
16//=============================================================================================================
17// INCLUDES
18//=============================================================================================================
19
21
22//=============================================================================================================
23// QT INCLUDES
24//=============================================================================================================
25
26#include <QString>
27#include <QFile>
28#include <QRegularExpression>
29#include <QTextStream>
30
31#include <Eigen/Core>
32
33using namespace Eigen;
34
35//=============================================================================================================
36// USED NAMESPACES
37//=============================================================================================================
38
39using namespace FWDLIB;
40
41//=============================================================================================================
42// DEFINE MEMBER METHODS
43//=============================================================================================================
44
48
49//=============================================================================================================
50
54
55//=============================================================================================================
56
65
66//=============================================================================================================
67//fwd_eeg_sphere_models.c
69{
70 static const int def_nlayer = 4;
71 VectorXf def_unit_rads(def_nlayer);
72 def_unit_rads << 0.90f,0.92f,0.97f,1.0f;
73 VectorXf def_sigmas(def_nlayer);
74 def_sigmas << 0.33f,1.0f,0.4e-2f,0.33f;
75
77 def_nlayer,def_unit_rads,def_sigmas));
78}
79
80//=============================================================================================================
81//fwd_eeg_sphere_models.c
83{
84 if (!now)
86
87 if (filename.isEmpty())
88 return now;
89
90 QFile file(filename);
91 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
92 return now;
93
94 QTextStream in(&file);
95 QString name;
96 VectorXf rads;
97 VectorXf sigmas;
98 int nlayer = 0;
99
100 while (!in.atEnd()) {
101 QString line = in.readLine().trimmed();
102 if (line.isEmpty() || line.startsWith('#'))
103 continue;
104
105 QStringList parts = line.split(QRegularExpression("[:\\n\\r]"), Qt::SkipEmptyParts);
106 if (parts.isEmpty())
107 continue;
108
109 name = parts[0].trimmed();
110 nlayer = 0;
111
112 for (int i = 1; i + 1 < parts.size(); i += 2) {
113 bool okRad = false, okSig = false;
114 float r = parts[i].trimmed().toFloat(&okRad);
115 float s = parts[i + 1].trimmed().toFloat(&okSig);
116 if (!okRad || !okSig)
117 break;
118 rads.conservativeResize(nlayer + 1);
119 sigmas.conservativeResize(nlayer + 1);
120 rads[nlayer] = r;
121 sigmas[nlayer] = s;
122 nlayer++;
123 }
124 if (nlayer > 0)
126 }
127 return now;
128}
129
130//=============================================================================================================
131//fwd_eeg_sphere_models.c
133{
134 QString name("Default");
135
136 if (!p_sName.isEmpty())
137 name = p_sName;
138
139 if (this->nmodel() == 0) {
140 qWarning("No EEG sphere model definitions available");
141 return nullptr;
142 }
143
144 for (int k = 0; k < this->nmodel(); k++) {
145 if (this->models[k]->name.compare(name) == 0) {
146 qInfo("Selected model: %s",this->models[k]->name.toUtf8().constData());
147 return new FwdEegSphereModel(*(this->models[k]));
148 }
149 }
150 qWarning("EEG sphere model %s not found.",name.toUtf8().constData());
151 return nullptr;
152}
153
154//=============================================================================================================
155//dipole_fit_setup.c
157{
158 if (this->nmodel() <= 0)
159 return;
160 qInfo("Available EEG sphere models:");
161 for (int k = 0; k < this->nmodel(); k++) {
162 FwdEegSphereModel* this_model = this->models[k].get();
163 QString line = QString("\t%1 : %2").arg(this_model->name).arg(this_model->nlayer());
164 for (int p = 0; p < this_model->nlayer(); p++)
165 line += QString(" : %1 : %2").arg(this_model->layers[p].rel_rad, 7, 'f', 3).arg(this_model->layers[p].sigma, 7, 'f', 3);
166 qInfo("%s", line.toUtf8().constData());
167 }
168}
169
Named container of FwdEegSphereModel objects loaded from an mne_setup_eeg_sphere_model parameter file...
Forward modelling — BEM solver, spherical models, sensor/coil definitions and the lead-field assembly...
Definition compute_fwd.h:83
Multi-shell concentric-sphere head model holding the Berg-Scherg equivalent-source parameters that ac...
static FwdEegSphereModel::UPtr fwd_create_eeg_sphere_model(const QString &name, int nlayer, const Eigen::VectorXf &rads, const Eigen::VectorXf &sigmas)
std::vector< FwdEegSphereLayer > layers
std::unique_ptr< FwdEegSphereModel > UPtr
FwdEegSphereModel * fwd_select_eeg_sphere_model(const QString &p_sName)
static FwdEegSphereModelSet * fwd_add_default_eeg_sphere_model(FwdEegSphereModelSet *s)
static FwdEegSphereModelSet * fwd_add_to_eeg_sphere_model_set(FwdEegSphereModelSet *s, FwdEegSphereModel::UPtr m)
static FwdEegSphereModelSet * fwd_load_eeg_sphere_models(const QString &p_sFileName, FwdEegSphereModelSet *now)
std::vector< FwdEegSphereModel::UPtr > models