braintools.analysis.spike.cv

Contents

braintools.analysis.spike.cv#

braintools.analysis.spike.cv(trains)#

Compute the coefficient of variation of the inter-spike intervals.

\[\mathrm{CV} = \frac{\sigma_I}{\mu_I},\]

with the mean \(\mu_I\) and the population standard deviation \(\sigma_I\) (ddof=0) of the intervals of each neuron.

Parameters:

trains (SpikeTrains) – Spike trains with N neurons.

Returns:

CV of every neuron, shape (N,). nan for a neuron with fewer than 2 intervals (fewer than 3 spikes), or whose intervals are all 0.

Return type:

Array

Raises:

TypeError – If trains is not a SpikeTrains.

See also

isi, cv2, lv

Notes

A Poisson process has \(\mathrm{CV} = 1\), a perfectly regular train \(\mathrm{CV} = 0\) [1]. The value matches scipy.stats.variation (which elephant.statistics.cv is) applied to the intervals, except that a single interval gives nan here, whereas scipy.stats.variation returns 0.

Works under jax.jit and jax.vmap, and is differentiable with respect to the spike times.

References

Examples

>>> import jax.numpy as jnp
>>> from braintools.spike import SpikeTrains
>>> from braintools.analysis.spike import cv
>>> raster = jnp.zeros((10, 2)).at[jnp.array([0, 2, 6]), 0].set(1).at[::3, 1].set(1)
>>> st = SpikeTrains.from_dense(raster, dt=1.)
>>> cv(st)
Array([0.33333334, 0.        ], dtype=float32)