Fix export to EDF format with a set physical range smaller than the data range #11569
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today, I had a researcher from our sleep lab that came-in with a ~8 hours long night recording that could not be converted to EDF either through the BrainVision software or through MNE. The converted signals were all "flat" (or mostly flat), and this was due to 10' in the recording (around hour 7 ) where the signal went completely off-scale, for whatever reason.
The physical range is estimated here
mne-python/mne/export/_edf.py
Lines 122 to 131 in 6384a89
On a good file, I get:
pmin = ~ -130kandpmax= ~ 80k. The range is in the~ 250kscale. On the bad file, the range was in the~ 10Mor100Mrange, several order of magnitude larger. Thus, the conversion failed.By setting the
physical_rangeto(-150000, 80000)in the BrainVision software or in MNE, the data could be exported to EDF and the 10' segment off-scale is saturating as expected. However, in MNE, I did have to comment out this sanity-checkmne-python/mne/export/_edf.py
Lines 143 to 149 in 6384a89
I am not familiar at all with the EDF format, and might be missing something; but IMO it should be a warning instead of a raise.