mne.events_from_annotations¶
-
mne.events_from_annotations(raw, event_id='auto', regexp='^(?![Bb][Aa][Dd]|[Ee][Dd][Gg][Ee]).*$', use_rounding=True, chunk_duration=None, verbose=None)[source]¶ Get events and event_id from an Annotations object.
- Parameters
- rawinstance of
Raw The raw data for which Annotations are defined.
- event_id
dict|callable()|None| ‘auto’ Can be:
dict: map descriptions (keys) to integer event codes (values). Only the descriptions present will be mapped, others will be ignored.
callable: must take a string input and return an integer event code, or return
Noneto ignore the event.None: Map descriptions to unique integer values based on their
sortedorder.‘auto’ (default): prefer a raw-format-specific parser:
Brainvision: map stimulus events to their integer part; response events to integer part + 1000; optic events to integer part + 2000; ‘SyncStatus/Sync On’ to 99998; ‘New Segment/’ to 99999; all others like
Nonewith an offset of 10000.Other raw formats: Behaves like None.
New in version 0.18.
- regexp
str|None Regular expression used to filter the annotations whose descriptions is a match. The default ignores descriptions beginning
'bad'or'edge'(case-insensitive).Changed in version 0.18: Default ignores bad and edge descriptions.
- use_roundingbool
If True, use rounding (instead of truncation) when converting times to indices. This can help avoid non-unique indices.
- chunk_duration
float|None Chunk duration in seconds. If
chunk_durationis set to None (default), generated 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 tochunk_duration. As a consequence annotations with duration shorter thanchunk_durationwill not contribute events.- verbosebool,
str,int, orNone If not None, override default verbose level (see
mne.verbose()and Logging documentation for more). If used, it should be passed as a keyword-argument only.
- rawinstance of
- Returns
Notes
For data formats that store integer events as strings (e.g., NeuroScan
.cntfiles), passing the Python built-in functionintas theevent_idparameter will do what most users probably want in those circumstances: return anevent_iddictionary that maps event'1'to integer event code1,'2'to2, etc.