# ignore wrong triggers from data collection

**URL:** <https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560>\
**Category:** Support & Discussions\
**Tags:** preprocessing, event-codes\
**Created:** [March 20, 2023, 10:29am UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560 "2023-03-20T10:29:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yunr](https://avatars.discourse-cdn.com/v4/letter/y/e5b9ba/32.png) [@Yunr](https://mne.discourse.group/u/Yunr)\
**Post date:** [March 20, 2023, 10:29am UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/1 "2023-03-20T10:29:04Z")

</div>

Hi,

I have a problem to find my correct events, because during data collection, the Biosemi system sent wrong extra triggers for some reasons, please see the screenshot. My correct triggers were sent correctly in the first line, but it kept sending 202020 triggers in the second line.

 ![202020](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/b/ba7391343c36bb2f0331d7b112ec1bd15b956578.jpeg)

In ActiRead902, it shows this, the red line here is the wrong 202020 triggers.

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

During preprocessing, I cannot find my correct triggers due to this error. By using find\_events, it can find events, but then I want to print the events, it gives “You have 16 events shorter than the shortest\_event…”.

I heard this error can be ignored in eeglab, can we do this in MNE? Could you please help me ignore the triggers in the second line. Thank you very much!

- operating system: Windows 10

Thank you again!

Yunr

---

<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:** [March 20, 2023, 10:57am UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/2 "2023-03-20T10:57:05Z")

</div>

You can extract all events with `events = mne.find_events(raw)` and then subset only those you actually need (`events` is a NumPy array).

---

<div class="post-metadata">

**Author:** ![Yunr](https://avatars.discourse-cdn.com/v4/letter/y/e5b9ba/32.png) [@Yunr](https://mne.discourse.group/u/Yunr)\
**Post date:** [March 20, 2023, 10:59am UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/3 "2023-03-20T10:59:29Z")

</div>

Thank you for your reply~

I did this, then I tried to print the events to check, but I cannot print it, it gives error: “You have 16 events shorter than the shortest\_event…”

Do you know how to deal with this?

---

<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:** [March 20, 2023, 11:16am UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/4 "2023-03-20T11:16:31Z")

</div>

Can you share a minimal example what you did?

---

<div class="post-metadata">

**Author:** ![Yunr](https://avatars.discourse-cdn.com/v4/letter/y/e5b9ba/32.png) [@Yunr](https://mne.discourse.group/u/Yunr)\
**Post date:** [March 20, 2023, 12:17pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/5 "2023-03-20T12:17:35Z")

</div>

Thank you! Here is the code I am using to find events:

events = mne.find\_events(raw, shortest\_event=1)  
events[:200]

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/c/ce8917d78267f46b41b92d1dd797e1385f0e3c48.png)  
I don’t have a 512 event, instead I have 51. I guess the 202020 influences the 51 trigger.

raw.copy().pick\_types(stim=True).plot() # try to find the STIM channels  
events = mne.find\_events(raw)  
print(events[:20])

“ValueError: You have 16 events shorter than the shortest\_event. These are very unusual and you may want to set min\_duration to a larger value.”

If I set min\_duration=0.140 which is the minimum duration between my correct triggers, it returns no events (“array(, shape=(0, 3), dtype=int32)”).

---

<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:** [March 20, 2023, 12:23pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/6 "2023-03-20T12:23:33Z")

</div>

This error originates from your events having a duration of less than 2 samples. You can change that with `shortest_event`. However, I think you need to take a look at other parameters as well to tailor it to your needs: [mne.find\_events — MNE 1.3.1 documentation](https://mne.tools/stable/generated/mne.find_events.html)

---

<div class="post-metadata">

**Author:** ![Yunr](https://avatars.discourse-cdn.com/v4/letter/y/e5b9ba/32.png) [@Yunr](https://mne.discourse.group/u/Yunr)\
**Post date:** [March 20, 2023, 1:23pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/7 "2023-03-20T13:23:51Z")

</div>

Thank you for your suggestion!

I have tried different parameters and combinations. But it looks like MNE merges the 2 lines of triggers and the 202020 contaminates the correct ones. I don’t have trigger named 512, and I barely see my correct triggers, so it seems that it doesn’t matter how do I select events, no correct ones would show up.

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/8/88e480651b797369646f06f36d330e0aeb7f5720.png)

---

<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:** [March 20, 2023, 3:20pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/8 "2023-03-20T15:20:09Z")

</div>

Are there two separate trigger channels or just one? Can you not manually filter the events you want? If they stack (i.e. add up when occurring at the same time), maybe you can still find a criterion which tells you which events to keep.

---

<div class="post-metadata">

**Author:** ![mainakjas](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mainakjas/32/34_2.png) [@mainakjas](https://mne.discourse.group/u/mainakjas)\
**Post date:** [March 20, 2023, 8:23pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/9 "2023-03-20T20:23:34Z")

</div>

Hi Yunr,

The way to fix your problem is to do:

find\_events(…, min\_duration=1. / raw.info[‘sfreq’])

Hope this helps,  
Mainak

---

<div class="post-metadata">

**Author:** ![Yunr](https://avatars.discourse-cdn.com/v4/letter/y/e5b9ba/32.png) [@Yunr](https://mne.discourse.group/u/Yunr)\
**Post date:** [March 20, 2023, 9:10pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/10 "2023-03-20T21:10:09Z")

</div>

Hi Mainak,

Thank you very much for the help~ I tried it, but still got error “You have 16 events shorter than the shortest\_event. These are very unusual and you may want to set min\_duration to a larger value e.g. x / raw.info[‘sfreq’]…”.

I tried to set min\_duration=2, it can run, but returns event ‘512’ which is the wrong event. I guess the system may merge events somehow.

Thank you again!  
Yunr

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [March 21, 2023, 10:44pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/11 "2023-03-21T22:44:36Z")

</div>

if there are 2 separate stim channels, and one of them has the correct events and the other one is garbage, then try passing `mne.find_events(raw, stim_channel='name_of_the_good_stim_channel')`

---

<div class="post-metadata">

**Author:** ![Yunr](https://avatars.discourse-cdn.com/v4/letter/y/e5b9ba/32.png) [@Yunr](https://mne.discourse.group/u/Yunr)\
**Post date:** [March 22, 2023, 3:26pm UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/12 "2023-03-22T15:26:37Z")

</div>

Thank you very much for the suggestion!

I found another solution. In case other people would have the similar problem. I put it here:

We can select or remove the extra triggers with the “Muter” tool in ActiTools902 ( [http://www.biosemi.com/download/ToolsFo … 02-Win.zip](http://www.biosemi.com/download/ToolsForRuntimeEngine2021/ActiTools902-Win.zip) ). It will generate a new BDF file without the wrong triggers.

---

<div class="post-metadata">

**Author:** ![wmvanvliet](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/wmvanvliet/32/100_2.png) [@wmvanvliet](https://mne.discourse.group/u/wmvanvliet)\
**Post date:** [May 4, 2023, 6:14am UTC](https://mne.discourse.group/t/ignore-wrong-triggers-from-data-collection/6560/14 "2023-05-04T06:14:09Z")

</div>

The BioSemi system uses the lower 8 bits for actual trigger codes and the upper 8 bits for status updates about the system. This is what is generating these weirdly high event codes. In my opinion (yes, let’s add yet another opinion to this thread 😉 ) is to use the `mask` parameter of the `find_events` function to have it only pay attention to the bottom 8 bits of the status channel:

```python
events = mne.find_events(raw, mask=0b11111111) # that's 8 ones

```
