52 using namespace Eigen;
61 #define MALLOC_2(x,t) (t *)malloc((x)*sizeof(t))
62 #define REALLOC_2(x,y,t) (t *)((x == NULL) ? malloc((y)*sizeof(t)) : realloc((x),(y)*sizeof(t)))
63 #define FREE_2(x) if ((char *)(x) != NULL) free((char *)(x))
85 using namespace FWDLIB;
91 FwdEegSphereModelSet::FwdEegSphereModelSet()
105 FwdEegSphereModelSet::~FwdEegSphereModelSet()
107 for (
int k = 0;
k < this->nmodel();
k++)
108 delete this->models[
k];
146 static const int def_nlayer = 4;
147 VectorXf def_unit_rads(def_nlayer);
148 def_unit_rads << 0.90f,0.92f,0.97f,1.0f;
149 VectorXf def_sigmas(def_nlayer);
150 def_sigmas << 0.33f,1.0f,0.4e-2f,0.33f;
152 return FwdEegSphereModelSet::fwd_add_to_eeg_sphere_model_set(s,FwdEegSphereModel::fwd_create_eeg_sphere_model(
"Default",
153 def_nlayer,def_unit_rads,def_sigmas));
170 now = fwd_add_default_eeg_sphere_model(now);
172 if (filename.isEmpty())
175 QFile t_file(filename);
176 if (!t_file.isReadable())
179 if ((fp = fopen(filename.toUtf8().data(),
"r")) == NULL) {
180 printf(filename.toUtf8().data());
183 while (fgets(line,MAXLINE,fp) != NULL) {
186 one = strtok(line,SEP);
188 if (tag.isEmpty() || tag.size() == 0)
191 name = QString(
"%1 %2").arg(one).arg(tag);
194 one = strtok(NULL,SEP);
197 two = strtok(NULL,SEP);
200 rads.resize(nlayer+1);
201 sigmas.resize(nlayer+1);
202 if (sscanf(one,
"%g",rads[nlayer]) != 1) {
206 if (sscanf(two,
"%g",sigmas[nlayer]) != 1) {
213 now = fwd_add_to_eeg_sphere_model_set(now,FwdEegSphereModel::fwd_create_eeg_sphere_model(name,nlayer,rads,sigmas));
218 printf(filename.toUtf8().data());
238 QString name(
"Default");
240 if (!p_sName.isEmpty())
243 if (this->nmodel() == 0) {
244 printf(
"No EEG sphere model definitions available");
248 for (
k = 0;
k < this->nmodel();
k++) {
249 if (this->models[
k]->name.compare(name) == 0) {
250 printf(
"Selected model: %s\n",this->models[
k]->name.toUtf8().constData());
254 printf(
"EEG sphere model %s not found.",name.toUtf8().constData());
260 void FwdEegSphereModelSet::fwd_list_eeg_sphere_models(FILE *f)
265 if ( this->nmodel() < 0 )
267 fprintf(f,
"Available EEG sphere models:\n");
268 for (
k = 0;
k < this->nmodel();
k++) {
269 this_model = this->models[
k];
270 fprintf(f,
"\t%s : %d",this_model->
name.toUtf8().constData(),this_model->nlayer());
271 for (p = 0; p < this_model->nlayer(); p++)
272 fprintf(f,
" : %7.3f : %7.3f",this_model->
layers[p].rel_rad,this_model->
layers[p].sigma);