# Problems reading .vhdr and .eeg files

**URL:** <https://mne.discourse.group/t/problems-reading-vhdr-and-eeg-files/3133>\
**Category:** Support & Discussions\
**Created:** [May 13, 2021, 1:33pm UTC](https://mne.discourse.group/t/problems-reading-vhdr-and-eeg-files/3133 "2021-05-13T13:33:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nyorunn](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nyorunn/32/455_2.png) [@Nyorunn](https://mne.discourse.group/u/Nyorunn)\
**Post date:** [May 13, 2021, 1:33pm UTC](https://mne.discourse.group/t/problems-reading-vhdr-and-eeg-files/3133/1 "2021-05-13T13:33:25Z")

</div>

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](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 🙁

2.) .eeg  
 → I tried it with [Importing data from EEG devices — MNE 1.6.0 documentation](https://mne.tools/stable/auto_tutorials/io/20_reading_eeg_data.html)

`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](https://mne.tools/stable/generated/mne.io.read_raw_eeglab.html)  
`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

```python
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)

 ![Screenshot (242)](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/53a6621f7e953d016ec005c8fcf3c134ed85f5ae.png)

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 😕

Thanks for reading

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [May 13, 2021, 1:44pm UTC](https://mne.discourse.group/t/problems-reading-vhdr-and-eeg-files/3133/2 "2021-05-13T13:44:45Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![Nyorunn](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nyorunn/32/455_2.png) [@Nyorunn](https://mne.discourse.group/u/Nyorunn)\
**Post date:** [May 14, 2021, 7:19am UTC](https://mne.discourse.group/t/problems-reading-vhdr-and-eeg-files/3133/3 "2021-05-14T07:19:40Z")

</div>

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.

```python
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?

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [May 14, 2021, 1:45pm UTC](https://mne.discourse.group/t/problems-reading-vhdr-and-eeg-files/3133/4 "2021-05-14T13:45:32Z")

</div>

> [@Nyorunn](#):
>
> 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).

---

<div class="post-metadata">

**Author:** ![Nyorunn](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nyorunn/32/455_2.png) [@Nyorunn](https://mne.discourse.group/u/Nyorunn)\
**Post date:** [May 15, 2021, 6:47am UTC](https://mne.discourse.group/t/problems-reading-vhdr-and-eeg-files/3133/5 "2021-05-15T06:47:57Z")

</div>

Thanks, I will try that on monday.
