mne.annotations_from_events#
- mne.annotations_from_events(events, sfreq, event_desc=None, first_samp=0, orig_time=None, verbose=None)[source]#
Convert an event array to an Annotations object.
- Parameters
- events
ndarray
, shape (n_events, 3) The events.
- sfreq
float
Sampling frequency.
- event_desc
dict
| array-like |callable()
|None
Events description. Can be:
dict: map integer event codes (keys) to descriptions (values). Only the descriptions present will be mapped, others will be ignored.
array-like: list, or 1d array of integers event codes to include. Only the event codes present will be mapped, others will be ignored. Event codes will be passed as string descriptions.
callable: must take a integer event code as input and return a string description or None to ignore it.
None: Use integer event codes as descriptions.
- first_samp
int
The first data sample (default=0). See
mne.io.Raw.first_samp
docstring.- orig_time
float
|str
|datetime
|tuple
ofint
|None
Determines the starting time of annotation acquisition. If None (default), starting time is determined from beginning of raw data acquisition. For details, see
mne.Annotations()
docstring.- verbosebool |
str
|int
|None
Control verbosity of the logging output. If
None
, use the default verbosity level. See the logging documentation andmne.verbose()
for details. Should only be passed as a keyword argument.
- events
- Returns
- annotinstance of
Annotations
The annotations.
- annotinstance of
See also
Notes
Annotations returned by this function will all have zero (null) duration.
Creating events from annotations via the function
mne.events_from_annotations
takes in event mappings with key→value pairs as description→ID, whereasmne.annotations_from_events
takes in event mappings with key→value pairs as ID→description. If you need to use these together, you can invert the mapping by doing:event_desc = {v: k for k, v in event_id.items()}