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 computed as:

\[S = \frac{1}{N(N-1)} \sum_{i \neq j} \frac{C_{ij}}{min(N_i, N_j)}\]

where \(C_{ij}\) is the number of coincidences between trains i and j, and \(N_i\) is the number of spikes in train i.

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) – Size of the coincidence detection window.

  • 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