uwmadison-chm / bioread

Utilities to work with files from BIOPAC's AcqKnowlege software
MIT License
66 stars 23 forks source link

UnicodeDecodeError when opening files #24

Closed agharibans closed 4 years ago

agharibans commented 5 years ago

I'm getting the following error when trying to open files recorded in Acqknowledge 3.8.1.

/usr/local/lib/python3.6/dist-packages/bioread/__init__.py in read(filelike, channel_indexes)
     24     target_chunk_size:  A guide for the number of bytes to read at a time.
     25     """
---> 26     return reader.Reader.read(filelike, channel_indexes).datafile
     27 
     28 # Deprecated; provided for compatibility with previous versions.

/usr/local/lib/python3.6/dist-packages/bioread/reader.py in read(cls, fo, channel_indexes, target_chunk_size)
     72         with open_or_yield(fo, 'rb') as io:
     73             reader = cls(io)
---> 74             reader._read_headers()
     75             reader._read_data(channel_indexes, target_chunk_size)
     76         return reader

/usr/local/lib/python3.6/dist-packages/bioread/reader.py in _read_headers(self)
    141         self._read_markers()
    142         try:
--> 143             self._read_journal()
    144         except struct.error:
    145             logger.info("No journal information found.")

/usr/local/lib/python3.6/dist-packages/bioread/reader.py in _read_journal(self)
    164         self.journal_header = None
    165         if self.file_revision <= rev.V_400B:
--> 166             self.__read_journal_v2()
    167         else:
    168             self.__read_journal_v4()

/usr/local/lib/python3.6/dist-packages/bioread/reader.py in __read_journal_v2(self)
    181         self.journal = self.acq_file.read(
    182             self.journal_header.data['lJournalLen']).decode(
--> 183             'utf-8').strip('\0')
    184 
    185     def __read_journal_v4(self):

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 10: invalid start byte
dgfitch commented 5 years ago

Hello! Thanks for the bug report. Both bioread maintainers are pretty busy this month, so response from us may be a bit slow...

Can you please post results of a run with --verbose? Thanks!

njvack commented 4 years ago

Hi @agharibans!

Yes, thank you for the bug report. Is there any chance you can share the file you're having trouble reading?

Also, what version of Python are you running?

njvack commented 4 years ago

Never mind, I looked at the output and it's Python 3.6. Right now, bioread only works with Python 2; getting it going in Py3 is a good plan but not at the top of our list right now. Previously, I wanted to be sure it would work with both 2 and 3, but at this point, dropping support for Python 2 is probably fine.

If you install this with Python 2.7, it should work fine; I'm going to close the ticket — technically, this is probably a duplicate of #25. If that doesn't work, feel free to re-open this ticket.