Use an exact +- dt window in spike_time_tiling_coefficient - #706
Use an exact +- dt window in spike_time_tiling_coefficient#706adityasingh2400 wants to merge 1 commit into
Conversation
run_p built the synchronicity window with np.isclose(t_j, t_i, atol=dt). np.isclose also applies its default relative tolerance rtol=1e-5, so the test is |t_j - t_i| <= dt + 1e-5 * |t_i| rather than |t_j - t_i| <= dt. Spike times are absolute, so the window grew with the distance of the recording from t = 0, and it was asymmetric between the two trains because rtol multiplies only the second argument. run_t computes the T terms with dt exactly, so P and T were being derived from different windows. The effect is a silently wrong coefficient rather than an error. Two spikes 12 ms apart with dt = 5 ms score -0.0005 when the recording starts at t = 0 and +1.0 when the same pair starts at t = 1000 s. For two independent 5 Hz Poisson trains over 600 s with dt = 5 ms, the STTC is +0.027 at t_start = 0 and +0.9998 once the recording carries wall-clock style timestamps, where the correct value is -0.003 throughout. Compare the times directly instead. This matches the documented [-dt, +dt] window, matches what run_t already does, and makes the result invariant under a shift of the whole recording in time. The comparison against C. Cutts' original C implementation in test_sttc_validation_test still passes. The relative tolerance came in with the vectorization in 8bac14c (NeuralEnsemble#564); it looks like an artifact of moving to np.isclose rather than a deliberate tolerance.
|
The three red jobs here are not from this branch. All three fail on the same two tests, This branch only changes |
|
Small addition to my earlier note: the Also, the Coveralls number on this PR, about 45.7 percent against a base of 88.6, is consistent with the failed jobs never uploading their coverage rather than with a real regression. The passing run still reports 773 passed and 5 skipped, with only the two |
|
Hello there, |
|
Correcting my note above, since the rerun has now happened and did not do what I predicted. I said a rerun should clear this once the network settled. Attempt 2 on
That is what #709 pins |
run_pbuilds the synchronicity window withnp.isclose(t_j, t_i, atol=dt).np.isclosealso applies its default relative tolerancertol=1e-5, so the test performed is|t_j - t_i| <= dt + 1e-5 * |t_i|rather than the documented|t_j - t_i| <= dt.Spike times are absolute, so the window grows with the distance of the recording from t = 0, and it is asymmetric between the two trains because
rtolmultiplies only the second argument.run_tcomputes the T terms withdtexactly, so P and T were being derived from different windows.The result is a silently wrong coefficient rather than an error:
The effective window is
dt + 1e-5*|t|. A requested 5 ms is already 11 ms at the end of an ordinary 10 minute recording, and 869 ms at t = 86400 s.This compares the times directly instead. It matches the documented
[-dt, +dt], it matches whatrun_talready does, and it makes the result invariant under a time shift of the whole recording.test_sttc_validation_test, which checks against C. Cutts' original C implementation, still passes.The relative tolerance came in with the vectorization in
8bac14c(#564) and looks like an artifact of moving tonp.iscloserather than a deliberate tolerance.Tested with two new cases in
elephant/test/test_spike_train_correlation.py, one pinning the window to exactly dt and one asserting invariance under a time shift. Revertingelephant/spike_train_correlation.pyto master makes both fail, the first withnp.float64(1.0) != -0.0005. The full file passes after at 37 passed and 12 subtests.pycodestyleis clean.Note the module doctest shows
np.float64(0.4958601655933762)against an expected0.4958601655933762. The value is identical and the difference is repr only, which is known issue #686, and CI forces legacy numpy printing.I have not added myself to
doc/authors.rst. It is a numbered institutional affiliation list and I did not want to presume, so please let me know if you would like an entry there.Disclosure: this change was prepared with AI assistance. I have reviewed and tested it.