Problems importing EDFs - wrong amplitude values

Hi,
I am trying to import EDF files from natus.
When importing the EDFs i get a warning "physical maximum larger than minimum" and the signal amplitudes are messed up.

In older Natus EDFs before 2022, this error does not occur and the amplitude values are maintained.

I tried reading the EDFs in matlab's new edfread included with the signal processing toolbox 2023 and the older edfread from the mathworks repository. The amplitude is consistent with EDF browser.

The problem only exists with the brainstorms EDF importer. Please take a look at it as soon as possible.
My guess is that the header is not read properly and the amplitude is set to -32768 to 32767.
Thank you

Hi @nmakaram,

Could you share an example of a EDF file to reproduce the trouble?

Best,
Raymundo

test_edf_deidentified.EDF (1.9 MB)
Here you go just look at the header and the amplitude of ECG2

Hi @nmakaram, thank you for sharing the example to fix explore the issue.
This is now addressed in commit 0ea4396
Please update your Brainstorm instance to get the updated.

There is a typo in the warning (also fixed), it should have stated:
"Warning: Physical minimum larger than physical maximum"
as this is the case with the data in the header:

So, when importing the EDF file, the warning will still be there.

This condition lead to a negative gain, which was incorrectly handled in Brainstorm as this condition is unusual. This change may have been introduced in the EDF writing code from Natus.

Check Question 6 in the EDF specification FAQ:
EDF FAQ

While the Digital maximum must be larger than Digital minimum, Physical maximum can be smaller than the Physical minimum, this is often done to indicate negativity upward i.e., to plot negative values on top.
Point 5 in Section 2.1.3: EDF+ specification

This can be done in Brainstorm with the buttons:

  • Positive values up:iconYup

  • Negative values up: iconYdown

Example:
image

Thanks for solving the issue.