kavli-ntnu / opexebo

Collection of python code for electrophysiology /ɪˌlɛktrəʊfɪzɪˈɒlədʒi/
MIT License
8 stars 7 forks source link

Error in fit_ellipse() #18

Closed horsto closed 4 years ago

horsto commented 5 years ago

During shuffling, errors were accumulating: File "/home/ubuntu/dj36/lib/python3.6/site-packages/opexebo/general/fitEllipse.py", line 102, in fit_ellipse\n eval_x, evec_x = np.linalg.eig(np.linalg.inv(tmpD) @ (tmpA - (tmpB@tmpE)))\n File "<__array_function__ internals>", line 6, in eig\n File "/home/ubuntu/dj36/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 1305, in eig\n _assertFinite(a)\n File "/home/ubuntu/dj36/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 218, in _assertFinite\n raise LinAlgError("Array must not contain infs or NaNs")\nnumpy.linalg.LinAlgError: Array must not contain infs or NaNs\n' Would be great if that could be avoided.

simon-ball commented 5 years ago

The immediate cause is that the linear alegebra in fit_ellipse doesn't handle non-finite numbers. Where those are coming from is less clear.

At a superficial level, the points passed to fit_ellipse are derived from the autocorrelegoram, and the autocorrelogram should be all finite, although I suspect that there are edge cases where this is not true. Best guess, these are showing up where the RateMap is majority-non-finite, leaving insufficient data for the autocorrelogram to work with. Since the autocorrelation is a custom function, it may be that it isn't handling MaskedArrays properly, and error is creeping in there

simon-ball commented 4 years ago

Fixed in #29