Hello! I have an already trained classifier and a I need to load it only once, when pressing play to the scenario. I'm using a Matlab Scripting Box, and I want to know if it should be loaded in the "Initialize" script of the box and declared as global (an how to use it after that) or if I should do it in the "Process" script.
Thank you!
Defining a trained classifier as a global variable in Matlab
-
- Posts: 775
- Joined: Tue Dec 04, 2012 3:53 pm
- Location: INRIA Rennes, FRANCE
Re: Defining a trained classifier as a global variable in Ma
Hello Eli,
global variables can get a bit messy, so I recommend doing it like this,
For reference, the global variable solution would look like
In any case, if you have a premade classifier, you should definitely load/build it in initialize unless you have some reason to do it in process.
Hope this helps,
Jussi
global variables can get a bit messy, so I recommend doing it like this,
Code: Select all
% in initialize.m
box_in.user_data.classifier = myClassifier; % store your loaded classifier
box_out = box_in; % pass it out to openvibe
% in process.m
myClassifier = box_in.user_data.classifier; % take the classifier from openvibe
% use it somehow
For reference, the global variable solution would look like
Code: Select all
% in initialize.m
global myClassifier;
% do something to initialize it, load from disk or whatever
% in process.m
global myClassifier;
% use it somehow
Hope this helps,
Jussi
Re: Defining a trained classifier as a global variable in Ma
Thank you! It helps a lot!!jtlindgren wrote:Hello Eli,
global variables can get a bit messy, so I recommend doing it like this,
Code: Select all
% in initialize.m box_in.user_data.classifier = myClassifier; % store your loaded classifier box_out = box_in; % pass it out to openvibe % in process.m myClassifier = box_in.user_data.classifier; % take the classifier from openvibe % use it somehow
For reference, the global variable solution would look like
In any case, if you have a premade classifier, you should definitely load/build it in initialize unless you have some reason to do it in process.Code: Select all
% in initialize.m global myClassifier; % do something to initialize it, load from disk or whatever % in process.m global myClassifier; % use it somehow
Hope this helps,
Jussi