ValueError: No events in events array, cannot plot.

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

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())?

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]))

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.

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 ??

Did you read our tutorial on this topic? I think it will answer your questions – if not, feel free to give us an update here!

1 Like

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:

from matplotlib import pyplot as plt

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

Or simply look for non-zero values:

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.


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

Thank u so much Mr. Mathieu @mscheltienne :smiling_face:

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

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?

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'?

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

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