unitary_LFP

Contents

unitary_LFP#

class brainpy.measure.unitary_LFP(times, spikes, spike_type, xmax=0.2, ymax=0.2, va=200.0, lambda_=0.2, sig_i=2.1, sig_e=3.1500000000000004, location='soma layer', seed=None)#

Calculate unitary local field potentials (uLFP) from spike train data.

Computes the contribution of spiking neurons to local field potentials using a kernel-based method. This approach models the spatial distribution of neurons, axonal conduction delays, and layer-specific amplitude scaling to estimate the LFP signal recorded at an electrode positioned at the center of the neural population.

The method implements a biophysically-motivated model where each spike contributes to the LFP through a Gaussian kernel with amplitude and delay determined by the neuron’s distance from the recording electrode:

\[\text{uLFP}(t) = \sum_{i,s} A_i \exp\left(-\frac{(t - t_s - \delta_i)^2}{2\sigma^2}\right)\]

where \(A_i\) is the distance-dependent amplitude, \(t_s\) is the spike time, \(\delta_i\) is the conduction delay, and \(\sigma\) is the kernel width (different for excitatory and inhibitory neurons).

Parameters:
  • times (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Time points of the recording with shape (n_time_steps,), in milliseconds.

  • spikes (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Binary spike matrix with shape (n_time_steps, n_neurons) where non-zero values indicate spike occurrences.

  • spike_type (str) –

    Type of neurons generating the spikes:

    • 'exc': Excitatory neurons (positive contribution)

    • 'inh': Inhibitory neurons (can be positive or negative depending on layer)

  • xmax (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Spatial extent of the neuron population in the x-dimension (mm). Neurons are randomly distributed within a rectangle of size xmax × ymax centered at the electrode position.

  • ymax (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Spatial extent of the neuron population in the y-dimension (mm).

  • va (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Axonal conduction velocity in mm/s. Determines the delay between spike occurrence and its contribution to the LFP. Typical values range from 100-500 mm/s for cortical neurons.

  • lambda_ (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Spatial decay constant in mm. Controls how quickly the LFP amplitude decreases with distance from the electrode.

  • sig_i (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Standard deviation of the inhibitory neuron kernel in ms.

  • sig_e (Union[Array, ndarray, bool, number, bool, int, float, complex, Quantity]) – Standard deviation of the excitatory neuron kernel in ms (default 2.1 * 1.5).

  • location (str) –

    Recording electrode location relative to the cortical layers:

    • 'soma layer': At the soma level (excitatory: +0.48, inhibitory: +3.0)

    • 'deep layer': Below soma layer (excitatory: -0.16, inhibitory: -0.2)

    • 'superficial layer': Above soma layer (excitatory: +0.24, inhibitory: -1.2)

    • 'surface' (alias 'surface layer'): At cortical surface (excitatory: -0.08, inhibitory: +0.3)

  • seed (Union[int, Array, ndarray]) – Random seed for reproducible neuron positioning.

Returns:

Unitary LFP signal with shape (n_time_steps,) representing the contribution of the specified neuron population to the local field potential, in microvolts (μV).

Return type:

Array

Raises:
  • ValueError – If spike_type is not 'exc' or 'inh', if spikes is not 2-D, or if times and spikes have incompatible first axes.

  • NotImplementedError – If location is not one of the supported options.

Notes

This implementation focuses on spike-triggered LFP contributions and does not account for subthreshold synaptic currents, dendritic active channels, volume conduction from distant sources, or frequency-dependent propagation.

The per-neuron peak delay is \(\delta_i = 10.4\,\text{ms} + d_i / v_a\), where \(d_i\) is the neuron-electrode distance (mm) and \(v_a\) the axonal velocity (mm/s); the d_i / v_a term (seconds) is converted to milliseconds so it is commensurate with the 10.4 ms peak constant of Telenczuk et al. (2020).

This function runs on host (concrete) arrays — it uses jnp.where(spikes) (data-dependent output shape), so it is not jit/vmap-compatible.

Examples

>>> import brainstate
>>> import jax.numpy as jnp
>>> import braintools
>>> brainstate.random.seed(42)
>>> n_time, n_exc = 1000, 100
>>> times = jnp.arange(n_time) * 0.1  # ms
>>> exc_spikes = (brainstate.random.random((n_time, n_exc)) < 0.02).astype(float)
>>> lfp = braintools.metric.unitary_LFP(times, exc_spikes, 'exc', seed=42)
>>> lfp.shape
(1000,)

References