Skip to content

Commit

Permalink
Fix _parse_prefilter_string to remain non-filtered channels
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmdnk committed Dec 28, 2023
1 parent 6790426 commit c224fdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
28 changes: 10 additions & 18 deletions mne/io/edf/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,26 +758,18 @@ def _get_info(
return info, edf_info, orig_units


def _extract_filter_value(s, prefix, suffix):
if prefix in s:
start = s.find(prefix) + len(prefix)
end = s.find(suffix, start)
return s[start:end].strip()
return None


def _parse_prefilter_string(prefiltering):
"""Parse prefilter string from EDF+ and BDF headers."""
highpass = np.array(
[
v
for hp in [
re.findall(r"HP:\s*([0-9]+[.]*[0-9]*)", filt) for filt in prefiltering
]
for v in hp
]
)
lowpass = np.array(
[
v
for hp in [
re.findall(r"LP:\s*([0-9]+[.]*[0-9]*)", filt) for filt in prefiltering
]
for v in hp
]
)
highpass = [_extract_filter_value(s, "HP:", "Hz") for s in prefiltering]
lowpass = [_extract_filter_value(s, "LP:", "Hz") for s in prefiltering]
return highpass, lowpass


Expand Down
5 changes: 5 additions & 0 deletions mne/io/edf/tests/test_edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@ def test_edf_prefilter_parse():
assert_array_equal(highpass, ["0.1"])
assert_array_equal(lowpass, ["75"])

prefilter_edf_specs_doc = ["", "HP:0.1Hz LP:75Hz N:50Hz", ""]
highpass, lowpass = _parse_prefilter_string(prefilter_edf_specs_doc)
assert_array_equal(highpass, [None, "0.1", None])
assert_array_equal(lowpass, [None, "75", None])


@testing.requires_testing_data
@pytest.mark.parametrize("fname", [test_generator_edf, test_generator_bdf])
Expand Down

0 comments on commit c224fdc

Please sign in to comment.