cross_correlation#

class brainpy.measure.cross_correlation(spikes, bin, dt=None, numpy=True, method='loop')[source]#

Calculate cross correlation index between neurons.

The coherence [1] between two neurons i and j is measured by their cross-correlation of spike trains at zero time lag within a time bin of \(\Delta t = \tau\). More specifically, suppose that a long time interval T is divided into small bins of \(\Delta t\) and that two spike trains are given by \(X(l)=\) 0 or 1, \(Y(l)=\) 0 or 1, \(l=1,2, \ldots, K(T / K=\tau)\). Thus, we define a coherence measure for the pair as:

\[\kappa_{i j}(\tau)=\frac{\sum_{l=1}^{K} X(l) Y(l)} {\sqrt{\sum_{l=1}^{K} X(l) \sum_{l=1}^{K} Y(l)}}\]

The population coherence measure \(\kappa(\tau)\) is defined by the average of \(\kappa_{i j}(\tau)\) over many pairs of neurons in the network.

Note

To JIT compile this function, users should make bin, dt, numpy static. For example, partial(brainpy.measure.cross_correlation, bin=10, numpy=False).

Parameters:
  • spikes (ndarray) – The history of spike states of the neuron group.

  • bin (float, int) – The time bin to normalize spike states.

  • dt (float, optional) – The time precision.

  • numpy (bool) – Whether we use numpy array as the functional output. If False, this function can be JIT compiled.

  • method (str) –

    The method to calculate all pairs of cross correlation. Supports two kinds of methods: loop and vmap. vmap method needs much more memory.

    New in version 2.2.3.4.

Returns:

cc_index – The cross correlation value which represents the synchronization index.

Return type:

float

References