mne.
find_events
(raw, stim_channel=None, verbose=None, output='onset', consecutive='increasing', min_duration=0, shortest_event=2, mask=0)¶Find events from raw file
Parameters: | raw : Raw object
stim_channel : None | string | list of string
verbose : bool, str, int, or None
output : ‘onset’ | ‘offset’ | ‘step’
consecutive : bool | ‘increasing’
min_duration : float
shortest_event : int
mask : int
|
---|---|
Returns: | events : array, shape = (n_events, 3)
|
See also
find_stim_steps
Examples
Consider data with a stim channel that looks like: [0, 32, 32, 33, 32, 0]
By default, find_events returns all samples at which the value of the stim channel increases:
>>> print(find_events(raw))
[[ 1 0 32]
[ 3 32 33]]
If consecutive is False, find_events only returns the samples at which the stim channel changes from zero to a non-zero value:
>>> print(find_events(raw, consecutive=False))
[[ 1 0 32]]
If consecutive is True, find_events returns samples at which the event changes, regardless of whether it first returns to zero:
>>> print(find_events(raw, consecutive=True))
[[ 1 0 32]
[ 3 32 33]
[ 4 33 32]]
If output is ‘offset’, find_events returns the last sample of each event instead of the first one:
>>> print(find_events(raw, consecutive=True,
... output='offset'))
[[ 2 33 32]
[ 3 32 33]
[ 4 0 32]]
If output is ‘step’, find_events returns the samples at which an event starts or ends:
>>> print(find_events(raw, consecutive=True,
... output='step'))
[[ 1 0 32]
[ 3 32 33]
[ 4 33 32]
[ 5 32 0]]
To ignore spurious events, it is also possible to specify a minimum event duration. Assuming our events channel has a sample rate of 1000 Hz:
>>> print(find_events(raw, consecutive=True,
... min_duration=0.002))
[[ 1 0 32]]
For the digital mask, it will take the binary representation of the digital mask, e.g. 5 -> ‘00000101’, and will block the values where mask is one, e.g.:
7 '0000111' <- trigger value
37 '0100101' <- mask
----------------
2 '0000010'