Skip to content

Commit

Permalink
support only list (or np.ndarray) in _set_prefilter (edf, bdf return …
Browse files Browse the repository at this point in the history
…highpass/lowpass of ndarray of str to _get_info. gdf returns highpass/lowpass of ndarray of np.float32 to _get_info)
  • Loading branch information
rcmdnk committed Feb 19, 2024
1 parent 74fb876 commit d22a503
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions mne/io/edf/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,8 @@ def _prefilter_float(filt):


def _set_prefilter(info, edf_info, key):
if key not in edf_info:
return
value = 0
values = edf_info[key]
if isinstance(values, (int, float, np.number)):
value = values
elif len(values):
if len(values := edf_info.get(key, [])):
if len(np.unique(values)) > 1:
warn(
f"Channels contain different {key} filters. "
Expand Down
4 changes: 2 additions & 2 deletions mne/io/edf/tests/test_edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,11 @@ def test_edf_prefilter_float(prefilter_string, expected):
({"highpass": ["0"], "lowpass": ["1.1"]}, -1, 1.1, False, False),
({"highpass": [""], "lowpass": [""]}, -1, -1, False, False),
({"highpass": ["DC"], "lowpass": [""]}, -1, -1, False, False),
({"highpass": [1], "lowpass": [2]}, 1, 2, False, False),
({"highpass": [np.nan], "lowpass": [np.nan]}, -1, -1, False, False),
({"highpass": ["1", "2"], "lowpass": ["3", "4"]}, 2, 3, True, True),
({"highpass": [np.nan, 1], "lowpass": ["", 3]}, 1, 3, True, True),
({"highpass": [np.nan, np.nan], "lowpass": [1, 2]}, -1, 1, False, True),
({"highpass": 1, "lowpass": 2}, 1, 2, False, False),
({"highpass": np.nan, "lowpass": np.nan}, -1, -1, False, False),
({}, -1, -1, False, False),
],
)
Expand Down

0 comments on commit d22a503

Please sign in to comment.