StepCurrentEncoder

StepCurrentEncoder#

class braintools.spike.StepCurrentEncoder(current_scale=10.0, offset=0.0, normalize=True, min_val=None, max_val=None)#

Encode inputs as step current injections for LIF neurons.

Converts input values to constant current levels \(I = x \cdot \text{current_scale} + \text{offset}\) that can be injected into integrate-and-fire neurons; the neuron model then produces the spikes, with a firing rate set by the current amplitude. The values are plain numbers: multiply by a unit (e.g. u.nA) when the model expects a Quantity.

Parameters:
  • current_scale (float) – Scaling factor that converts inputs to currents.

  • offset (float) – Baseline current offset.

  • normalize (bool) – Whether to rescale inputs to [0, 1] with min_val and max_val; it has no effect unless both are given.

  • min_val (float | None) – Minimum value for normalization.

  • max_val (float | None) – Maximum value for normalization.

See also

DeltaEncoder

Spikes on changes of a time series.

Examples

>>> import jax.numpy as jnp
>>> import braintools
>>> encoder = braintools.spike.StepCurrentEncoder(current_scale=10.0)
>>> currents = encoder(jnp.array([0.1, 0.5, 1.0]), n_time=100)
>>> currents.shape
(100, 3)
>>> currents[0]
Array([ 1.,  5., 10.], dtype=float32)