Hi Jess,<br><br>What you could do is rewrite the events (so that the name of an event has the name of the next event concatenated to it), and then epoch based on the rewritten events. It would look something like this (I haven't tested this exact code):<br>
<span style="color:rgb(0,102,0)"><br><span style="font-family:courier new,monospace">% Loop through epochs until the second-to-last epoch<br>for i=1:length(EEG.epoch)-1<br></span></span><div style="margin-left:40px"><span style="color:rgb(0,102,0)"><span style="font-family:courier new,monospace">% Concatenate the epochtype of the next epoch to the epochtype of this epoch, with a space in between<br>
</span></span></div><div style="margin-left:40px"><span style="color:rgb(0,102,0)"><span style="font-family:courier new,monospace">EEG.epoch(i).type = [ EEG.epoch(i).type ' ' EEG.epoch(i+1).type ];<br></span></span></div>
<span style="color:rgb(0,102,0)"><span style="font-family:courier new,monospace">end;</span></span><br><br>After that, you could select epochs 'S 1 S 4' using pop_epoch().<br><br>An alternative would be to use ERPLAB, which I hear has nice options for conditional trial selection like this. I haven't used ERPLAB myself, so this loop would be my suggestion for a brute-force way to do it in EEGLAB.<br>
<br>Best,<br>Seve<br><br><div class="gmail_quote">On Thu, Nov 15, 2012 at 8:34 AM, Jess <span dir="ltr"><<a href="mailto:jhartcher@tuebingen.mpg.de" target="_blank">jhartcher@tuebingen.mpg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I want to select epochs based on whether marker S 1 is followed by a response marker S 4. I have 1000 S 1 markers but i only want to extract the 80 S 1 markers followed by S 4 markers, in a time window of [-200 500] . If I use the eeg_getepochevent.m function then I have the problem that it does not appear to be able to select the particular marker combinations that I need.<br>

<br>
I have tried to write a separate loop to do this and then use the pop_epoch.m function but then I have the problem that the segmented data is not part of the EEG struct array anymore.<br>
<br>
Is there a function that can do this? I think if I had to select the 80 conditional S 1 markers by hand this would not be optimal.<br>
<br>
Maybe it is clearer what I want to do if you see my code in which I have loaded and filtered my .set data:<br>
<br>
%%%%%%%%%%%%%%% Step 1: identify and extract marker times%%%%%%%%%%%%<br>
<br>
n_events = length(EEG.event);<br>
<br>
% declare empty arrays for storing event latencies<br>
latency1 = [];<br>
latency2 = [];<br>
<br>
for go = 1:n_events<br>
<br>
   % find S1/S2 and S4 combinations<br>
   check1 = (strcmp(EEG.event(go).type, 'S  1') && strcmp(EEG.event(go+1).type, 'S  4'));<br>
   check2 = (strcmp(EEG.event(go).type, 'S  2') && strcmp(EEG.event(go+1).type, 'S  4'));<br>
<br>
   % store times at which combination S 1 & S 4 occurs<br>
   if check1 == 1<br>
       latency1 = [latency1; EEG.event(go).latency*1/EEG.srate];<br>
   end<br>
<br>
   % store times at which combination S 2 & S 4 occurs<br>
   if check2 == 1<br>
       latency2 = [latency2; EEG.event(go).latency*1/EEG.srate];<br>
   end<br>
<br>
end<br>
<br>
<br>
%%%%%%%%%%%%%%%%%%%%%%%step 2 - not using EEGlab functions but epoching according to the Marker combinations%%%%%%%%%%<br>
% S1<br>
for go = 1:length(latency1)<br>
<br>
   % retrieve marker time<br>
   t_marker = latency1(go);<br>
<br>
   % find indices of time vector<br>
   ind_start = round((t_marker-200/1000)*EEG.srate)<br>
   ind_end   = round((t_marker+500/1000)*EEG.srate)<br>
<br>
<br>
   % add all data struct<br>
   EEG_S1.epochs(go).data  = EEG.data(:, ind_start:ind_end);<br>
   EEG_S1.epochs(go).times = [ind_start:ind_end].'*1/EEG.srate;<br>
<br>
<br>
<br>
end<br>
<br>
<br>
Thanks in advance.<br>
jess<br>
<br>
<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><br><br clear="all"><br>-- <br>Stephen Politzer-Ahles<br>University of Kansas<br>Linguistics Department<br><a href="http://people.ku.edu/~sjpa/" target="_blank">http://people.ku.edu/~sjpa/</a><br>