I am working on eeg visual stimulus data. the images are shown 10 ×40 from each 40 classes.
The events array returns the same exact code 65281 for all the 400 events except for first 2 and last one event, which shows no image.
events array returns:
[[ 3085 65280 65533]
[ 44751 65280 65281]
[ 57084 65280 65281]
…
[4962462 65280 65281]
[4974818 65280 65281]
[5021696 65280 0]]
I want to labels all epochs based on events and event label.
picks = mne.pick_types(raw.info, meg=True, eeg=True, eog=True,
stim=False, exclude=‘bads’)
epochs = mne.Epochs(raw, events, event_name, tmin=0, tmax=0.5, proj=True,
picks=picks, baseline=(0,0), reject=None, on_missing=‘warn’)
event_name, accepts only a type dict.
When i make a dict out of events and 40 class labels, it uses the event_id, the (third column from events) as key, and make only 40 unique pairs, thus destroying all the events data.
Since apparently the same event code was used for all images (not good practice, because it causes exactly the type of issue you’re running into now), there is no way to assign the correct labels based on the event codes alone. If you have a separate list or table of the images in the order in which they were presented during the experiment, you can use those to construct an events array where the values in the 3rd column are unique for each image label.
how was the events array created? The code you provided does not show that step. As @richard said, if the events in the Raw file are like that (all the same number) then you’ll need to rely on some other source of information (probably the code that ran the experiment) to figure out what the presentation order was, and use that to modify the events array. But show us the code related to creating / extracting events array, if you made a mistake with that, maybe there’s an easier fix.
OK, thanks. I’m kinda guessing here, but you have some non-standard param values in your call to find_events:
uint_cast=True I think is only useful for Neuromag data? Since you’re loading from a .bdf file this is probably wrong
output="step" will give 2 events for every stim-channel “trigger” (an onset and an offset event). Usually this is not what people want / not how triggers are used during acquisition. Make sure this is correct given what you know about how the data were collected / the design of the experiment.
However I doubt that changing either of those is likely to fix the problem you see (all events have same value)… so you’ll probably need to do as suggested above: reconstruct the event codes from some other data source. One last thing to check is to make sure that the STIM channel being identified automatically (because you set stim_channel=None) is actually the correct source of events in the Raw recording.