Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect/correct invalid HP/LP settings in EDF/BDF/GDF #8584

Merged
merged 5 commits into from Dec 2, 2020

Conversation

cbrnr
Copy link
Contributor

@cbrnr cbrnr commented Nov 30, 2020

Fixes #8582. EDF/BDF/GDF files can contain invalid LP/HP filter settings (cutoff frequencies for HP can be greater than the one for LP). This PR (1) issues a warning and (2) sets HP/LP values for affected channels to None.

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 30, 2020

@apospraf loading files from BCI Competition IV 2B works as expected with this PR.

@cbrnr cbrnr requested a review from larsoner November 30, 2020 17:06
@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 30, 2020

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to add a quick test via monkeypatch (probably of _read_edf_header)? If not I can see if it's easy and push if so

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 30, 2020

Please go ahead and add a test, I won't have time until tomorrow.

@larsoner
Copy link
Member

I don't think the current approach quite works properly, for example it doesn't handle '0.0' and '0.000' because they are strings

>>> '0.0' < '0.000'
True

Moreover sometimes edf_info['highpass'] can have length zero and edf_info['lowpass'] can have length n_channels, which fails the NumPy < comparison on latest NumPy dev. It seems safer to deal with these being reversed when actually setting info['highpass'] and info['lowpass'], but maybe not. I'm pushing a commit with this approach and a test that asserts it works for the monkeypatch code at least.

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @cbrnr

mne/io/edf/edf.py Outdated Show resolved Hide resolved
mne/io/edf/edf.py Outdated Show resolved Hide resolved
@larsoner
Copy link
Member

larsoner commented Dec 1, 2020

@cbrnr all good now?

@cbrnr
Copy link
Contributor Author

cbrnr commented Dec 1, 2020

Yes, perfect!

@larsoner larsoner merged commit 01a6ec0 into mne-tools:master Dec 2, 2020
1 check passed
@cbrnr cbrnr deleted the warn-edf-lp-hp branch December 2, 2020 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in mne.io.read_raw_gdf()
3 participants