Skip to content

Commit b4a7c64

Browse files
greasycatscott-hubertypre-commit-ci[bot]
authored
BUG: Fix GDF Out of Bound Error (mne-tools#13113)
Co-authored-by: Scott Huberty <52462026+scott-huberty@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 77195a2 commit b4a7c64

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

doc/changes/devel/13113.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug in :func:`mne.io.read_raw_gdf`, by :newcontrib:`Rongfei Jin`.

doc/changes/names.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
.. _Romain Derollepot: https://github.com/rderollepot
258258
.. _Romain Trachel: https://fr.linkedin.com/in/trachelr
259259
.. _Roman Goj: https://romanmne.blogspot.co.uk
260+
.. _Rongfei Jin: https://github.com/greasycat
260261
.. _Ross Maddox: https://medicine.umich.edu/dept/khri/ross-maddox-phd
261262
.. _Rotem Falach: https://github.com/Falach
262263
.. _Roy Eric Wieske: https://github.com/Randomidous

mne/io/edf/edf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,9 +1453,7 @@ def _read_gdf_header(fname, exclude, include=None):
14531453
n_events = np.fromfile(fid, UINT32, 1)[0]
14541454
else:
14551455
ne = np.fromfile(fid, UINT8, 3)
1456-
n_events = ne[0]
1457-
for i in range(1, len(ne)):
1458-
n_events = n_events + int(ne[i]) * 2 ** (i * 8)
1456+
n_events = sum(int(ne[i]) << (i * 8) for i in range(len(ne)))
14591457
event_sr = np.fromfile(fid, FLOAT32, 1)[0]
14601458

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

0 commit comments

Comments
 (0)