Skip to content

Commit

Permalink
FIX: gracefully handle bad patient info in edf reader (#12968)
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-huberty authored Nov 15, 2024
1 parent d810cc5 commit ede7f01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/changes/devel/12968.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gracefully handle invalid patient info when reading EDF files by `Scott Huberty`_.
13 changes: 11 additions & 2 deletions mne/io/edf/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,10 +824,19 @@ def _read_edf_header(
for info in id_info[4:]:
if "=" in info:
key, value = info.split("=")
err = f"patient {key} info cannot be {value}, skipping."
if key in ["weight", "height"]:
patient[key] = float(value)
try:
patient[key] = float(value)
except ValueError:
logger.debug(err)
continue
elif key in ["hand"]:
patient[key] = int(value)
try:
patient[key] = int(value)
except ValueError:
logger.debug(err)
continue
else:
warn(f"Invalid patient information {key}")

Expand Down

0 comments on commit ede7f01

Please sign in to comment.