uwmadison-chm / bioread

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

error: unpack requires a buffer of 40 bytes #34

Closed alexander-maier closed 3 years ago

alexander-maier commented 3 years ago

Hey,

I can't read the attached file:

testfile.zip

I'm getting the following error:

Traceback (most recent call last): File "", line 7, in File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread__init.py", line 26, in read return reader.Reader.read(filelike, channel_indexes).datafile File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread\reader.py", line 85, in read reader._read_headers() File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread\reader.py", line 131, in _read_headers pad_header = self.single_header(ch_start, UnknownPaddingHeader) File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread\reader.py", line 266, in single_header return self.__multi_headers(1, start_offset, h_class)[0] File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread\reader.py", line 278, in multi_headers h.unpack_from_file(self.acq_file, h_offset) File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread\headers.py", line 45, in unpack_from_file self.__unpack_data() File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread\headers.py", line 59, in __unpack_data self.data = self.struct_dict.unpack(self.raw_data) File "C:\Users\User\Anaconda3\envs\py37\lib\site-packages\bioread\struct_dict.py", line 58, in unpack unpacked = struct.unpack(self.format_string, data) struct.error: unpack requires a buffer of 40 bytes

njvack commented 3 years ago

Hi Alexander,

It doesn't look like this file was made by AcqKnowledge; the start of the file has:

FILE FORMAT=RigSys
FORMAT ISSUE=001.002
VARIANT=Standardised data file format (c) IST, 1998.
EMPTY HEADER CHARACTER=ASCII 128
THIS HEADER BLOCK=ASCII
HEADER SIZE=1024
DATA COMPLEXITY=3
CHANNEL HEADER SIZE=512
FRAME HEADER SIZE=256
BLOCK SCANS PER FRAME=1
HISTORY LENGTH=1019
SAMPLE INTERVAL=0.010000000000000
FILE DESCRIPTION=
NCHANNELS=3
CYCLIC FRAMES=0
START FRAME=0
END FRAME=2
NUMBER OF SECTIONS=0
SECTION SIZE=512
ORIGIN=
REFERENCE TIME=
START TIME=
LOGICAL FILE LENGTH=6000

Maybe it's from some kind of old "RigSys" thing?

If it's really from 1998-era software, it's also possible it's from some ancient version of a Biopac that I've never seen before.

alexander-maier commented 3 years ago

I think you're right. It seems that this file was not made by AcqKnowledge. I initially searched for the file ending. Thanks for helping.

For anyone having a similar issue, I found a Matlab script to read the file:

https://mathworks.com/matlabcentral/fileexchange/9500-load-rigsys-acq-files