Incorrect Epoch Labelling

I am processing an EEG signal acquired by showing 10 image of each of 40 different classes. I want to label the signals converted to epochs to their corresponding class labels.

raw = mne.io.read_raw_bdf(raw_file,  preload =True)
events=mne.find_events(raw, stim_channel = None,
                       initial_event = True, consecutive='increasing', output='step',
                       uint_cast=True, verbose=None)

The events return

array([[      0,       0,   65280],
       [   3085,   65280,   65533],
       [  44751,   65280,   65281],
       ...,
       [4962462,   65280,   65281],
       [4974818,   65280,   65281],
       [5021696,   65280,       0]], dtype=int64)

The third column from events is the event code, that are the same for all events 65281, except for initial event.
I made an event dict, by combining the events[2], and the class labels which were shown:

event_dictt = []
for event, class_label in zip(events, class_labels):

    event_dictt.append((class_label,event[2]))

print(event_dictt)

The event_dictt is a list that contains data

[('initial event', 65280), ('initial event', 65533), ('airliner', 65281), ('watch', 65281), ('folding chair', 65281), ('radio telescope', 65281), ('jack-o-lantern', 65281),

As i plot the epochs to view the class labelling

epochs.plot(n_channels=10, events=events, event_id=event_dictt)
I gives the error
event_id[0] must be an int, got <class ‘tuple’>

if i convert the event_dictt to a dictionary, the epochs.plot works but the epoch labelling is incorrect,The epochs are plotted but the label from the second last class label ‘Pool table’ is used only:

All initial class labels are ignored.

The epochs are not correctly labelled

Hello,

I assume the problem is that you re-use the exact same event code (65281) multiple times. There can only be exactly one event name per event code.

Best wishes,
Richard

2 Likes

@richard
yes, as my events array returns the same exact code 65281 for all the 400 events.
and the images are shown 10 ×40 from each 40 classes.
if i convert the data to dictionary, it eliminates the multiple copies, keeping only the last one.
how can i do the correct labelling then, i also have 400 diffent names of images shown to subject, can they be used.
please help

You need to modify your events array to reflect that. Different event types need to have different values in the third column of the array.

2 Likes