Skip to content

Commit

Permalink
BUG: Fix GDF Out of Bound Error (mne-tools#13113)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Huberty <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 13, 2025
1 parent 77195a2 commit b4a7c64
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/changes/devel/13113.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug in :func:`mne.io.read_raw_gdf`, by :newcontrib:`Rongfei Jin`.
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
.. _Romain Derollepot: https://github.com/rderollepot
.. _Romain Trachel: https://fr.linkedin.com/in/trachelr
.. _Roman Goj: https://romanmne.blogspot.co.uk
.. _Rongfei Jin: https://github.com/greasycat
.. _Ross Maddox: https://medicine.umich.edu/dept/khri/ross-maddox-phd
.. _Rotem Falach: https://github.com/Falach
.. _Roy Eric Wieske: https://github.com/Randomidous
Expand Down
4 changes: 1 addition & 3 deletions mne/io/edf/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,9 +1453,7 @@ def _read_gdf_header(fname, exclude, include=None):
n_events = np.fromfile(fid, UINT32, 1)[0]
else:
ne = np.fromfile(fid, UINT8, 3)
n_events = ne[0]
for i in range(1, len(ne)):
n_events = n_events + int(ne[i]) * 2 ** (i * 8)
n_events = sum(int(ne[i]) << (i * 8) for i in range(len(ne)))
event_sr = np.fromfile(fid, FLOAT32, 1)[0]

pos = np.fromfile(fid, UINT32, n_events) - 1 # 1-based inds
Expand Down

0 comments on commit b4a7c64

Please sign in to comment.