- 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])