<p dir="ltr">Dear Matthew and Makoto,</p>
<p dir="ltr">synchronizing with base workspace eeglab GUI usually requires a bit more (unless you want to change your function into a script).<br>
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:<br>
global EEG</p>
<p dir="ltr">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.</p>
<p dir="ltr">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.</p>
<p dir="ltr">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. ).</p>
<div class="gmail_quote">28 cze 2014 05:35 "Makoto Miyakoshi" <<a href="mailto:mmiyakoshi@ucsd.edu">mmiyakoshi@ucsd.edu</a>> napisał(a):<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Dear Matthew,<div><br></div><div>Looks like you want to automate the epoch rejection process.</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:Tahoma;font-size:13.142857551574707px">> My problem may be that I can't seem to find how to load the eeglab workspace variables, other than through the gui.</span><br>
</div><div><span style="color:rgb(0,0,0);font-family:Tahoma;font-size:13.142857551574707px"><br></span></div><div>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.</div>
<div><br></div><div>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.</div><div><br></div><div>Makoto</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Jun 24, 2014 at 9:44 PM, Matthew Moore <span dir="ltr"><<a href="mailto:matthew.moore@otago.ac.nz" target="_blank">matthew.moore@otago.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi,<br>
<br>
I am having a bit of trouble getting eegplot to allow inspection and editing of candidates for rejection.<br>
<br>
I have looked at this thread: <a href="http://sccn.ucsd.edu/pipermail/eeglablist/2011/004085.html" target="_blank">
http://sccn.ucsd.edu/pipermail/eeglablist/2011/004085.html</a><br>
<br>
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.<br>
<br>
I would really appreciate if someone could have a look at the code and give me some pointers.<br>
<br>
Matt<br>
<font face="Courier New"><br>
function cleanedEEGData = detectArtefacts(eegData,locFile)<br>
%DETECTARTEFACTS Detects artefactual data using EEGLAB's functions, then<br>
% displays the data in a plot for the user to check.<br>
% Returns the eegData with artefactual trials removed.<br>
% locFile is the file containing electrode locations.<br>
<br>
epochLength=eegData.xmax;<br>
epochTimeFrames=eegData.pnts;<br>
sampleRate=eegData.srate;<br>
events=eegData.event;<br>
nElec=eegData.nbchan;<br>
<br>
%Absolute limit of electrode values in uV<br>
lowerLimit=-150;<br>
upperLimit=150;<br>
<br>
%Maximum slope over an epoch in uV/epoch<br>
maxSlope=60;<br>
rVal=0.3;<br>
<br>
%Reject unlikely epochs, by number of SDs<br>
sdJPSingleChan=4;<br>
sdJPAllChans=4;<br>
<br>
%Reject abnormal distributions, by number of SDs<br>
sdKurtSingleChan=4;<br>
sdKurtAllChans=4;<br>
<br>
%Reject abnormal spectra<br>
thresholds=[-50 50;-100 25];<br>
frequencies=[0 2;20 40];<br>
<br>
%Do the error detecting.<br>
eegData=pop_eegthresh(eegData,1,1:nElec,lowerLimit,upperLimit,0,epochLength,1,0,0);<br>
eegData=pop_rejtrend(eegData,1,1:nElec,epochTimeFrames,maxSlope,rVal,1,0,0);<br>
eegData=pop_jointprob(eegData,1,1:nElec,sdJPSingleChan,sdJPAllChans,1,0);<br>
eegData=pop_rejkurt(eegData,1,1:nElec,sdKurtSingleChan,sdKurtAllChans,1,0);<br>
% eegData=pop_rejspec( eegData, 1,'elecrange',1:30,'threshold',thresholds,'freqlimits',frequencies,'eegplotcom','','eegplotplotallrej',1,'eegplotreject',0,'specdata',eegData.specdata);<br>
<br>
%Get the format for marking trials in an eegplot<br>
plotRejThr=trial2eegplot(eegData.reject.rejthresh,eegData.reject.rejthreshE,epochTimeFrames,eegData.reject.rejthreshcol);<br>
plotRejTre=trial2eegplot(eegData.reject.rejconst,eegData.reject.rejconstE,epochTimeFrames,eegData.reject.rejconstcol);<br>
plotRejJp =trial2eegplot(eegData.reject.rejjp,eegData.reject.rejjpE,epochTimeFrames,eegData.reject.rejjpcol);<br>
plotRejKur=trial2eegplot(eegData.reject.rejkurt,eegData.reject.rejkurtE,epochTimeFrames,eegData.reject.rejkurtcol);<br>
% rejSpe=trial2eegplot(eegData.reject.rejfreq,eegData.reject.rejfreqE,epochTimeFrames,eegData.reject.rejfreqcol);<br>
<br>
%Put the reject candidates in one array.<br>
rejE=[plotRejThr;plotRejTre;plotRejJp;plotRejKur];%;rejSpe];<br>
<br>
%command string for reject marked trials... all marked epochs...<br>
%from <a href="http://sccn.ucsd.edu/pipermail/eeglablist/2011/004085.html" target="_blank">http://sccn.ucsd.edu/pipermail/eeglablist/2011/004085.html</a><br>
cmd = [ ...<br>
'[tmprej tmprejE] = eegplot2trial( TMPREJ,EEG.pnts,EEG.trials);' ...<br>
'[EEGTMP LASTCOM] = pop_rejepoch(EEG, tmprej, 1);' ...<br>
'if ~isempty(LASTCOM),'...<br>
' [ALLEEG EEG CURRENTSET tmpcom] = pop_newset(ALLEEG, EEGTMP, CURRENTSET);' ...<br>
' if ~isempty(tmpcom),' ...<br>
' EEG = eegh(LASTCOM, EEG);' ...<br>
' eegh(tmpcom);' ...<br>
' eeglab(''redraw'');' ...<br>
' end;' ...<br>
'end;' ...<br>
'clear EEGTMP tmpcom;' ...<br>
] ;<br>
<br>
%Draw the data.<br>
eegplot(eegData.data,...<br>
'eloc_file',locFile,...<br>
'srate',sampleRate,...<br>
'events',events,...<br>
'winrej',rejE,...<br>
'command',cmd,...<br>
'butlabel','Reject');<br>
<br>
<br>
end</font><br>
<br>
</div>
</div>
<br>_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">eeglablist-request@sccn.ucsd.edu</a><br></blockquote></div><br><br clear="all">
<div><br></div>
-- <br><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div>
</div>
<br>_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu">eeglablist-request@sccn.ucsd.edu</a><br></blockquote></div>