brainspike documentation

brainspike documentation#

brainspike is the point-neuron spiking-network layer of the BrainX ecosystem: building, simulating, and training spiking neural networks of point neurons. A new kernel language unifies how models are built, how they are simulated, and how they are trained. It is built on JAX and brainstate.

brainspike provides NEST-compatible models — JAX re-implementations of NEST simulator neuron, synapse, plasticity (STDP, STP), and device models with NEST parameter names, validated against live NEST with formal tolerance bands — driven through a NEST-style Simulator. The new kernel (one Network graph shared by simulation and learning) is in development and still private.

All parameters carry physical units via brainunit, and every model compiles through JAX to CPU, GPU, and TPU.

Installation#

pip install -U brainspikes[cpu]
pip install -U brainspikes[cuda12]

pip install -U brainspikes[cuda13]
pip install -U brainspikes[tpu]
pip install -U BrainX

Quick example#

A Brunel (2000) sparse balanced random network, built with the explicit Simulator:

import brainstate
import brainunit as u
from brainspike import (Simulator, iaf_psc_alpha, poisson_generator,
                           spike_recorder, all_to_all, fixed_indegree)


# Brunel (2000) sparse balanced random network, built with the explicit Simulator
order = 400
NE, NI = 4 * order, 1 * order              # 1600 excitatory + 400 inhibitory
CE, CI = int(0.1 * NE), int(0.1 * NI)      # 10% fixed in-degree
J = 20. * u.pA                             # excitatory PSC; inhibition is -g * J

neuron = dict(C_m=250. * u.pF, tau_m=20. * u.ms, t_ref=2. * u.ms,
              E_L=0. * u.mV, V_reset=0. * u.mV, V_th=20. * u.mV)

sim = Simulator(dt=0.1 * u.ms)
ne = sim.create(iaf_psc_alpha, NE, params=neuron)
ni = sim.create(iaf_psc_alpha, NI, params=neuron)
noise = sim.create(poisson_generator, rate=15000. * u.Hz)
rec = sim.create(spike_recorder)

sim.connect(noise, ne + ni, weight=J, delay=1.5 * u.ms, rule=all_to_all)
sim.connect(ne, ne + ni, weight=J, delay=1.5 * u.ms,
            rule=fixed_indegree(CE), comm='sparse', seed=1)
sim.connect(ni, ne + ni, weight=-5. * J, delay=1.5 * u.ms,
            rule=fixed_indegree(CI), comm='sparse', seed=2)
sim.connect(ne[:50], rec)

res = sim.simulate(1000. * u.ms)
print(res.rate(rec.segments[0].population))   # excitatory firing rate

Learn more#

NEST-Compatible Hub
nest-style/index.html
API Reference
apis/index.html
Examples Gallery
examples/nest-gallery.html

See also the ecosystem#

brainspike is one part of the BrainX ecosystem:

  • brainstate — state management for JAX-based brain modeling

  • brainunit — physical units for neuroscience

  • brainevent — event-driven sparse operators

  • braintools — surrogate gradients, analysis, and utilities

  • braintrace — linear-memory online learning for spiking networks