[Eeglablist] Using EEGLAB from within a function

Andreas Widmann widmann at uni-leipzig.de
Mon Jan 27 00:53:12 PST 2014


Hi David,

try to find an introduction on variable scope in MATLAB, e.g. here
http://www.ieee-uffc.org/ultrasonics/software/MATLAB/Lecture2/Lecture2_6.htm
or here
http://msenux.redwoods.edu/Math4Textbook/Programming/VariableScope.pdf

You cannot modify a workspace variable from within a function (without using global what is usually not recommended due to unexpected side effects). EEGLAB’s ALLEEG and EEG are workspace variables.

Berry’s example should guide you on the right track, however, there is either a pop_newset or eeg_store command missing before eeglab -redraw.
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET)
or
[ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);

Best,
Andreas

Am 24.01.2014 um 23:03 schrieb berry van den berg <berryv.dberg at gmail.com>:

> Hi David, 
> 
> I would use something like: 
> 
> function dataOut = loadData(dataPath,filename)
>   dataOut = pop_loadbv(dataPath,fileName);
> end
>  
> then outside the function call
> EEG = loadData(dataPath,filename)
> eeglab -redraw
> 
> cheers,
> 
> 
> 
> On 24 January 2014 03:41, David Kaufman <david.kaufman at gmx.de> wrote:
> Hello everyone,
> 
> I'm trying to use EEGLAB from within a function inside a script, e.g.
> 
> function test
>     [ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
>     EEG = pop_loadbv(baseFolder, eegFile);     
>     [ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET)
>     eeglab redraw       
> end
> 
> Unfortunatly, as soon as the function returns my data set is not present in the GUI. If I put the contents of the above function in the root script the data set appears in the GUI.
> 
> Is it possible to call EEGLAB from a function and also see the data set or am I using EEGLAB wrong?
> 
> Regards,
> David Kaufman
> 
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> 
> 
> 
> -- 
> Berry van den Berg
> berryv.dberg at gmail.com
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu





More information about the eeglablist mailing list