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

Problem converting ndarray to EDF+ #178

Closed superbin98 closed 1 year ago

superbin98 commented 2 years ago

Hello,

I am trying to create an EDF+ file from a Pandas dataframe. I convert the dataframe into a ndarray (df.to_numpy()).

When I pass the array into the function I get the following error message:

AssertionError: signals and signal_headers must be same length

The Shape of the given array is (738,15) and it contains floats and strings (because of the timestamp and the event channel).

I don't know why this error occurs because the length of my array is 15 and the header list is also 15.

channel_names = ['Time', 'PEEP', 'PIP', 'Insptime', 'JetFreq', 'O2-Conc', 'SpO2', 'tcpCO2', 'tPR', 'tPO2', 'tPI', 'tHP', 'Status', 'event', 'event_def'] headers = highlevel.make_signal_headers(channel_names) highlevel.write_edf(edf_file='edf_file.edf', signals=data, signal_headers=headers, file_type=1)

Is the problem because not all data have the same sample frequency and there are NaN Values?

skjerns commented 2 years ago

Currently the headers do not have any information about the sampling frequency, so they expect the data to have the same sampling frequency. You should edit those in the signal header accordingly to your data.