braintools.analysis.spike.isi

Contents

braintools.analysis.spike.isi#

braintools.analysis.spike.isi(trains)#

Compute the inter-spike intervals of every neuron.

For neuron \(n\) with spike times \(t_1 < \dots < t_{c_n}\), the intervals are \(I_k = t_{k+1} - t_k\), \(k = 1, \dots, c_n - 1\).

Parameters:

trains (SpikeTrains) – Spike trains with N neurons and capacity K.

Returns:

Intervals of shape (N, K - 1), padded with nan beyond entry counts - 1 of every row. A Quantity in the unit of the spike times when they carry one.

Return type:

Any

Raises:

TypeError – If trains is not a SpikeTrains.

See also

cv, cv2, lv

braintools.spike.SpikeTrains.from_dense

Build the input from a raster.

Notes

The output shape depends only on the capacity, so the function works under jax.jit and jax.vmap and is differentiable with respect to the spike times (the padding receives zero gradient).

Examples

>>> import brainunit as u
>>> import jax.numpy as jnp
>>> from braintools.spike import SpikeTrains
>>> from braintools.analysis.spike import isi
>>> raster = jnp.zeros((10, 2)).at[jnp.array([0, 2, 7]), 0].set(1).at[4, 1].set(1)
>>> st = SpikeTrains.from_dense(raster, dt=1. * u.ms)
>>> isi(st)
Quantity([[ 2.  5.]
          [nan nan]], "ms")