[Eeglablist] epoching for 2 consecutive marker events

Tarik S Bel-Bahar tarikbelbahar at gmail.com
Thu Nov 15 19:21:44 PST 2012


Hi Jess,

Hope the following helps you a bit.
You should be able to have success with a small variation of your method.
In the first bit of code you shared, you're looping through the events
and determining which latencies you want to keep.
Now, instead, consider just adding a new event at each latency of interest.
Then 1 ) epoching on the new event via the gui or command line,
and 2) saving that as a new file and/or refreshing eeglab from the
command line, should give you only the epochs you want as the active
EEG structure.
Another path to solutions is to take a closer look
at the eeg history after doing various epoching functions
and try to replicate them in your code.
You may also want to check the function eeg_addnewevents
Also please consider checking some of the
online documentation and eeglab list archives if you have not had a
chance to yet. You may also want to review Luck's erplab "binning" capabilities
for alternative event handling using eeglab files and data structures.

Please send news when when have a chance.  Cheers, Tarik




On Thu, Nov 15, 2012 at 9: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




More information about the eeglablist mailing list