Skip to content

Fix STTC coincidence window growing with spike time (rtol=0 in np.isclose)Sttc fix - #738

Open
Pedro-RP wants to merge 2 commits into
NeuralEnsemble:masterfrom
Pedro-RP:sttc_fix
Open

Pedro-RP wants to merge 2 commits into
NeuralEnsemble:masterfrom
Pedro-RP:sttc_fix

Conversation

@Pedro-RP

@Pedro-RP Pedro-RP commented Dec 5, 2026

Copy link
Copy Markdown

Fixes #736.

Problem

In spike_time_tiling_coefficient, run_p tests whether a spike lies within ±dt of a spike of the other train with np.isclose(..., atol=dt). With the default rtol=1e-5, the test is |t_j - t_i| <= dt + 1e-5 * |t_i|, so the coincidence window grows with the absolute spike time (5.2 ms instead of 5 ms at t = 20 s for dt = 5 ms). The STTC of two spike trains then changes when both are shifted in time, and P is computed with a wider window than T.

Change

  • elephant/spike_train_correlation.py: pass rtol=0 to np.isclose in run_p, so the window is exactly ±dt.
  • elephant/test/test_spike_train_correlation.py: add test_sttc_window_independent_of_spike_time, which checks that two spikes 5.1 ms apart are not coincident for dt = 5 ms, both at t = 1 s and at t = 20 s.

Tests

Run locally on Elephant 1.2.1 with the change applied:

  • the new test fails without the change (STTC = 1.0 at t = 20 s) and passes with it (STTC = -0.00025 at both times);
  • all tests of SpikeTimeTilingCoefficientTestCase pass, including test_sttc_validation_test against the original C implementation;
  • all 36 tests of test_spike_train_correlation.py pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] spike_time_tiling_coefficient: coincidence window grows with spike time (np.isclose default rtol)

1 participant