- MNE version: e.g. 0.24.0
- operating system: e.g. Windows 11
I am new to python and MNE. Please can you help I am having a hard time fixing this error.
ValueError: 2 from event_id is not present in events.
This is my code:
raw_train.plot(start=60, duration=60,
scalings=dict(eeg=1e-4, resp=1e3, eog=1e-4, emg=1e-7,
misc=1e-1))
annotation_desc_2_event_id = {‘Sleep stage W’: 1,
‘Sleep stage 1’: 2,
‘Sleep stage 2’: 3,
‘Sleep stage 3’: 4,
‘Sleep stage 4’: 4,
‘Sleep stage R’: 5}
annot_train.crop(annot_train[1][‘onset’] - 30 * 60,
annot_train[-2][‘onset’] + 30 * 60)
raw_train.set_annotations(annot_train, emit_warning=False)
events_train, _ = mne.events_from_annotations(
raw_train, event_id=annotation_desc_2_event_id, chunk_duration=30.)
create a new event_id that unifies stages 3 and 4
event_id = {‘Sleep stage W’: 1,
‘Sleep stage 1’: 2,
‘Sleep stage 2’: 3,
‘Sleep stage 3/4’: 4,
‘Sleep stage R’: 5}
#mne.viz.plot_events(events_train[:100])
#print(events_train[:4])
plot events
fig = mne.viz.plot_events(events_train, event_id=event_id,
sfreq=raw_train.info[‘sfreq’],
first_samp=events_train[0,0])