This documentation is for development version 0.18.dev0.

mne.events_from_annotations

mne.events_from_annotations(raw, event_id=None, regexp=None, use_rounding=True, chunk_duration=None, verbose=None)[source]

Get events and event_id from an Annotations object.

Parameters:
raw : instance of Raw

The raw data for which Annotations are defined.

event_id : dict | callable | None

Dictionary of string keys and integer values as used in mne.Epochs to map annotation descriptions to integer event codes. Only the keys present will be mapped and the annotations with other descriptions will be ignored. Otherwise, a callable that provides an integer given a string or that returns None for an event to ignore. If None, all descriptions of annotations are mapped and assigned arbitrary unique integer values.

regexp : str | None

Regular expression used to filter the annotations whose descriptions is a match.

use_rounding : boolean

If True, use rounding (instead of truncation) when converting times to indices. This can help avoid non-unique indices.

chunk_duration: float | None

If chunk_duration parameter in events_from_annotations is None, events correspond to the annotation onsets. If not, mne.events_from_annotations() returns as many events as they fit within the annotation duration spaced according to chunk_duration, which is given in seconds.

verbose : bool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

Returns:
events : ndarray, shape (n_events, 3)

The events.

event_id : dict

The event_id variable that can be passed to Epochs.