# Events order issue after epoching

**URL:** <https://mne.discourse.group/t/events-order-issue-after-epoching/10467>\
**Category:** Support & Discussions\
**Tags:** event-codes, epochs\
**Created:** [October 31, 2024, 3:37am UTC](https://mne.discourse.group/t/events-order-issue-after-epoching/10467 "2024-10-31T03:37:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonokat](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/bonokat/32/1901_2.png) [@bonokat](https://mne.discourse.group/u/bonokat)\
**Post date:** [October 31, 2024, 3:37am UTC](https://mne.discourse.group/t/events-order-issue-after-epoching/10467/1 "2024-10-31T03:37:09Z")

</div>

- MNE version: 1.8.0
- operating system:Windows 10

Hi All,

I have two issues when analysing epochs. Since they are very similar, I’m describing both here.

**– 1 –**  
I have the data with the following triggers: 10, 11, 12, 13, 15, 14  
The order above is the correct order for every trial. I cheched it on the raw data and there were not any order issues.

Then, I created epochs using all events:

`epochs = mne.Epochs(raw, events[0], event_id=events[1], tmin=-0.5, tmax=0.5, preload=True)`

events[0] - array with events  
events[1] - dict with event ids

And tried to plot the epochs:

`epochs.plot(events=events[0])`  
and  
`epochs.plot(events=True)`

Either way I see incorrect events order on the plot, which based on what I see in the raw data should not be possible. For example:

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/3/3426417a665d6ba987c8eac1a2ced279aaef6ac0.png)

Do you have an idea what might be causing this issue?

**– 2 –**  
It has implicaitons for my analysis too, since I am interested in epochs around trigger 11 and need to exclude all the ‘11’ epochs which also have triggers 14 and 15. As I have understood from the information on the forums, it is not very straightforward. Could you suggest any ideas for me how to filter epochs with ‘undesirable’ triggers?

I’ll appreciate your help!

Best,  
Kat

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [October 31, 2024, 6:29am UTC](https://mne.discourse.group/t/events-order-issue-after-epoching/10467/2 "2024-10-31T06:29:16Z")

</div>

A very quick first answer (as I’m currently in a rush), I think one thing you should do is epoch only around events of interest, i.e., event 11. Otherwise, you are creating 1s epochs around every event, which is probably not what you want. Then at least the plots should look correct hopefully.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 31, 2024, 7:45am UTC](https://mne.discourse.group/t/events-order-issue-after-epoching/10467/3 "2024-10-31T07:45:55Z")

</div>

> [@bonokat](#):
>
> It has implicaitons for my analysis too, since I am interested in epochs around trigger 11 and need to exclude all the ‘11’ epochs which also have triggers 14 and 15. As I have understood from the information on the forums, it is not very straightforward. Could you suggest any ideas for me how to filter epochs with ‘undesirable’ triggers?

Yes, you can use epochs metadata queries for this. Check out [this tutorial](https://mne.tools/stable/auto_tutorials/epochs/40_autogenerate_metadata.html) for an introduction.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![bonokat](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/bonokat/32/1901_2.png) [@bonokat](https://mne.discourse.group/u/bonokat)\
**Post date:** [November 4, 2024, 2:33am UTC](https://mne.discourse.group/t/events-order-issue-after-epoching/10467/4 "2024-11-04T02:33:25Z")

</div>

Thanks a lot!  
It worked really well. Nice functionality 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [November 11, 2024, 2:33am UTC](https://mne.discourse.group/t/events-order-issue-after-epoching/10467/5 "2024-11-11T02:33:37Z")

</div>

Closed on November 11, 2024, 2:33am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
