xdf-modules / pyxdf

Python package for working with XDF files
BSD 2-Clause "Simplified" License
34 stars 16 forks source link

unpack requires a buffer of 8 bytes #78

Closed agleontyev closed 1 month ago

agleontyev commented 3 years ago

Hi! I am trying to read in an .xdf file (streamed physiological data). However, i get the following error:

  File "C:\Users\agleo\anaconda3\lib\site-packages\pyxdf\pyxdf.py", line 335, in load_xdf
    struct.unpack("<d", f.read(8))[0]

error: unpack requires a buffer of 8 bytes

This error only occurs at a certain point in reading a file. In other words, if turn the debug output on, this only happens way down the line.

cbrnr commented 3 years ago

This looks like your file might be corrupted. Can you load other XDF files normally?

agleontyev commented 3 years ago

I can read some, but not others. I used Matlab function, and this one actually read in the file, but with this error:

got error "MATLAB:matrix:singleSubscriptNumelMismatch" (Unable to perform assignment because the left and right sides have a different number of elements.), scanning forward to next boundary chunk. scan forward reached end of file with no match.

cbrnr commented 3 years ago

What do you mean by the MATLAB function read in the file? Didn't it throw the error you are mentioning? @tstenner do you know if there is a tool that checks if a given XDF file is valid?

agleontyev commented 3 years ago

In mean that I tried reading this file using Matlab, via the function in xdf-Matlab. Matlab throws an error, but I can see and access the array with stream information, time stamps and time series.

cbrnr commented 3 years ago

What is the result of pyxdf.resolve_streams() on that file?

tstenner commented 3 years ago

@tstenner do you know if there is a tool that checks if a given XDF file is valid?

That was part of a grant application that didn't go through. Maybe XDFBrowser?

cbrnr commented 1 month ago

If you are still encountering this problem, please feel free to open a new issue (and ideally share the problematic file).