Given an epochs with the following event create using the mne.make_fixed_length_events
[[ 6450 0 1]
[ 7350 0 1]
[ 8251 0 1]
[ 9152 0 1]
[10053 0 1]
[10954 0 1]
[11855 0 1]
[12756 0 1]
[13657 0 1]
[14558 0 1]]
Then, along the way, I redefine the integer Event IDs
into the following.
[[ 6450 0 0]
[ 7350 0 0]
[ 8251 0 0]
[ 9152 0 0]
[10053 0 0]
[10954 0 0]
[11855 0 1]
[12756 0 1]
[13657 0 1]
[14558 0 1]]
Is it possible to map the Integer Event IDs
onto meaningful description.
Such that, I would like create an event dictionary
event_ids ={'r0': 0, 'r1': 1,'r2': 2}
The full code to reproduce the above epoch
creation is as below
import mne
import numpy as np
import pandas as pd
sample_data_raw_file='sample_audvis_filt-0-40_raw.fif'
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.crop(tmax=250)
tmin, tmax = 0, 6
event_id = 1 # This is used to identify the events.
events = mne.make_fixed_length_events(raw, event_id, start=0, stop=None, duration=tmax)
epochs = mne.Epochs(raw, events=events, event_id=event_id, baseline=None,
verbose=True, tmin=tmin, tmax=tmax, preload=True)
list_time = [int(x / tmax) for x in [40,80,150]]
df = pd.DataFrame(epochs.events, columns=['time_point', 'duration', 'event']).reset_index()
conditions = [
(df['index'].between(list_time[0], list_time[1])),
(df['index'].between(list_time[0], len(df)))]
df['event'] = np.select(conditions, [1, 2], default=0)
df.drop(columns=['index'], inplace=True)
epochs.events = df.to_numpy()
event_ids ={'r0': 0, 'r1': 1,'r2': 2}
I tried something like
epochs = mne.Epochs(raw, events=events, event_id={'r0': 0, 'r1': 1,'r2': 2}, baseline=None,
verbose=True, tmin=tmin, tmax=tmax, preload=True)
notice the event_id
referencing
but as expected, the compiler return ValueError
ValueError: No matching events found for r0 (event id 0)
Appreciate for any hints