Read and analysis EEG from .dat file

I have several EEG data in .dat files.
Is there any function from men to load/read this type of file?
And the process to visualize it and to display it as a topo map?
I am a freshman at EEG and mne library, so I really need help.
Thank you

Hello @longle1319898,

you need to figure out which EEG system was used to produce the files, and then pick an appropriate reader for loading the data with MNE-Python.

Best wishes,

Hi @richard,

I checked information on MNE website, and I found that:
" Persyst EEG data (.lay, .dat)

EEG data from the Persyst system can be read with

Note that subject metadata may not be properly imported because Persyst sometimes changes its specification from version to version. Please let us know if you encounter a problem."

However, I used this function and got this error.
fname = “s01.dat”

FileNotFoundError: The path you specified, “s01.dat.lay”,does not exist.

What should I do?
Thank you

In the Notes section for that reader, it’s stated that there also needs to be a .lay file. Since you don’t have one, I doubt that your data is in the Persyst format. .dat is just a very generic extension and could basically mean anything …

You could try to open the file in a text editor and see if it’s a text file or a binary format.

Hi @richard ,

It is a text file.
The file below is my EEG signal, could you please help me to take a look on it?

Hello, the data is a pickled Python dictionary stored in an encoding that’s unusual today. This is how you can read it:

# %%
from pathlib import Path
import pickle

path = Path('EEG_template.dat')

content = path.read_bytes()
data = pickle.loads(content, encoding='ISO-8859-1')

Storing data in such a way (i.e., pickled) is one of the worst ways to store data for long-term archiving. It’s not guaranteed that you’ll even be able to open the data with a future version of Python and NumPy (the dictionary contains a NumPy array). Don’t do it.

At any rate, good luck with the data!



Hi @richard ,

Thank you for your support, I can read the .dat file now and I also can visualize the signal.
However, after loading the file by mne, it does not contain the configuration for channels/electrodes, I know the order of channels but I don’t know how to set up or add the location. Could you help me with this task?
Because if the data does not have the information related to the location of channels, I cannot applied ICA or topo maps.
Attach the link to the channel’s order of my data:

I have used mne.create_info as the code below, however, I still got issues with channels

ch_names = ['Fp1', 'AF3', 'F3', 'F7', 'FC5', 'FC1', 'C3', 'T7', 'CP5', 'CP1', 'P3', 'P7', 'PO3', 'O1',
            'Oz', 'Pz', 'Fp2', 'AF4', 'Fz', 'F4', 'F8', 'FC6', 'FC2', 'Cz', 'C4', 'T8', 'CP6', 'CP2',
            'P4', 'P8', 'PO4', 'O2']
sampling_freq = 128  # in Hertz
info = mne.create_info(ch_names=ch_names, sfreq=sampling_freq)
raw1 =[0][0:32,0:8064],info=info)

ica = mne.preprocessing.ICA(n_components=20, random_state=0), 40))


You can apply the standard_1005 montage via raw.set_montage

Best wishes