[Eeglablist] Regular expression to extract epochs from continuous EEG data

Tarik S Bel-Bahar tarikbelbahar at gmail.com
Tue Oct 27 15:49:50 PDT 2015

Hello Anne, hope the below helps a bit. Kindly search past eeglablist
discussions on similar topics. Cheers.

***See the details and functions listed below. If you know the time and
label of each event you want to create, the function eeg_addnewevents might
do the trick.



*function names

Depending on whether you have your file already epoched or not, you
probably want to use information in the some subfields of EEG.event and,
especially for epoched data, EEG.epoch. Or fillup and use info into
EEG.epochdescription, etc...

Try to make a loop in matlab that runs through the "trial info" regarding
each trial, which should be easy to find in the EEG structure. The loop
should have as many steps as there are current trials.Also, you could have
a matrix of information about the trials that the code refers to in order
to make a decision about the trial in question.
Then at each step of the loop determine which condition it is, which marker
you want to give it, and then either
a) insert a marker,
or b) make a list of event markers/times and then insert them all at once

There are much more elegant solutions that avoid loops in Matlab, see the
example from the eeglab list at the beginning of this note.

There are also ways you can complicate the event-marking process by making
the creation of events dependent on other things (such as whether preceding
or following trials were of a certain type, the speed of responding, etc...)

You'll also most likely have to make sure you've updated your structure and
run eeg_checkset to make sure all is kosher.

On Fri, Oct 23, 2015 at 5:17 AM, Anne Mickan <amickan1990 at gmail.com> wrote:

> Hi all,
> I would like to extract and segment a subpart of trials from my continuous
> EEG data based on the marker names for the trials. My trial names are
> rather long and an example marker name would be
> this: S1_con1_sub1_corr_corrresp_Snr_12
> I would like to epoch all trials of condition 1 (con1) that are correct
> (corr) and ignore all others. I know I can describe the type of markers I
> want using the following regular expression: S1_con1_sub\d_corr_\w+.+
> I just don't know how to correctly embed this regular expression into the
> epoch() function in my Matlab script. I've tried a few things already, but
> nothing worked properly. My question is thus: How do I tell Matlab / EEGlab
> to go through the list of markers (i.e. trials/epochs) in the current
> dataset and to only select the ones fitting the above regexp string for
> epoching?
> Thanks a lot in advance for your help!
> Best,
> Anne
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20151027/b71843a7/attachment.html>

More information about the eeglablist mailing list