mne.event.match_event_names#

mne.event.match_event_names(event_names, keys, *, on_missing='raise')[source]#

Search a collection of event names for matching (sub-)groups of events.

This function is particularly helpful when using grouped event names (i.e., event names containing forward slashes /). Please see the Examples section below for a working example.

Parameters:
event_namesarray_like of str | dict

Either a collection of event names, or the event_id dictionary mapping event names to event codes.

keysarray_like of str | str

One or multiple event names or groups to search for in event_names.

on_missing‘raise’ | ‘warn’ | ‘ignore’

How to handle situations when none of the keys can be found in event_names. If 'warn' or 'ignore', an empty list will be returned.

Returns:
matcheslist of str

All event names that match any of the keys provided.

Notes

New in version 1.0.

Examples

Assuming the following grouped event names in the data, you could easily query for all auditory and left event names:

>>> event_names = [
...     'auditory/left',
...     'auditory/right',
...     'visual/left',
...     'visual/right'
... ]
>>> match_event_names(
...     event_names=event_names,
...     keys=['auditory', 'left']
... )
['auditory/left', 'auditory/right', 'visual/left']