# Overflow error when trying to read GDF

**URL:** https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432
**Category:** Support & Discussions
**Tags:** preprocessing, eeg
**Created:** [October 21, 2024, 2:30pm UTC](https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432 "2024-10-21T14:30:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Groenborg14](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/groenborg14/32/3945_2.png) [@Groenborg14](https://mne.discourse.group/u/Groenborg14)
#### Post date: [October 21, 2024, 2:30pm UTC](https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432/1 "2024-10-21T14:30:17Z")

</div>

MNE Version 1.8.0  
OS Ubuntu 24.04.1 LTS

Hello

I am trying to read a GDF file for a MI run from Ofner 2017 dataset [Upper limb movements can be decoded from the time-domain of low-frequency EEG](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0182578)

When i try to load a single gdf file in, i get the following error:

```python
File "/home/groenborg/venv/lib/python3.12/site-packages/mne/io/edf/edf.py", line 1901, in read_raw_gdf
    return RawGDF(
           ^^^^^^^
  File "<decorator-gen-204>", line 12, in __init__
  File "/home/groenborg/venv/lib/python3.12/site-packages/mne/io/edf/edf.py", line 293, in __init__
    info, edf_info, orig_units = _get_info(
                                 ^^^^^^^^^^
  File "/home/groenborg/venv/lib/python3.12/site-packages/mne/io/edf/edf.py", line 537, in _get_info
    edf_info, orig_units = _read_header(
                           ^^^^^^^^^^^^^
  File "/home/groenborg/venv/lib/python3.12/site-packages/mne/io/edf/edf.py", line 515, in _read_header
    return _read_gdf_header(fname, exclude, include), None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groenborg/venv/lib/python3.12/site-packages/mne/io/edf/edf.py", line 1445, in _read_gdf_header
    n_events = n_events + ne[i] * 2 ** (i * 8)
                          ~~~~~~^~~~~~~~~~~~~~
OverflowError: Python integer 256 out of bounds for uint8

```

My code currently looks like this:

```python
path_to_gdf = "Data/S06_MI/motorimagination_subject6_run4.gdf"
raw = mne.io.read_raw_gdf(path_to_gdf, eog=['EOG left','EOG middle','EOG right'],exclude=(65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96))
events = mne.events_from_annotations(raw)

```

I thought it would work by exluding all the sensor channels (Exoskeleton and glove sensors) but i get the same error and i have no clue why. I’m very new to MNE in general but could not find anything in the documentation. It does say “GDF file detected” but then it ends with that error.

---

<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: [October 21, 2024, 2:35pm UTC](https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432/2 "2024-10-21T14:35:04Z")

</div>

I think this issue has already been reported here:

> [@Error loading GDF file with MNE: Python integer 256 out of bounds for uint8](https://mne.discourse.group/t/error-loading-gdf-file-with-mne-python-integer-256-out-of-bounds-for-uint8/10410):
>
> Need Help Reading EEG Data in.GDF Format Hello everyone, I’ve been working on a project involving EEG data analysis for the past couple of days, but I’m encountering a persistent issue. I’m trying to read my signal data from a . GDF file, but I’m running into an error that I can’t seem to resolve. Details: File Format: .GDF Error Message: [Error loading GDF file with MNE: Python integer 256 out of bounds for uint8] I would greatly appreciate any guida…

@Groenborg14 can you please post the output of `mne.sys_info()`?

---

<div class="post-metadata">

### Author: ![Groenborg14](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/groenborg14/32/3945_2.png) [@Groenborg14](https://mne.discourse.group/u/Groenborg14)
#### Post date: [October 21, 2024, 2:38pm UTC](https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432/3 "2024-10-21T14:38:47Z")

</div>

I couldn’t find a definitive answer in that post though i may be overlooking something. Here is the output:

```python
Platform Linux-6.8.0-47-generic-x86_64-with-glibc2.39
Python 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0]
Executable /home/groenborg/venv/bin/python
CPU x86_64 (12 cores)
Memory Unavailable (requires "psutil" package)
Core
├☑ mne 1.8.0 (latest release)
├☑ numpy 2.1.2 (unknown linalg bindings (threadpoolctl module not found: No module named 'threadpoolctl'))
├☑ scipy 1.14.1
└☑ matplotlib 3.9.2 (backend=agg)

Numerical (optional)
└☐ unavailable sklearn, numba, nibabel, nilearn, dipy, openmeeg, cupy, pandas, h5io, h5py

Visualization (optional)
└☐ unavailable pyvista, pyvistaqt, vtk, qtpy, ipympl, pyqtgraph, mne-qt-browser, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy, pybv

```

It is the exact same version as the other person so could very well be the same issue.

---

<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: [October 21, 2024, 2:47pm UTC](https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432/4 "2024-10-21T14:47:56Z")

</div>

I can confirm this problem, which is caused by our GDF reader being incompatible with NumPy \>= 2. I’ve opened an issue [here](https://github.com/mne-tools/mne-python/issues/12907). In the meantime, you can downgrade NumPy to e.g. 1.26.4, which fixes this issue.

---

<div class="post-metadata">

### Author: ![Groenborg14](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/groenborg14/32/3945_2.png) [@Groenborg14](https://mne.discourse.group/u/Groenborg14)
#### Post date: [October 21, 2024, 2:49pm UTC](https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432/5 "2024-10-21T14:49:18Z")

</div>

Roger that, thank you very much!

---

<div class="post-metadata">

### Author: ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)
#### Post date: [October 28, 2024, 2:49pm UTC](https://mne.discourse.group/t/overflow-error-when-trying-to-read-gdf/10432/6 "2024-10-28T14:49:57Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
