mne.io.read_events_eeglab

mne.io.read_events_eeglab(eeg, event_id=None, event_id_func='strip_to_integer', uint16_codec=None)[source]

Create events array from EEGLAB structure.

An event array is constructed by looking up events in the event_id, trying to reduce them to their integer part otherwise, and entirely dropping them (with a warning) if this is impossible. Returns a 1x3 array of zeros if no events are found.

Usually, the EEGLAB readers will automatically construct event information for you. However, the reader for continuous data stores event information in the stimulus channel, which can only code one event per time sample. Use this function if your EEGLAB file has events happening at the same time (sample) point to manually create an events array.

Parameters:

eeg : str | object

The EEGLAB object from which events are read in. If str, path to the (EEGLAB) .set file. Else, the “EEG” field of a MATLAB EEGLAB structure as read in by scipy.io.loadmat.

event_id : dict | None

The ids of the events to consider. If None (default), an empty dict is used and event_id_func (see below) is called on every event value. If dict, the keys will be mapped to trigger values on the stimulus channel and only keys not in event_id will be handled by event_id_func. Keys are case-sensitive. Example:

{'SyncStatus': 1; 'Pulse Artifact': 3}

event_id_func : None | str | callable

What to do for events not found in event_id. Must take one str argument and return an int. If string, must be ‘strip-to-integer’, in which case it defaults to stripping event codes such as “D128” or “S 1” of their non-integer parts and returns the integer. If the event is not in the event_id and calling event_id_func on it results in a TypeError (e.g. if event_id_func is None) or a ValueError, the event is dropped.

uint16_codec : str | None

If your *.set file contains non-ascii characters, sometimes reading it may fail and give rise to error message stating that “buffer is too small”. uint16_codec allows to specify what codec (for example: ‘latin1’ or ‘utf-8’) should be used when reading character arrays and can therefore help you solve this problem.

Returns:

events : array, shape = (n_events, 3)

All events that were found. The first column contains the event time in samples and the third column contains the event id. The center column is zero.

See also

mne.find_events
Extract events from a stim channel. Note that stim channels can only code for one event per time point.