spike_time_tiling_coefficient#
- class braintools.metric.spike_time_tiling_coefficient(spike_matrix, dt=None, tau=0.005)#
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.
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) – Time step between successive samples. If None, uses brainstate default.tau (
float) – Half-width of the temporal window for coincidence detection. Must use the same time unit asdt(default assumes seconds).
- Returns:
STTC matrix with shape
(n_neurons, n_neurons). Diagonal elements are 1. Values range from -1 to 1, where 1 indicates perfect synchrony.- 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). Each STTC term is guarded independently against a zero denominator.
This function runs on host (concrete) arrays (Python loops,
len, boolean-mask indexing), so it is notjit/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.metric.spike_time_tiling_coefficient(spikes, dt=1.0, tau=2.0) >>> sttc.shape (3, 3)
References