holgern / pyedflib

pyedflib is a python library to read/write EDF+/BDF+ files based on EDFlib.
http://pyedflib.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
214 stars 121 forks source link

can't write an edf with a signal including np.NaN values #219

Closed CyrilLeMat closed 1 year ago

CyrilLeMat commented 1 year ago

Hi,

I may misunderstand how to use the pyedflib library, but it seems impossible to write a edf file with missing values (which would reflect in np.NaN in a numpy array)

example:

from pyedflib import highlevel
signals = [np.array([1, 2, np.NaN, 3])]
highlevel.write_edf('test.edf', signals, highlevel.make_signal_headers(['ch1']), highlevel.make_header())
skjerns commented 1 year ago

Indeed, the edf standard does not allow missing values. You will need to replace them.

In the background, edf saves data as integers (digital amplifier values). Ints can't represent NaN.