question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: import of EDF files with accentuated annotations

See original GitHub issue

Hey! So importing an EDF file, I have a crash

ValueError: byte must be in range(0, 256)

occuring at this level: https://github.com/mne-tools/mne-python/blob/f04d1460d10ebe3b9466ccad9c077040d42a6d5f/mne/io/edf/edf.py#L258

Digging into the code, I realize that the (French) people who have recorded the EEG may have put characters with accents.

By changing the above part of the code to :

try:
    tals.extend([i % 256, i // 256])
except:
    print i, tals[10:].decode('ascii', 'ignore')
    raise('DEBUG')

I obtained this:

-5779 0000+44+1166PHOTO 0.5Hz+45+1172+1172.200000+46+1172Yeux ouverts+47+1178+1178.840000+48+1178Yeux fer

It’s indeed French, and the error occurs exactly at the level of the annotation Yeux fer (if you take i = -5779, the i % 256 gives ‘m’, so I assume the original second character causing the bug was ‘é’…

So, what should be the best way to handle this?

Thanks! Guillaume

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
larsonercommented, Jul 13, 2016

Shall we just make a warning and replace the character with a neutral one?

It would be better to properly handle UTF-8 encoding. We do it everywhere else (that we know of), and if the file format allows it, there should be some reasonable way to do it.

0reactions
agramfortcommented, Aug 29, 2016

I think so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An error on importing some of my .edf files - Bugs - Brainstorm
I'm new to this software, and my research requires only Coherence NxN matrixes of different subjects. The issue is that the program prevents ......
Read more >
EDF+ / Annotations / Most are missing when importing the .edf ...
I've been trying to import some recordings that have events saved as annotations in the edf+ file and I'm having trouble to successfully...
Read more >
PyEDFlib Documentation - Read the Docs
PyEDFlib is a free Open Source wavelet toolbox for reading / writing EDF/EDF+/BDF files. import pyedflib import numpy as np.
Read more >
Bug 1726 – events are not loaded from EDF file
Just another precision: 1) With Matlab R2014b and Biosig 2.88, I have an error message similar to ayeriera 's bug Reading data in...
Read more >
AcqKnowledge Software Guide | BIOPAC
Data Acquisition and Analysis with BIOPAC MP Systems. Reference Manual for ... European Data Format (EDF) file import/export—pages X285H195X/X286H205X.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found