Skip to content

Commit aafa189

Browse files
Hypnodyne zmax EDFs fix (#10754)
* enables reading edfs of zmax hypnodyne Zmax hypnodyne EDFs could not be read in due to their header having comma float values instead of point float values in the physical dimension. This addition fixes the reading while not changing support for other EDFs. * Update edf.py * style correction make flake happy * dont delete header info from edf edf_info['physical_min'] and edf_info['digital_min'] are not deleted as redundant as they are vital for reconstruction of the original signals * revert delete private header info * Update names.inc * Update latest.inc Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent a424fba commit aafa189

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

doc/changes/latest.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Enhancements
107107

108108
Bugs
109109
~~~~
110+
- Fix bug in :func:`mne.io.read_raw_edf` to allow reading in all Hypnodyne ZMax EDFs to be read in without issues (:gh:`10754` by :newcontrib:`Frederik Weber`)
110111

111112
- Fix bug in :func:`mne.Epochs.drop_bad` where data was loaded although no rejection had to be performed (:gh:`10718` by :newcontrib:`Lukas Gemein`)
112113

doc/changes/names.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,5 @@
455455
.. _Jordan Drew: https://github.com/jadrew43
456456
457457
.. _Lukas Gemein: https://github.com/gemeinl
458+
459+
.. _Frederik Weber: https://github.com/Frederik-D-Weber

mne/io/edf/edf.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ def _edf_str(x):
601601
return x.decode('latin-1').split('\x00')[0]
602602

603603

604+
def _edf_str_num(x):
605+
return _edf_str(x).replace(",", ".")
606+
607+
604608
def _read_edf_header(fname, exclude, infer_types, include=None):
605609
"""Read header information from EDF+ or BDF file."""
606610
edf_info = {'events': []}
@@ -736,13 +740,13 @@ def _read_edf_header(fname, exclude, infer_types, include=None):
736740
orig_units = dict(zip(ch_names, units))
737741

738742
physical_min = np.array(
739-
[float(_edf_str(fid.read(8))) for ch in channels])[sel]
743+
[float(_edf_str_num(fid.read(8))) for ch in channels])[sel]
740744
physical_max = np.array(
741-
[float(_edf_str(fid.read(8))) for ch in channels])[sel]
745+
[float(_edf_str_num(fid.read(8))) for ch in channels])[sel]
742746
digital_min = np.array(
743-
[float(_edf_str(fid.read(8))) for ch in channels])[sel]
747+
[float(_edf_str_num(fid.read(8))) for ch in channels])[sel]
744748
digital_max = np.array(
745-
[float(_edf_str(fid.read(8))) for ch in channels])[sel]
749+
[float(_edf_str_num(fid.read(8))) for ch in channels])[sel]
746750
prefiltering = [_edf_str(fid.read(80)).strip() for ch in channels][:-1]
747751
highpass, lowpass = _parse_prefilter_string(prefiltering)
748752

0 commit comments

Comments
 (0)