pyedflib icon indicating copy to clipboard operation
pyedflib copied to clipboard

error when opening an edf file: the file is not EDF(+) or BDF(+) compliant (it contains format errors)

Open data-RanDan opened this issue 4 years ago • 5 comments

Hi This is my first time working with EDFs using Python. This is the error i get when trying to open them. the file is not EDF(+) or BDF(+) compliant (it contains format errors)

I couldn't find much information on-line, I saw that you answered a similar question in the past. any idea how can i solve the problem?

data-RanDan avatar Jun 29 '20 12:06 data-RanDan

Try opening and saving it with EDFBrowsers header editor (EDFBrowser->Tools->Header Editor). This often fixes the problem. Also EDFBrowser might give you some more details on where the error is.

skjerns avatar Jun 29 '20 13:06 skjerns

Can you please elaborate?

What is EDFBrowser? I have a couple of hundred files to open. Do I need to do this for all? Is there any method to do it for all in bulk?

xaishu avatar Dec 13 '20 17:12 xaishu

EDFBrowser uses the same library as we do in the background: https://www.teuniz.net/edfbrowser/

Download the program, start the header editor from the menu and try to repair the file (open it in header editor and just click save again). If that works it is repairable

Currently there is no way to do this in batch mode. But if the error is always the same you might be lucky by creating a script that repairs the header automatically. Often it's just a small format, e.g. the time is with a : instead of .. This can be easily solved by just opening it in binary mode and replacing the chars. I'd need a sample file to check that.

skjerns avatar Dec 13 '20 17:12 skjerns

This actually is one of the more annoying shortcomings of EDF in practice. Happens so very often. Would there be any way to fix it (I assume it is primarily a political problem, UTF-8 is not really that esoteric anymore, is it)?

NarayanSchuetz avatar Apr 17 '23 17:04 NarayanSchuetz

Behind this error there are actually a multitude of different problems. I have not encountered many UTF8 problems recently, most of the errors I saw were inconsistent use of specifications, i.e. wrong date format, time format, wrong use of digital min/max, etc. I trust edflib (the C library) to have the most accurate implementation of the EDF standard, which it also enforces very strictly.

skjerns avatar Apr 18 '23 13:04 skjerns