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 (in 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
Examples
>>> import jax.numpy as jnp >>> import braintools as braintools >>> # Create correlated spike trains >>> spikes = jnp.zeros((1000, 3)) >>> # Add some synchronized spikes >>> 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) >>> print(f"STTC matrix:\\n{sttc}")
References