- MNE-Python version: 0.21.0
- operating system: Windows 10
I am looking for a way to change the annotations from an EDF file. When I use the function events_from_annotations(), I want to change the classes. So far example, class 2 will become 4 and class 3 will become 5. I want to save this change inside the raw file. This is my code so far:
raw = read_raw_edf(fname, preload = True)
custom_mapping = {"T0": 1, "T1": 4, "T2":5}
new_annotations = events_from_annotations(raw, event_id = custom_mapping)
new = mne.annotations_from_events(events=new_annotations[0], sfreq=raw.info['sfreq'], orig_time=raw.info['meas_date'], event_desc = {1:"T0", 4:"T1", 5:"T2"})
raw.set_annotations(new)
print(events_from_annotations(raw))
The problem I am experiencing right now is that even after I modify the classes and then use the set_annotations() function, the classes will not change and stays the same as before. So for example, I want to change the events from
array([[ 0, 0, 1],
[ 672, 0, 2],
[ 1328, 0, 1],
[ 2000, 0, 3],
[ 2656, 0, 1],
[ 3328, 0, 2],
…]])
to
array([[ 0, 0, 1],
[ 672, 0, 4],
[ 1328, 0, 1],
[ 2000, 0, 5],
[ 2656, 0, 1],
[ 3328, 0, 4],
…]])
but I don’t know why it stays the same even after I call the function set_annotations().