How to store
longintegers and floats
EDF+ are based on 2-byte integer data values. This page specifies
how to store longer-integer or floating-point data into these 2-byte
specification is formally part of EDF+.
Reference: Kemp B,
Penzel T, Värri AO, Sykacek
P, Roberts SJ, Nielsen KD. EDF: a simple format for graphical analysis
results from polygraphic SIESTA recordings. J Sleep Research 7, suppl.
Read this first
transformation was designed in the Biomed-2 project ‘SIESTA’,
BMH4-CT97-2040 led by Georg Dorffner (Vienna) and funded by the
Commission, DG XII.
In many cases, the floating point data
can be scaled to fit into
the available 2byte integer range of -32768 till 32767. The scaling
can be adapted to the dynamic range of the analysis result even after
analysis was done. Put these scaling factors in the header (digital and
physical minimum and maximum) of the analysis file. If such scaling is
really impossible because the useful dynamic range of the analysis
is too large, but only then, apply the below logarithmic
The transformation is formally part of EDF+, so EDF+ software will
apply the inverse transformation when reading the file. But old EDF
is not aware of this transformation and will show the analysis results
on a logarithmic scale.
So really try scaling first! In particular, be aware that no biological
signal needs more then 14 bits accuracy, even when sampled by a 22-bit
The idea is simple. Integers have
constant absolute inaccuracy (the
equal to 1. So their relative inaccuracy ranges from 0.03% (at
maxint) to 100% (at 1). A
transformation maps realtype values to 2-byte integer values in such a
way that the relative resolution is the same everywhere in a
range. Depending on this range, this constant relative resolution is
about 0.05% to 1%.
The transformation does not cause any
incompatibility with EDF and EDF+.
The transformation is logarithmic and symmetric around 0. It has
parameters a and Ymin. It converts floating-point values, Y, to 2-byte
integers, N. All float values between -Ymin and Ymin are rounded to
All values of Y larger than Ymin and smaller than –Ymin are
(with the LN being e-based) converted to N>0 and N<0,
The obtained integers, N, must be exponentially (with the EXP also
e-based) converted back to to the original float value, Y. The relative
resolution of this conversion is constant, i.e. Y(N)/Y(N-1) = EXP(a).
exact conversion formulas are:
So that EDF and EDF+ software will be
aware of the conversion, the ‘physical
dimension’ in the EDF or EDF+ fileheader must read ‘Filtered’. The
maximum’ = ‘digital maximum’ = ‘32767 ‘, and the ‘physical
minimum’ = ‘digital minimum’ =’-32767 ‘. Note that digital minimum is -32767, not -32768. The parameters a and
can be chosen freely and have to be specified, together with the
of the original signal, in the ‘prefiltering’ field of the header. This
field should contain ‘sign*LN[sign*(physical dimension)/(Ymin)]/(a)’ in
which ‘physical dimension’ and the values of a and Ymin are coded in
of 8 ASCII characters (left-justified and filled out with
For example if a=0.002 and Ymin=0.01 and the physical dimension of Y
‘uV ‘, then the prefiltering field should
|Float - to - Integer
||Integer back to Float
The accuracy of the
Y(1) and Y(-1) are the smallest float
values that can be distinguished
from 0. So, if Ymin=0.001, then all values between -0.001 and +0.001
rounded to 0.
Float values outside this range are
represented with the selected
accuracy, a. The relative accuracy is Y(N)/Y(N-1) = EXP(a). For
if a=0.005 (that is 0.5%) then floating point values that differ less
than 0.5% from
other are rounded to the same value. So, values 1.1226 - 1.1275 are
to 1.125, values 1.1276 - 1.1325 are rounded to 1.130 and so on. Also,
values 0.009824 - 0.009875 are rounded to 0.0985 and values 9824 - 9875
are rounded to 9850.
of Y (+ and -)
till 1.42 E+66
The top rows
show that floating-point variables can be stored in EDF+ with an
accuracy of 0.5%. Try other values of
a and Ymin in this spreadsheet.