How to add events to raw .edf EEG with no stim channel

I want to add a column of events to raw data .csv file of EEG signal with 64 Channel data from .edf file with no STIM channel.

import mne

raw = mne.io.read_raw_edf('../../data\S058\S058R08.edf', preload=True)

montage = mne.channels.make_standard_montage("standard_1020")

raw.rename_channels(lambda s: s.strip("."))

raw.set_montage(montage, match_case=False)

raw.set_eeg_reference("average")

events_from_annot, event_dict = mne.events_from_annotations(raw)

raw.add_events(events_from_annot) #, stim_channel

data = raw.to_data_frame(index="time", time_format="ms")

see https://github.com/mne-tools/mne-python/issues/4208

to add a stim channel first

1 Like