diff --git a/doc/changes/devel/12968.bugfix.rst b/doc/changes/devel/12968.bugfix.rst new file mode 100644 index 00000000000..a512cc34ad6 --- /dev/null +++ b/doc/changes/devel/12968.bugfix.rst @@ -0,0 +1 @@ +Gracefully handle invalid patient info when reading EDF files by `Scott Huberty`_. \ No newline at end of file diff --git a/mne/io/edf/edf.py b/mne/io/edf/edf.py index 59ea7ab4870..bb79c46f24a 100644 --- a/mne/io/edf/edf.py +++ b/mne/io/edf/edf.py @@ -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}")