braintools.analysis.spike.auto_correlogram#
- braintools.analysis.spike.auto_correlogram(trains, bin_size, max_lag)#
Compute the spike-time auto-correlogram of every neuron.
This is
cross_correlogram()oftrainswith itself, with the zero-lag pairs of a spike with itself removed. Distinct spikes at the same time are still counted at lag 0.- Parameters:
trains (
SpikeTrains) – Spike trains withNneurons.bin_size (
Any) – Width of the lag bins, static and positive. A plain number is in milliseconds.max_lag (
Any) – Largest lag of interest, static and non-negative. A plain number is in milliseconds.
- Return type:
- Returns:
counts (jax.Array) –
int32pair counts of shape(N, n_bins)withn_bins = 2 * ceil(max_lag / bin_size) + 1; symmetric about the centre bin.lags (jax.Array or Quantity) – Bin centres, shape
(n_bins,).
- Raises:
TypeError – If
trainsis not aSpikeTrains.ValueError – As for
cross_correlogram().
See also
Notes
Equal to
elephant.spike_train_correlation.cross_correlation_histogramof a binned train with itself minus the spike count in the centre bin, for grid-aligned spikes. Works underjax.jitandjax.vmap; not differentiable.Examples
>>> import jax.numpy as jnp >>> from braintools.spike import SpikeTrains >>> from braintools.analysis.spike import auto_correlogram >>> raster = jnp.zeros((10, 1)).at[jnp.array([1, 3, 4]), 0].set(1) >>> st = SpikeTrains.from_dense(raster, dt=1.) >>> counts, lags = auto_correlogram(st, bin_size=1., max_lag=3.) >>> counts Array([[1, 1, 1, 0, 1, 1, 1]], dtype=int32) >>> lags Array([-3., -2., -1., 0., 1., 2., 3.], dtype=float32)