# Problems concatenating list of Epochs. Event samples not Unique

**URL:** <https://mne.discourse.group/t/problems-concatenating-list-of-epochs-event-samples-not-unique/9264>\
**Category:** Support & Discussions\
**Created:** [August 30, 2024, 9:41pm UTC](https://mne.discourse.group/t/problems-concatenating-list-of-epochs-event-samples-not-unique/9264 "2024-08-30T21:41:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cardoso1994](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cardoso1994/32/3857_2.png) [@Cardoso1994](https://mne.discourse.group/u/Cardoso1994)\
**Post date:** [August 30, 2024, 9:41pm UTC](https://mne.discourse.group/t/problems-concatenating-list-of-epochs-event-samples-not-unique/9264/1 "2024-08-30T21:41:23Z")

</div>

Hi, everyone!  
I am trying to concatenate a list of epoch objects but keep getting the following error:

```python
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:

```python
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:

```python
<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:

```python
[[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!

---

<div class="post-metadata">

**Author:** ![codZeus](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@codZeus](https://mne.discourse.group/u/codZeus)\
**Post date:** [September 5, 2024, 8:11pm UTC](https://mne.discourse.group/t/problems-concatenating-list-of-epochs-event-samples-not-unique/9264/2 "2024-09-05T20:11:24Z")

</div>

Hi,

I think first you have to concatenate your 5 sessions and then put them into an mne object.  
After that, use the

```python
mne.Epochs(...)

```

To see the epochs for the 5 sessions.

For eg:  
concat\_obj is the variable used to assign the 5 sessions concatenated together

```python
raw = mne.io.RawArray(concat_obj, infomne)
epochs = mne.Epochs(raw, .... )

```

I think this should give you the list of epochs for the 5 sessions.
