Event's based Classification

Hello,

This is a sample of my dataset.

sampling frequency - 128 Hz

  • operating system: Windows 10

Have converted the .csv to .fif but the event column is not getting processed.
Have created a channel “STIM channel” for the events also. But getting error.
ValueError: No stim channels found. Consider specifying them manually using the ‘stim_channel’ parameter.

events = mne.find_events(raw)

How to process the events column of the csv file and process the eeg signals and predict which event based on the 14 channels?

@richard @cbrnr
Thanks

Hello @Star,

you need to set the channel type of the event channel to stim, otherwise find_events() won’t be able to find it.

So you’ll need to do something like:

raw.set_channel_types({'event': 'stim'})

first.

Please follow our tutorial on MVPA at Decoding (MVPA) — MNE 1.0.3 documentation

Best wishes,
Richard

Hi @richard ,

Thanks,
Now when I run:
events = mne.find_events(raw)

Trigger channel has a non-zero initial value of 1 (consider using initial_event=True to detect this event)
Removing orphaned offset at the beginning of the file.
286 events found
Event IDs: [1 2]

It’s only finding 2 events when there are 4 events totally.
Why is this happening? Not finding all events and also number of events are less.

Thanks

According to our glossary entry, stim channels only have values >= 0. This probably explains why only events with codes 1 and 2 are being considered.

https://mne.tools/dev/glossary.html#term-stim-channel

I also have to say I’m surprised the values in that channel fluctuate so much from row to row. What does each row in your input data actually represent?

Hi,

The dataset contains recording of 14 channels and their event/class. There are totally 4 classes: listening, writing, resting etc…
ok.

Then it should be 0 ,1 and 2 events right. If the events are 1 and 2 only, then also all the events of 1 and 2 are not being considered.

Yes it fluctuates so much that’s the reason I’m think of doing this (the below one).
Any idea for this:

Thanks

Hello,

No, because 0 means “nothing” in a stim channel.

I’m failing to see the connection here.

I was asking because normally, triggers (event codes) need to persist over several samples, whereas in your example, they seem to change with every row. The only explanation I have is that rows don’t represent samples here. But if they don’t, then using a RawArray for your data doesn’t make any sense.

Best wishes,
Richard

Hello @richard,

Ok. Thanks.

Yes it does persist over several samples, I change it so that you can see different class in the screenshot. The next event occurs after a long time only.

The entire dataset actually contains Timestamp, 14-channels, Classification/Label/event, PPG, BPM, IBI etc. for each patients in separate .csv file.
What I want to do is to predict the Class/label based on the EEG signal and figure if there are any feature or frequency band that particular affects the classification?
And figure how the EEG signal looks when a person is listening, writing etc…
Am I going in a the wrong approach for this.
What the right approach then?

Thanks

Hi richard,

Was trying to extract the features from EEG Signal. For that wanted to import the data and epoch it.

tmin, tmax = -0.2, 0.5
event_id = dict(listening=1, writing=3)

# Setup for reading the raw data
raw = mne.io.RawArray(data, info)  
raw.filter(.5, None, fir_design='firwin')
events = mne.read_events(data)
picks = mne.pick_types(raw.info, eeg=True)

# Read epochs
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks, proj=True,
                    baseline=None, preload=True)
labels = epochs.events[:, -1]

# get MEG and EEG data
data = epochs.get_data()

Had the data in csv format like before. Here for the read_events since I don’t have separate event/label file, I gave the data path itself which I converted from csv and transposed to numpy.ndarray.

Now when I run the code I get

TypeError: fname must be an instance of path-like, got <class ‘numpy.ndarray’> instead.

Don’t have a path to the event/label. I know I need to give fname of the events.
How to handle this error if I don’t have event_fname? How to resolve this?

Thanks