Skip to content

Commit 571b17c

Browse files
authored
FIX: Avoid iteration errors caused by None when reading Nihon Kohden .LOG files (#13915)
1 parent c1b048c commit 571b17c

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

doc/changes/dev/13915.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix iteration errors in :func:`mne.io.read_raw_nihon` when reading log files, by `Tom Ma`_.

mne/io/nihon/nihon.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,23 @@ def _read_nihon_header(fname):
289289

290290

291291
def _read_event_log_block(fid, t_block, version):
292+
empty_logs = np.empty(0, dtype="|S45")
293+
292294
fid.seek(0x92 + t_block * 20)
293295
data = np.fromfile(fid, np.uint32, 1)
294296
if data.size == 0 or data[0] == 0:
295-
return
297+
return empty_logs
296298
t_blk_address = data[0]
297299

298300
fid.seek(t_blk_address + 0x1)
299301
data = np.fromfile(fid, "|S16", 1).astype("U16")
300302
if data.size == 0 or data[0] != version:
301-
return
303+
warn(f"Event log version mismatch: expected '{version}', got '{data}'")
302304

303305
fid.seek(t_blk_address + 0x12)
304306
data = np.fromfile(fid, np.uint8, 1)
305307
if data.size == 0:
306-
return
308+
return empty_logs
307309
n_logs = data[0]
308310

309311
fid.seek(t_blk_address + 0x14)

0 commit comments

Comments
 (0)