Hi, everyone!
I am trying to concatenate a list of epoch objects but keep getting the following error:
RuntimeError: Event time samples were not unique. Consider setting the `event_repeated` parameter."
My environment is the following:
- MNE version: 1.8.0
- OS: Ubuntu 22.04.04
I’m working with a motor imagery dataset, for the same subject I have 5 sessions, so in my code I have 5 epochs objetcs; whenever I try to concatenate the epochs I get the error.
My code is as follows:
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import mne
import normalization
SUB = int(sys.argv[1])
NUM_SES = 5
sessions = []
dir_path = os.path.join("..", "preprocess_first", f"sub_{SUB:02d}")
for session in range(1, NUM_SES + 1):
fname = os.path.join(dir_path, f"ses_{session:02d}",
"epochs_preprocessed-epo.fif")
epochs_ses = mne.read_epochs(fname, preload=True)
sessions.append(epochs_ses)
""" leave one session out """
nums = [num for num in range(NUM_SES)]
for ses in range(NUM_SES):
train = sessions[:ses] + sessions[ses + 1:]
test = list(sessions[ses])
mne.concatenate_epochs(train, add_offset=False)
It is not the first time that I try to concatenate epochs, but it is the first time I encounter this error. Additionally, and this is very funny to me, the error occurs when I try to run the script in the terminal, i.e. python script.py
, but if I copy and paste the whole script in iPython
, it runs without any issues, unless add_offset=False
, in that case I have the same Error.
Here there are the info of one session:
<Info | 11 non-empty values
bads: []
ch_names: Fp1, Fp2, Fz, F3, F4, F7, F8, FC1, FC2, FC5, FC6, Cz, C3, C4, ...
chs: 32 EEG
custom_ref_applied: False
dig: 35 items (3 Cardinal, 32 EEG)
file_id: 4 items (dict)
highpass: 1.0 Hz
lowpass: 40.0 Hz
meas_date: 2022-02-24 19:57:50 UTC
meas_id: 4 items (dict)
nchan: 32
projs: []
sfreq: 250.0 Hz
subject_info: 4 items (dict)
>
and the events of the same session:
[[ 0 0 1]
[ 1000 0 1]
[ 2000 0 2]
[ 3000 0 1]
[ 4000 0 1]
[ 5000 0 2]
[ 6000 0 2]
...
...
[95000 0 1]
[96000 0 1]
[97000 0 1]
[98000 0 1]
[99000 0 1]]
Basically all epochs events have the same structure: they start at zero and each new event comes exactly at 1000 sample points after (4 seconds).
Thanks in advance!