mariomulansky / PySpike

Python implementation of spike distance metrics
http://mariomulansky.github.io/PySpike
Other
71 stars 30 forks source link

Two division errors #80

Closed AustinNgs closed 4 months ago

AustinNgs commented 4 months ago

There is a ZeroDivisionError: float division by zero happens in: s1 = dt_f1(t_f1-t_p1) / isi1 s2 = dt_f2(t_f2-t_p2) / isi2

And another error: RuntimeWarning: invalid value encountered in double_scalars happens in: s2 = (dt_p2(t_f2-t_p1) + dt_f2(t_p1-t_p2)) / isi2

thomaskreuz commented 4 months ago

Hello Austin,

this must mean that some of your interspike intervals have zero length. Could it be that you have double spikes? Otherwise this should not happen.

If this should be the case then you could use the function reconcile_spike_trains() which applies three fixes to a list of SpikeTrain objects. It sorts the times, it removes all but one of any duplicated time, and it ensures all t_start and t_end values are compatible. Please also refer to the Section Spike trains in the tutorial ("https://mariomulansky.github.io/PySpike/").

Please let us know if this resolves the problem.

AustinNgs commented 4 months ago

Thanks so much for your reply. Actually, the errors are fixed after implementing "add_auxiliary_spike". After checking the spike train, this error occurs when there is only one spike in a spike train.

However, there is another strange thing that some SPIKE-distance is smaller than 0 (such as -11.9 or -1.2). I wonder is it reasonable?

thomaskreuz commented 4 months ago

Hello Austin,

no, this is certainly not reasonable. All distances should never be negative. Could you please send me an example for which you get this error so that I could try to reproduce it?

AustinNgs commented 4 months ago

Thanks for reply. I have fixed this negative value error. This package is working well and thanks for your great contributions!

thomaskreuz commented 4 months ago

Thanks a lot for your feedback. So I close the issue.