spike_time_tiling_coefficient

spike_time_tiling_coefficient#

class braintools.analysis.spike.spike_time_tiling_coefficient(spike_matrix, dt=None, tau=5.0)#

Calculate Spike Time Tiling Coefficient (STTC).

STTC measures synchrony between spike trains while controlling for firing rate differences. It’s based on the proportion of spikes that fall within a temporal window around spikes in the other train [1].

The STTC is computed as:

\[STTC = \frac{1}{2}\left(\frac{P_A - T_B}{1 - P_A T_B} + \frac{P_B - T_A}{1 - P_B T_A}\right)\]

where \(P_A\) is the proportion of spikes in train A that have a spike from train B within time \(\tau\), and \(T_A\) is the proportion of total time covered by windows around spikes in train A.

Parameters:
  • spike_matrix (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Spike matrix with shape (n_time_steps, n_neurons).

  • dt (float | None) – Time step between successive samples. If None, uses the default from brainstate.environ.get_dt(). A plain float is assumed to be in milliseconds (the brainstate convention), so it must be expressed in the same unit as window_size/max_isi/tau; a brainunit.Quantity is converted automatically.

  • tau (float) – Half-width of the temporal window for coincidence detection. A plain float is in milliseconds (like dt); a Quantity is converted. The default is 5 ms.

Returns:

STTC matrix with shape (n_neurons, n_neurons). Diagonal elements are 1. Values range from -1 to 1, where 1 indicates perfect synchrony. A pair involving a silent neuron has STTC 0.

Return type:

jnp.ndarray

Notes

The time-coverage terms \(T_A\), \(T_B\) use the union of the per-spike \([\,s - \tau,\ s + \tau\,]\) windows, so overlapping windows are not double-counted (the defining quantity in Cutts & Eglen, 2014 [1]). Each STTC term is guarded independently against a zero denominator.

All pairs are computed at once: a cumulative sum marks the samples covered by each neuron’s windows, and one matrix product counts, for every ordered pair, the spikes of one neuron inside the other’s windows. Memory is O(T N + N^2).

This function runs on host (concrete) arrays with NumPy, so it is not jit/vmap/grad-compatible.

Examples

>>> import jax.numpy as jnp
>>> import braintools
>>> spikes = jnp.zeros((1000, 3))
>>> sync_times = [100, 300, 500, 700]
>>> for t in sync_times:
...     spikes = spikes.at[t:t + 3, :].set(1)
>>> sttc = braintools.analysis.spike.spike_time_tiling_coefficient(spikes, dt=1.0, tau=2.0)
>>> sttc.shape
(3, 3)

References