sccn / xdf

BSD 2-Clause "Simplified" License
87 stars 34 forks source link

pyxdf: rcond=None or rcond=-1? #44

Closed BCIstorm closed 5 years ago

BCIstorm commented 5 years ago

I'm trying to read a XDF in Python 2.7.14. Executing the provided example by pyxdf, at the end there's an error:

.
.
.
DEBUG:pyxdf: Read tag: 3 at 6579007 bytes, length=197971, StreamId=2
DEBUG:pyxdf:  reading [2,21952]
DEBUG:pyxdf: Read tag: 6 at 6776983 bytes, length=452, StreamId=3
DEBUG:pyxdf: Read tag: 6 at 6777440 bytes, length=456, StreamId=2
DEBUG:pyxdf: Read tag: 6 at 6777901 bytes, length=449, StreamId=1
DEBUG:pyxdf: Read tag: 6 at 6778355 bytes, length=450, StreamId=4
INFO:pyxdf:  reached end of file.
INFO:pyxdf:  performing clock synchronization...
INFO:pyxdf:  performing jitter removal...
Traceback (most recent call last):
  File "example.py", line 10, in <module>
    streams, fileheader = pyxdf.load_xdf(fname)
  File "C:\Users\Pedro\Documents\PhD\py\XDF\xdf_zip\Python\example\pyxdf.py", line 362, in load_xdf
    jitter_break_threshold_samples,)
  File "C:\Users\Pedro\Documents\PhD\py\XDF\xdf_zip\Python\example\pyxdf.py", line 539, in _jitter_removal
    mapping = np.linalg.lstsq(X, y, rcond=None)[0]
  File "C:\Users\Pedro\Anaconda2\lib\site-packages\numpy\linalg\linalg.py", line 1915, in lstsq
    0, work, -1, iwork, 0)
TypeError: a float is required

Any help?

cboulay commented 5 years ago

Change this line from rcond=None to rcond=-1. I still don't know if numpy has settled on what format they want.

BTW, Python 2 support might break at any time as it isn't explicitly tested against. Even if the pyxdf code is Python 2 compatible, it might depend on libraries that drop python 2 compatibility. Edit: Numpy dropped py2.7 support at the end of 2018 (source), which means anything v1.16 and on will probably not work with Python 2.

cboulay commented 5 years ago

FYI: Compare the numpy manual for np.linalg.lstsq between v1.13 and v1.14. If we want to use the updated behaviour in numpy >= 1.14 then we need rcond=None, but this is not backwards compatible with numpy <= 1.13.

BCIstorm commented 5 years ago

Thank you @cboulay , the change worked!