<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<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 http://sccn.ucsd.edu/pipermail/eeglablist/2011/004085.html<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>
</body>
</html>