spike_train_synchrony

spike_train_synchrony#

class braintools.metric.spike_train_synchrony(spike_matrix, window_size, dt=None)#

Calculate spike train synchrony using the SPIKE-synchronization measure.

This measure quantifies the degree of synchronization between multiple spike trains by counting coincident events within sliding time windows and normalizing by the total number of possible coincidences.

The synchrony index is the average over neuron pairs of a symmetric coincidence ratio:

\[S = \frac{1}{N_{pairs}} \sum_{i < j} \frac{C_{i \to j} + C_{j \to i}}{N_i + N_j}\]

where \(C_{i \to j}\) is the number of spikes in train \(i\) that have at least one spike of train \(j\) within half the coincidence window, and \(N_i\) is the number of spikes in train \(i\). Counting coincidences in both directions and normalizing by the total spike count guarantees \(S \in [0, 1]\).

Parameters:
  • spike_matrix (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Spike matrix with shape (n_time_steps, n_neurons) where non-zero values indicate spike occurrences.

  • window_size (float) – Full width of the coincidence-detection window. Two spikes are coincident when they are at most window_size / 2 apart. Must use the same time unit as dt.

  • dt (float) – Time step between successive samples. If None, uses brainstate default.

Returns:

Spike train synchrony index between 0 (no synchrony) and 1 (perfect synchrony).

Return type:

float

Examples

>>> import jax.numpy as jnp
>>> import braintools as braintools
>>> # Create synchronized spikes
>>> spikes = jnp.zeros((100, 5))
>>> spikes = spikes.at[20:25, :].set(1)  # Synchronized burst
>>> synchrony = braintools.metric.spike_train_synchrony(spikes, window_size=10.0)
>>> print(f"Synchrony: {synchrony:.3f}")

References