[Eeglablist] epoching for 2 consecutive marker events

Stephen Politzer-Ahles politzerahless at gmail.com
Thu Nov 15 16:01:25 PST 2012


Hi Jess,

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):

% Loop through epochs until the second-to-last epoch
for i=1:length(EEG.epoch)-1
% Concatenate the epochtype of the next epoch to the epochtype of this
epoch, with a space in between
EEG.epoch(i).type = [ EEG.epoch(i).type ' ' EEG.epoch(i+1).type ];
end;

After that, you could select epochs 'S 1 S 4' using pop_epoch().

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.

Best,
Seve

On Thu, Nov 15, 2012 at 8:34 AM, Jess <jhartcher at tuebingen.mpg.de> wrote:

> 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.
>
> 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.
>
> 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.
>
> Maybe it is clearer what I want to do if you see my code in which I have
> loaded and filtered my .set data:
>
> %%%%%%%%%%%%%%% Step 1: identify and extract marker times%%%%%%%%%%%%
>
> n_events = length(EEG.event);
>
> % declare empty arrays for storing event latencies
> latency1 = [];
> latency2 = [];
>
> for go = 1:n_events
>
>    % find S1/S2 and S4 combinations
>    check1 = (strcmp(EEG.event(go).type, 'S  1') &&
> strcmp(EEG.event(go+1).type, 'S  4'));
>    check2 = (strcmp(EEG.event(go).type, 'S  2') &&
> strcmp(EEG.event(go+1).type, 'S  4'));
>
>    % store times at which combination S 1 & S 4 occurs
>    if check1 == 1
>        latency1 = [latency1; EEG.event(go).latency*1/EEG.srate];
>    end
>
>    % store times at which combination S 2 & S 4 occurs
>    if check2 == 1
>        latency2 = [latency2; EEG.event(go).latency*1/EEG.srate];
>    end
>
> end
>
>
> %%%%%%%%%%%%%%%%%%%%%%%step 2 - not using EEGlab functions but epoching
> according to the Marker combinations%%%%%%%%%%
> % S1
> for go = 1:length(latency1)
>
>    % retrieve marker time
>    t_marker = latency1(go);
>
>    % find indices of time vector
>    ind_start = round((t_marker-200/1000)*EEG.srate)
>    ind_end   = round((t_marker+500/1000)*EEG.srate)
>
>
>    % add all data struct
>    EEG_S1.epochs(go).data  = EEG.data(:, ind_start:ind_end);
>    EEG_S1.epochs(go).times = [ind_start:ind_end].'*1/EEG.srate;
>
>
>
> end
>
>
> Thanks in advance.
> jess
>
>
> _______________________________________________
> 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
>



-- 
Stephen Politzer-Ahles
University of Kansas
Linguistics Department
http://people.ku.edu/~sjpa/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20121115/e7f46ae5/attachment.html>


More information about the eeglablist mailing list