I have a problem with creating a plot and sensor placement from my database

Hello Everyone,

My MNE version: e.g. 0.23.0 and operating system: Windows 10.

I am new to the mne. I would like to preprocess my database, which I download from here (Event-Related Potentials (P300, EEG) - BCI dataset | IEEE DataPort). I working on the P300 Potentials from the EEG signal.

I used the recommeneded steps from the link:

import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import mne

# To load the data:
# ==============================
import pickle
filename = 'data_allsubjects'

with open(filename, 'rb') as handle:
    data = pickle.load(handle)  

# Here data is a python list to access first subjects 

subject6 = data[5]

""" Output:
<EpochsArray  |   3982 events (all good), 0 - 0.585938 sec, baseline off, ~37.0 MB, data loaded,
 'neg': 3413
 'pos': 569>

# Extract target and nontarget samples as:
target = subject6['pos']
nonTarget = subject6['neg']

This result in the
<EpochsArray | 3975 events (all good), 0 - 0.585938 sec, baseline off, ~36.9 MB, data loaded,
‘neg’: 3404
‘pos’: 571>

Then I split it to the two groups target nad nonTarget

target6 = subject6['pos']
nonTarget6 = subject6['neg']

In my preprocessing I used this Technotes for the referance:

FCz location were used for a reference electrode.

I change the data by using the low-pass filtered at 40 Hz, and a common average reference is set for the EEG channels, stored as a projector

target6.set_eeg_reference('average', projection=True)

However, the result is unreadable

I can olny see result adding the picks=‘eeg’,scalings=‘auto’, but even after that the outcome from the scope is better but still not good for further work, as I want to have the charts not to overlap beetwen each other.

The other issue for that database is that the placement of the sensors is outside of the head which I assume is another thing that need to be corrected.

Kindly please anyone for help with that issues. I can add the database in the therad if ther will be any need for that.

Thank you in advance !

Hello @PawBorEngineer and welcome to the forum!

Regarding the scaling issue, I assume that the data are not in the unit expected by MNE. MNE works with SI units, this means voltage has to be in the unit of Volts. I cannot access the dataset you’re using, but I’d assume it’s probably scaled to µV? If so, you need to multiply it by 1e-6 first.

I’d also like to add that using pickle files is probably one of the worst choices for long-term storage and data sharing, as it’s not guaranteed that all users will be able to open them (and get the same results even if they can).

Hello @richard

Thank you very much for your response.

Can you please, help me check if the data id in yhe correct units as I attached it to the case via link Share - Google Drive.

I also added in the link the read me file where they recommend to open the database with the Pickle command. Can you please recommend the other workaround for the data access.

Thank you in advance !

Hello, it’s impossible to know which scaling was used originally – you’d have to ask the creators of the dataset.

That said, I found that scaling the values by 10^-5 seems to put it into a somewhat reasonable range:

# %%
import pickle
import pathlib

infile = pathlib.Path('data_allsubjects')
all_epochs = pickle.load(open(infile, 'rb'))

# %%
# Scale by 10^-5
for epochs in all_epochs:
    epochs._data *= 1e-5

# %%
# Visualize epochs for one participant

Best wishes,

Hello ,

Thank you very much for the solution for my problem.

I just want to ask you one more thing is it possible to move the sensor placement to have them inside the head on the results ?

Thank you in advance!

Hello @richard,

Apologies for tagging you on that. But maybe you recomend to add some filtering to that dataset ?

Best Regards
Pawel Borowiak


I’m not sure what you mean by that?