pyxdf icon indicating copy to clipboard operation
pyxdf copied to clipboard

unpack requires a buffer of 8 bytes

Open agleontyev opened this issue 4 years ago • 6 comments

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.

agleontyev avatar Sep 14 '21 13:09 agleontyev

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

cbrnr avatar Sep 14 '21 13:09 cbrnr

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.

agleontyev avatar Sep 14 '21 14:09 agleontyev

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?

cbrnr avatar Sep 14 '21 15:09 cbrnr

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.

agleontyev avatar Sep 14 '21 15:09 agleontyev

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

cbrnr avatar Sep 15 '21 09:09 cbrnr

@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?

tstenner avatar Sep 15 '21 09:09 tstenner

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

cbrnr avatar Jul 18 '24 09:07 cbrnr