braintools.spike module

braintools.spike module#

Spike data: the SpikeTrains container, encoders and bitwise operations.

  • SpikeTrains stores the spike times of a population in a padded, fixed-shape layout that works under jax.jit and jax.vmap, and converts to and from dense rasters, flat event lists and ragged lists.

  • The encoders (LatencyEncoder, PoissonEncoder, …) turn numbers or time series into spike rasters.

  • The bitwise functions (bitwise_or(), bitwise_and(), …) combine spike tensors element-wise and stay differentiable for surrogate-gradient spikes.

Spike data in one place: a fixed-shape container for spike times, encoders that turn numbers or time series into spike rasters, and element-wise bitwise operations on spike tensors.

Spike Trains#

SpikeTrains stores the spike times of a population as a padded (n_neurons, capacity) array. It is a JAX pytree, so it can be built and used inside jax.jit and jax.vmap, and it converts to and from dense rasters (from_dense / to_dense), flat event lists (from_events / to_events) and ragged per-neuron lists (from_list / to_list). The braintools.visualize spike plots accept it directly.

SpikeTrains

Spike times of a population in a padded, fixed-shape layout.

Spike Encoders#

Encoders that convert continuous-valued signals into spike trains (or, for StepCurrentEncoder, into input currents) for spiking network simulations. Before 0.4.0 they lived at the top level (braintools.RateEncoder and so on); those names are deprecated aliases that will be removed in 1.0.0.

LatencyEncoder

Encode input intensities as the time of a single spike (latency coding).

RateEncoder

Encode analog values into spike rates using various rate encoding methods.

PoissonEncoder

Encode inputs as Poisson spike trains.

PopulationEncoder

Encode scalar values using population coding.

BernoulliEncoder

Encode inputs using independent Bernoulli processes.

DeltaEncoder

Encode a time series by send-on-delta (level-crossing) modulation.

StepCurrentEncoder

Encode inputs as step current injections for LIF neurons.

SpikeCountEncoder

Encode inputs as exact spike counts over time windows.

TemporalEncoder

Encode temporal patterns using synchronized spike timing.

RankOrderEncoder

Encode inputs using rank order coding.

Bitwise Operations#

Element-wise logical operations on spike tensors. Boolean inputs give boolean results; numeric inputs use arithmetic identities that keep the dtype and stay differentiable for surrogate-gradient spikes. The former top-level names (braintools.spike_bitwise_or and so on) remain available as aliases.

bitwise_or

Perform a bitwise OR operation on spike tensors.

bitwise_and

Perform a bitwise AND operation on spike tensors.

bitwise_iand

Perform a bitwise IAND (Inverse AND) operation on spike tensors.

bitwise_not

Perform a bitwise NOT operation on spike tensors.

bitwise_xor

Perform a bitwise XOR operation on spike tensors.

bitwise_ixor

Perform a bitwise IXOR (Inverse XOR) operation on spike tensors.

bitwise

Perform bitwise operations on spike tensors.