Problems reading .vhdr and .eeg files

Hey there,
I was given .eeg and .vhdr files from an EEG experiment to get some practice. My problem is, that I have struggles reading them into MNE python.

  • MNE-Python version: 3.9.2
  • operating system: Windows 10

1.) .vhdr
→ As suggested here http://predictablynoisy.com/mne-python/manual/io.html, I tried

raw = mne.io.read_raw_brainvision("C:/Users/S_Hei/Documents/Python_Folder/B068a_VP2_EEG.vhdr")

but it tells me:

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\S_Hei\Documents\Python_Folder\B068a_VP2_EEG.vmrk’

But there is a file called B068a_VP2_EEG.vhdr in C:\Users\S_Hei\Documents\Python_Folder. I also checked the working directory

os.getcwd()

‘C:\Users\S_Hei\Documents\Python_Folder’

and this:

ls

Volume in Laufwerk C: hat keine Bezeichnung.
Volumeseriennummer: 5E39-650E

Verzeichnis von C:\Users\S_Hei\Documents\Python_Folder

13.05.2021 08:58 .
13.05.2021 08:58 …
12.05.2021 16:57 .ipynb_checkpoints
13.05.2021 08:58 24.796 B068.ipynb
12.05.2021 16:00 424.175.360 B068a_VP2_EEG.eeg
12.05.2021 15:59 1.849 B068a_VP2_EEG.vhdr
05.05.2021 09:20 5.991 csv einlesen.ipynb
16.04.2021 09:13 462 environment.yml
22.04.2021 11:53 108.402.432 my_data.npy
10.05.2021 09:23 pybrain_mne-main
11.05.2021 10:11 Tutorials
6 Datei(en), 532.610.890 Bytes
5 Verzeichnis(se), 300.559.220.736 Bytes frei

I don’t understand why it cannot find the file :slightly_frowning_face:

2.) .eeg
→ I tried it with Importing data from EEG devices — MNE 1.6.0 documentation

raw_eeg = mne.io.read_raw_nihon("C:/Users/S_Hei/Documents/Python_Folder/B068a_VP2_EEG.eeg")

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xfa in position 0: ordinal not in range(128)

→ and mne.io.read_raw_eeglab — MNE 1.6.0 documentation
raw_eeg = mne.io.read_raw_eeglab("C:/Users/S_Hei/Documents/Python_Folder/B068a_VP2_EEG.eeg")

ValueError: Mat 4 mopt wrong format, byteswapping problem?

→ and also with

runs = [2, 4, 6, 8]
files = eegbci.load_data(runs, "C:/Users/S_Hei/Documents/Python_Folder/B068a_VP2_EEG.eeg")

TypeError: unsupported format string passed to list.__ format __

I chose the numbers because I thought they would code the condition: (crossed/uncrossed)

Do I have to convert them into .edf files? Or maybe set EEG references (I do not really understand what that is used for or what it does)?

I also thought about using pybv, but if I understood it correctly, MNE should be able to handle those files.
I am running out of ideas :confused:

Thanks for reading

Only read_raw_brainvision can correctly read data stored in the BrainVision format, so you definitely need to go with option (1).

Can you try to cd into the directory where the files are located, start ipython, and run the following code snippet:

import mne
raw = mne.io.read_raw_brainvision("B068a_VP2_EEG.vhdr")

You mean
cd C:\Users\S_Hei\Documents\Python_Folder in Jupyter and then the other part in IPython? That gives the same error, but now it says

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\S_Hei\B068a_VP2_EEG.vhdr’

→ even though os.getcwd() tells me

‘C:\Users\S_Hei\Documents\Python_Folder’

(which should be the correct path), the path in IPython is incomplete for some reason.

import mne
raw = mne.io.read_raw_brainvision("C:/Users/S_Hei/Documents/Python_Folder/B068a_VP2_EEG.vhdr")

in IPython gives the exact same output as in Jupyter.
Not sure if it is relevant, but why does it say “…EEG.vmrk” in the error message? Maybe it can’t find the file because it is searching for the wrong type of file?

Yes, this might be the issue! The .vhdr seems to contain a reference to the .vmrk file. So you either have to provide that file (in the same directory), or open the .vhdr file in a text editor and remove this reference (but note that you won’t have any markers then).

Thanks, I will try that on monday.