braintools.analysis.spike.cv2#
- braintools.analysis.spike.cv2(trains)#
Compute the local coefficient of variation CV2 of Holt et al. (1996).
\[\mathrm{CV2} = \frac{1}{n-1} \sum_{k=1}^{n-1} \frac{2 |I_{k+1} - I_k|}{I_{k+1} + I_k},\]for the \(n\) intervals \(I_k\) of a neuron [1]. Comparing only neighbouring intervals makes CV2 insensitive to slow rate changes.
- Parameters:
trains (
SpikeTrains) – Spike trains withNneurons.- Returns:
CV2 of every neuron, shape
(N,).nanfor a neuron with fewer than 2 intervals, or with two consecutive zero intervals.- Return type:
Array- Raises:
TypeError – If
trainsis not aSpikeTrains.
Notes
Matches
elephant.statistics.cv2(isi, with_nan=True). CV2 is about 1 for a Poisson process and 0 for a regular train. Works underjax.jitandjax.vmap, and is differentiable with respect to the spike times (except where two neighbouring intervals are equal, where|x|has a kink).References
Examples
>>> import jax.numpy as jnp >>> from braintools.spike import SpikeTrains >>> from braintools.analysis.spike import cv2 >>> raster = jnp.zeros((10, 2)).at[jnp.array([0, 1, 3]), 0].set(1).at[0, 1].set(1) >>> st = SpikeTrains.from_dense(raster, dt=1.) >>> cv2(st) Array([0.6666667, nan], dtype=float32)