# ValueError: No events in events array, cannot plot.

**URL:** <https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586>\
**Category:** Support & Discussions\
**Tags:** preprocessing, eeg, visualization, event-codes\
**Created:** [March 21, 2022, 4:26am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586 "2022-03-21T04:26:13Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 21, 2022, 4:26am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/1 "2022-03-21T04:26:13Z")

</div>

Hi guys,  
i couldn’t get it my stim channel has low value near zero but why my events is empty array?

events = mne.find\_events(raw, stim\_channel=‘STI’,shortest\_event=2)  
events —\> output is array(, shape=(0, 3), dtype=int32)

# i couldn’t get it my stim channel has low value near zero but why my events is empty array?

mne.viz.plot\_events(events[:]) ----\> When i try this code ı got

ValueError: No events in events array, cannot plot.

How can i solve this issue???

- operating system: Windows 10

---

<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 21, 2022, 7:38am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/2 "2022-03-21T07:38:01Z")

</div>

Things you could try:

- Is your stim channel labeled “STIM” (check with `raw.ch_names`)?
- You are setting `shortest_event=2` – maybe your events are just 1 sample (you can check by plotting the channel with e.g. `raw.plot()`)?

---

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 21, 2022, 3:53pm UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/3 "2022-03-21T15:53:22Z")

</div>

I changed the name “STI” to “STIM” it is not effect  
I deleted the shorthest\_event=2 parameter

raw[“STIM”] —\> when i run this code i get below tuple inside so many arrays

(array([[0., 0., 0., …, 0., 0., 0.]]),  
array([0.0000000e+00, 2.0000000e-03, 4.0000000e-03, …, 1.0802994e+04,

mne.viz.plot\_events(events[:]) —\> gives error which is  
ValueError: No events in events array, cannot plot.  
1.0802996e+04, 1.0802998e+04]))

---

<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 21, 2022, 4:03pm UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/4 "2022-03-21T16:03:15Z")

</div>

I did not mean to suggest that you rename the channel; I just wanted to make sure you are actually using the correct stimulus channel (so if it is really called “STI” then no need to rename).

Can you plot the actual continuous signal of the STI channel using `raw.plot()`? It would be helpful to see the actual signal contained in that channel.

---

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 21, 2022, 4:45pm UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/5 "2022-03-21T16:45:26Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/7/7d35734d717c91e3d8dfe97a1b217991465271f4.jpeg)  
I got this image. Mr. Clemens i search lots of things but , couldn’t get it what is stim channel and also event? Why do we need them? I read that to create epochs is important create event but what is that actually ??

---

<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 22, 2022, 6:34am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/6 "2022-03-22T06:34:55Z")

</div>

Did you read [our tutorial on this topic](https://mne.tools/stable/auto_tutorials/intro/20_events_from_raw.html)? I think it will answer your questions – if not, feel free to give us an update here!

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [March 22, 2022, 9:44am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/7 "2022-03-22T09:44:18Z")

</div>

To add on the tutorial, which is definitely where you should look into, you do have a channel `'STIM'` which looks flat (zeros) and probably has a couple of spikes at some points (events). To confirm you do have events (non-zero values) you can either:

Plot with `raw.copy().pick_types(stim=True).plot()` but pick only the stim channel and navigate/search interactively for events with the left/right arrow keys of your keyboard.

Plot with matplotlib:

```python
from matplotlib import pyplot as plt

plt.plot(raw.get_data(picks='STIM')[0, :])

```

Or simply look for non-zero values:

```python
import numpy as np

data = raw.get_data(picks='STIM')[0, :]
print (np.nonzero(data))

```

That will already tell us more about what is actually stored on your `'STIM'` channel.

---

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 24, 2022, 4:16am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/8 "2022-03-24T04:16:14Z")

</div>

Thanx @cbrnr I am reading the tutorial now. How can I miss this part 🥲

---

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 24, 2022, 4:17am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/9 "2022-03-24T04:17:01Z")

</div>

Thank u so much Mr. Mathieu @mscheltienne☺

---

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 24, 2022, 4:42am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/10 "2022-03-24T04:42:53Z")

</div>

> [@mscheltienne](#):
>
> ```python
> import numpy as np
> 
> data = raw.get_data(picks='STIM')[0, :]
> print (np.nonzero(data))
> 
> ```

i have “0” stim channel as an array. Now i m searching do i need add some artficial stim channel in my data or not? if necessary how do i add

---

<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 24, 2022, 6:46am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/11 "2022-03-24T06:46:12Z")

</div>

If you have an all-zero stim channel then something went wrong during recording. What kind of data do you have? What is the original file format? Did you check if you already have annotations in `raw.annotations`?

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [March 24, 2022, 9:47am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/12 "2022-03-24T09:47:47Z")

</div>

> [@ipek](#):
>
> i have “0” stim channel as an array

Not sure what you mean. Do you mean `raw.get_data(picks='STIM')[0, :]` this is entirely comprised of 0 or that it was not able to pick `'STIM'`?

---

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 30, 2022, 10:29am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/13 "2022-03-30T10:29:16Z")

</div>

> [@mscheltienne](#):
>
> entirely comprised of 0

entirely comprised of “0” I will work with data from another source.Thanxx a lot ☺

---

<div class="post-metadata">

**Author:** ![ipek](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/ipek/32/1268_2.png) [@ipek](https://mne.discourse.group/u/ipek)\
**Post date:** [March 30, 2022, 10:30am UTC](https://mne.discourse.group/t/valueerror-no-events-in-events-array-cannot-plot/4586/14 "2022-03-30T10:30:48Z")

</div>

I checked it. I worked on temple university data and now I will start working with another source. Thank you so much ☺
