Loss of precision when converting to EDF

Hello!

We would like to minimize the loss of precision when exporting from Brainstorm to EDF.

It is indicated, in the EDF specs, that the floating point data can be scaled to fit into 2byte integer (int16).

Is there a functionality from Brainstorm to get that scaling factor when exporting ?

Or should we simply calculate a factor so that our minimum and maximum values can be represented in int16 (from -32768 to 32767) ?

Thank you for your time,
Corentin

Hi Corentin,

When exporting EDF+ files from Brainstorm, the correspondence between the int16 values and the physical values is computed in out_fopen_edf.m:

We don't recommend using the EDF+ format for saving double-precision values such as processed data saved in Brainstorm. From the BIDS-EEG specification, we recommend using the BrainVision format instead, which allows saving floating point values and avoids this loss of precision. The EDF+ should be used to saved only raw data which are actually available in int16 after an analog-to-digital conversion.

https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/03-electroencephalography.html#eeg-recording-data

Thank you Francois for your response.

One last question:

Does the analog-to-digital conversion need data in int16 as input ?
Can we use data in float32 or float64 as input and obtain data in int16 after the analog-to-digital conversion ?

Thank you again,
Corentin

Does the analog-to-digital conversion need data in int16 as input ?

The ADC transforms an analog physical signal into a digital value. In input, there is a current recorded by a pair of electrodes, in output an integer value. You have no control over this, this is part of the acquisition device.

Can we use data in float32 or float64 as input and obtain data in int16 after the analog-to-digital conversion ?

If you are referring to the conversion of Brainstorm data files (floating point double precision - 8 bytes) to EDF+ (int16 - 2 bytes): the general recommendation is to avoid it. From 8 bytes to 2 bytes, there is necessarily of loss of precision.