I have troubles concatenating multiple fif-files, as I seem to lose all events in the process.
What I am doing right now is a concatenation of multiple files (typically 3 or 4, but varies) as follows:
for r in raws:
all_raws[r] = mne.io.read_raw(r, preload=False)
raw = mne.concatenate_raws([all_raws[r] for r in raws])
I checked, that the raw-files I feed into the dictionary still contain the events (in form of annotations).
After concatenation
mne.events_from_annotations(raw)
returns an empty list.
I am aware of
mne.concatenate_events()
but I don’t understand what the input for the arguments first_samp and last_samp is supposed tobe like in this scenario.
Concatenating events and event_ids from mne.events_from_annotations also seems suboptimal, as I am not sure in what order I would need to do that (i.e. which file comes first in the above list comprehension).
events and annotations are two related, but distinct concepts in MNE-Python. It’s a bit confusing, but suffice it to say that events are the things in that NumPy array with 3 columns (and without duration, as they are instantaneous), while annotations are a separate object type and can have a duration.
It’s unclear to me where exactly things go wrong in your above code. Could you please check what raw.annotations looks like after the concatenation? Are there even any annotations left?
If I run your code, @richard, on mne 0.24 it executes as expected.
The only thing I do before concatenating is filtering and resampling the files.
So my best guess right now is, that I am for some reason losing the events there.
I will check and let you know, once I can tell more.
Hello @RuKrei, if you want to, feel free to share your input data with me via Google Drive or a similar service; my email address is richard.hoechenberger@gmail.com
I can then have a look.