ValueError: No stim channel found to extract event triggers.

  • MNE version: 1.3.0
  • operating system: macOS 12
events_from_annot, event_dict = mne.events_from_annotations(raw,event_id='auto'). 
events_from_annot = mne.find_events(raw)
print(events_from_annot[:10]) 

print("event_dict.....",event_dict)
             
reject_criteria = dict(eeg=100e-6)                            
                                                          
 
epochs = mne.Epochs(raw, events_from_annot, tmin=-0.1, tmax=1.6,
                    reject=reject_criteria, baseline = (None,0), preload=True, picks=['eeg'])

Raw data is collected from .mat file in numpy array and then converted into RAW object in mne.
Above code is giving errors while getting events from raw data as follows-
ValueError Traceback (most recent call last)
in
1 events_from_annot, event_dict = mne.events_from_annotations(raw,event_id=‘auto’)# Get events and event_id from an Annotations object.
----> 2 events_from_annot = mne.find_events(raw,‘STI 014’)
3 print(events_from_annot[:10]) # show the first 10
4
5 print(“event_dict…”,event_dict)

in find_events(raw, stim_channel, output, consecutive, min_duration, shortest_event, mask, uint_cast, mask_type, initial_event, verbose)

/usr/local/lib/python3.8/dist-packages/mne/event.py in find_events(raw, stim_channel, output, consecutive, min_duration, shortest_event, mask, uint_cast, mask_type, initial_event, verbose)
701 picks = pick_channels(raw.info[‘ch_names’], include=stim_channel)
702 if len(picks) == 0:
→ 703 raise ValueError(‘No stim channel found to extract event triggers.’)
704 data, _ = raw[picks, :]
705

ValueError: No stim channel found to extract event triggers.

Can I get help on solving this issue?

Hello @vaishnavimore23 and welcome to the forum!

The problem is quite clear here:
To find events, MNE looks for a “stim” channel (which contains the trigger signals). In your case, there is no such channel in the data, or if there is, it has not been assigned the correct channel type, so MNE cannot find it. So what you need to do is go back to your raw data import step and check a) whether there is even a stim channel, and if yes, b) ensure that you assign the correct channel type (stim). Only then find_events() will work.

On another note, it’s unclear to me why you try to recover events with two different approaches:

This usually doesn’t make much sense. Either you have a stim channel and want the events from there, or you have annotations and get the events from those.

Best wishes,
Richard

Great Thanks for your response !
In my data there are 8 channels(8 rows) and 1 extra row- which I believe is indicating the time. I don’t see any extra channel in the data. Could you please help on how to create STIM channels before passing numpy array to raw object creation.
Is there any other way to get events if STIM channel is not available ?