[Eeglablist] Using the 'command' field of eeg_plot to reject trials

Mikołaj Magnuski imponderabilion at gmail.com
Sat Jun 28 00:15:47 PDT 2014


Dear Matthew and Makoto,

synchronizing with base workspace eeglab GUI usually requires a bit more
(unless you want to change your function into a script).
The easiest way is to declare relevant eeglab variables as globals at the
beginning of the function (EEG, ALLEEG, etc. - whatever eeglab variables
you are using and want to sync with workspace gui). For example:
global EEG

Unfortunately, using globals is usually frowned upon by programmers (for
good reasons) but I don't think you should worry too much when using
globals in small applications.

Another way however would be to assign (see assignin docummentation)
relevant eeglab variables in the base workspace and evaluate (see evalin)
eeglab GUI commands in the base workspace too.

Try globals first. EEGlab declares most (if not all) of the all-caps base
workspace variables as globals and synchronizes the gui functions (at least
some of them) with the workspace this way - so you should be fine with
global variables (from my experience - using globals is the easiest and
most efficient way of creating and synchronizing GUI data in matlab without
blocking the command window with uiwait( ) etc. ).
28 cze 2014 05:35 "Makoto Miyakoshi" <mmiyakoshi at ucsd.edu> napisał(a):

> Dear Matthew,
>
> Looks like you want to automate the epoch rejection process.
>
> > My problem may be that I can't seem to find how to load the eeglab
> workspace variables, other than through the gui.
>
> I recommend you replace all eegData in your code to EEG for the sake of
> simplicity. As long as they are 'EEG' by typing 'eeglab redraw' you can
> interact with it through EEGLAB main GUI.
>
> To load data, use EEG = pop_loadset()... of course you can do eegData =
> pop_loadset()... but again using 'EEG' allows you to interact it via GUI.
>
> Makoto
>
>
> On Tue, Jun 24, 2014 at 9:44 PM, Matthew Moore <matthew.moore at otago.ac.nz>
> wrote:
>
>>  Hi,
>>
>> I am having a bit of trouble getting eegplot to allow inspection and
>> editing of candidates for rejection.
>>
>> I have looked at this thread:
>> http://sccn.ucsd.edu/pipermail/eeglablist/2011/004085.html
>>
>> I tried to implement the command listed there, but am having trouble. My
>> problem may be that I can't seem to find how to load the eeglab workspace
>> variables, other than through the gui.
>>
>> I would really appreciate if someone could have a look at the code and
>> give me some pointers.
>>
>> Matt
>>
>> function cleanedEEGData = detectArtefacts(eegData,locFile)
>> %DETECTARTEFACTS Detects artefactual data using EEGLAB's functions, then
>> %   displays the data in a plot for the user to check.
>> %   Returns the eegData with artefactual trials removed.
>> %   locFile is the file containing electrode locations.
>>
>>     epochLength=eegData.xmax;
>>     epochTimeFrames=eegData.pnts;
>>     sampleRate=eegData.srate;
>>     events=eegData.event;
>>     nElec=eegData.nbchan;
>>
>>     %Absolute limit of electrode values in uV
>>     lowerLimit=-150;
>>     upperLimit=150;
>>
>>     %Maximum slope over an epoch in uV/epoch
>>     maxSlope=60;
>>     rVal=0.3;
>>
>>     %Reject unlikely epochs, by number of SDs
>>     sdJPSingleChan=4;
>>     sdJPAllChans=4;
>>
>>     %Reject abnormal distributions, by number of SDs
>>     sdKurtSingleChan=4;
>>     sdKurtAllChans=4;
>>
>>     %Reject abnormal spectra
>>     thresholds=[-50 50;-100 25];
>>     frequencies=[0 2;20 40];
>>
>>     %Do the error detecting.
>>
>> eegData=pop_eegthresh(eegData,1,1:nElec,lowerLimit,upperLimit,0,epochLength,1,0,0);
>>
>> eegData=pop_rejtrend(eegData,1,1:nElec,epochTimeFrames,maxSlope,rVal,1,0,0);
>>
>> eegData=pop_jointprob(eegData,1,1:nElec,sdJPSingleChan,sdJPAllChans,1,0);
>>
>> eegData=pop_rejkurt(eegData,1,1:nElec,sdKurtSingleChan,sdKurtAllChans,1,0);
>> %     eegData=pop_rejspec( eegData,
>> 1,'elecrange',1:30,'threshold',thresholds,'freqlimits',frequencies,'eegplotcom','','eegplotplotallrej',1,'eegplotreject',0,'specdata',eegData.specdata);
>>
>>     %Get the format for marking trials in an eegplot
>>
>> plotRejThr=trial2eegplot(eegData.reject.rejthresh,eegData.reject.rejthreshE,epochTimeFrames,eegData.reject.rejthreshcol);
>>
>> plotRejTre=trial2eegplot(eegData.reject.rejconst,eegData.reject.rejconstE,epochTimeFrames,eegData.reject.rejconstcol);
>>     plotRejJp
>> =trial2eegplot(eegData.reject.rejjp,eegData.reject.rejjpE,epochTimeFrames,eegData.reject.rejjpcol);
>>
>> plotRejKur=trial2eegplot(eegData.reject.rejkurt,eegData.reject.rejkurtE,epochTimeFrames,eegData.reject.rejkurtcol);
>> %
>> rejSpe=trial2eegplot(eegData.reject.rejfreq,eegData.reject.rejfreqE,epochTimeFrames,eegData.reject.rejfreqcol);
>>
>>     %Put the reject candidates in one array.
>>     rejE=[plotRejThr;plotRejTre;plotRejJp;plotRejKur];%;rejSpe];
>>
>>     %command string for reject marked trials... all marked epochs...
>>     %from http://sccn.ucsd.edu/pipermail/eeglablist/2011/004085.html
>>     cmd = [ ...
>>     '[tmprej tmprejE] = eegplot2trial( TMPREJ,EEG.pnts,EEG.trials);' ...
>>     '[EEGTMP LASTCOM] = pop_rejepoch(EEG, tmprej, 1);' ...
>>     'if ~isempty(LASTCOM),'...
>>     ' [ALLEEG EEG CURRENTSET tmpcom] = pop_newset(ALLEEG, EEGTMP,
>> CURRENTSET);' ...
>>     ' if ~isempty(tmpcom),' ...
>>     '  EEG = eegh(LASTCOM, EEG);' ...
>>     '  eegh(tmpcom);' ...
>>     '  eeglab(''redraw'');' ...
>>     ' end;' ...
>>     'end;' ...
>>     'clear EEGTMP tmpcom;' ...
>>     ] ;
>>
>>     %Draw the data.
>>     eegplot(eegData.data,...
>>         'eloc_file',locFile,...
>>         'srate',sampleRate,...
>>         'events',events,...
>>         'winrej',rejE,...
>>         'command',cmd,...
>>         'butlabel','Reject');
>>
>>
>> end
>>
>>
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Makoto Miyakoshi
> Swartz Center for Computational Neuroscience
> Institute for Neural Computation, University of California San Diego
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20140628/7ac5a885/attachment-0001.html>


More information about the eeglablist mailing list