7 #include "../CEBLModel.hpp"
11 #include "../TextUtils.hpp"
30 current_session =
new Session();
35 delete current_session;
50 this->updateSession();
51 current_session->
save();
57 this->updateSession();
58 current_session->
save(filename.c_str());
63 current_session->
load(filename.c_str());
72 string SessionManager::encodeKey(
string str)
74 std::replace(str.begin(), str.end(),
' ',
'_');
78 string SessionManager::decodeKey(
string str)
80 std::replace(str.begin(), str.end(),
'_',
' ');
90 void SessionManager::updateModel()
92 using namespace TextUtils;
100 s.setCurrentSection(
"data_source");
101 if(s.exists(
"source"))
103 int temp = s.get<
int>(
"source");
106 if(s.exists(
"stored_buffer"))
108 EEGData temp = s.get<ublas::matrix<double> >(
"stored_buffer");
109 m.getDataSource()->setDataBuffer(temp);
114 s.setCurrentSection(
"data_process");
115 if(s.exists(
"reference_enabled"))
117 bool temp = s.get<
bool>(
"reference_enabled");
118 m.processSetReferenceEnabled(temp);
120 if(s.exists(
"remove_enabled"))
122 bool temp = s.get<
bool>(
"remove_enabled");
123 m.processSetRemoveEnabled(temp);
125 if(s.exists(
"filter_enabled"))
127 bool temp = s.get<
bool>(
"filter_enabled");
128 m.processSetFilterEnabled(temp);
133 s.setCurrentSection(
"channels");
134 if(s.exists(
"configuration_string"))
136 string temp = s.get<
string>(
"configuration_string");
137 m.channelsSetConfigurationFromString(temp);
142 s.setCurrentSection(
"training");
143 if(s.exists(
"training_data_is_loaded"))
145 bool temp = s.get<
bool>(
"training_data_is_loaded");
146 m.getTraining()->setDataIsLoaded(temp);
149 if(s.exists(
"training_data"))
152 m.getTraining()->setTrainingData(temp);
156 if(s.exists(
"num_classes"))
158 int temp = s.
get<
int>(
"num_classes");
159 m.trainingSetNumClasses(temp);
161 if(s.exists(
"num_sequences"))
163 int temp = s.get<
int>(
"num_sequences");
164 m.trainingSetNumSequences(temp);
166 if(s.exists(
"sequence_length"))
168 int temp = s.get<
int>(
"sequence_length");
169 m.trainingSetSequenceLength(temp);
171 if(s.exists(
"pause_length"))
173 int temp = s.get<
int>(
"pause_length");
174 m.trainingSetPauseLength(temp);
177 if(s.exists(
"class_labels"))
179 std::vector<string> temp = s.get<std::vector<string> >(
"class_labels");
180 m.trainingSetClassLabels(temp);
186 s.setCurrentSection(
"features");
187 if(s.exists(
"selected"))
189 string temp = s.get<
string>(
"selected");
190 m.featuresSetSelected(temp);
196 if(s.exists(
"names"))
198 vector<string> names;
199 s.get(
"names",&names);
200 for(
unsigned i=0;i<names.size();i++)
204 p->
load(s.get<map<string, SerializedObject> >(encodeKey(names[i])
213 s.setCurrentSection(
"classifiers");
214 if(s.exists(
"selected"))
216 string temp = s.get<
string>(
"selected");
217 m.classifiersSetSelected(temp);
223 if(s.exists(
"names"))
225 vector<string> names;
226 s.get(
"names",&names);
227 for(
unsigned i=0;i<names.size();i++)
231 p->
load(s.get<map<string, SerializedObject> >(encodeKey(names[i])
239 s.setCurrentSection(
"decision");
240 if(s.exists(
"selected"))
242 string temp = s.get<
string>(
"selected");
243 m.decisionSetSelected(temp);
249 if(s.exists(
"names"))
251 vector<string> names;
252 s.get(
"names",&names);
253 for(
unsigned i=0;i<names.size();i++)
257 p->
load(s.get<map<string, SerializedObject> >(encodeKey(names[i])
265 s.setCurrentSection(
"filter");
266 if(s.exists(
"selected"))
268 string temp = s.get<
string>(
"selected");
269 m.filterSetSelected(temp);
273 int temp = s.get<
int>(
"lags");
274 m.filterSetNumLags(temp);
276 if(s.exists(
"components"))
278 string temp = s.get<
string>(
"components");
279 m.filterSetSelectedComponentsString(temp);
286 if(s.exists(
"names"))
288 vector<string> names;
289 s.get(
"names",&names);
290 for(
unsigned i=0;i<names.size();i++)
294 p->
load(s.get<map<string, SerializedObject> >(encodeKey(names[i])
303 void SessionManager::updateSession()
354 vector<string> names = plugins->
getNames();
359 for(
unsigned i=0;i<names.size();i++)
361 s(encodeKey(names[i]) +
"_internals",
370 vector<string> names = plugins->
getNames();
375 for(
unsigned i=0;i<names.size();i++)
377 s(encodeKey(names[i]) +
"_internals",
387 vector<string> names = plugins->
getNames();
394 for(
unsigned i=0;i<names.size();i++)
396 s(encodeKey(names[i]) +
"_internals",
406 vector<string> names = plugins->
getNames();
411 for(
unsigned i=0;i<names.size();i++)
413 s(encodeKey(names[i]) +
"_internals",