SynapseSpike

SynapseSpike is a biophysical neuromorphic spiking neural network (SNN) and synaptic plasticity dynamics simulator written in pure Python with NumPy and SciPy. It implements multi-timescale neuron models (Leaky Integrate-and-Fire, Izhikevich 2D dynamical systems, and Hodgkin-Huxley conductance equations), bi-exponential Spike-Timing-Dependent Plasticity (STDP) with eligibility traces, and balanced recurrent cortical networks following Dale’s principle.
Neurocomputational Architecture
In biological neural circuits, information is processed via discrete action potentials (spikes) rather than continuous activation values. SynapseSpike models electrophysiological dynamics across single neurons and recurrent populations:
flowchart TD
subgraph BiophysicalNeurons ["1. Biophysical Neuron Dynamics"]
LIF["Leaky Integrate-and-Fire (tau_m dV/dt = -V + RI)"]
IZH["Izhikevich 2D (v' = 0.04v^2 + 5v + 140 - u + I)"]
HH["Hodgkin-Huxley (m^3 h Na+, n^4 K+ Conductances)"]
end
subgraph SynapticPlasticity ["2. Synaptic Plasticity (STDP)"]
PRE["Pre-Synaptic Spike t_pre"] -->|Post Follows Pre (Delta t > 0)| LTP["Long-Term Potentiation: Delta w = A+ exp(-Delta t / tau+)"]
POST["Post-Synaptic Spike t_post"] -->|Pre Follows Post (Delta t < 0)| LTD["Long-Term Depression: Delta w = -A- exp(Delta t / tau-)"]
LTP & LTD --> TR["Eligibility Traces (x_pre, x_post)"]
TR --> W["Synaptic Weight Matrix W[i, j]"]
end
subgraph RecurrentNetwork ["3. Recurrent Balanced Circuit"]
EXC["80% Pyramidal Excitatory Neurons (W > 0)"]
INH["20% Fast-Spiking Inhibitory Interneurons (W < 0)"]
EXC <-->|Plastic STDP Synapses| EXC
EXC --> INH
INH --> EXC
end
subgraph Diagnostics ["4. Population Telemetry"]
W --> POP["Mean Synaptic Weight Evolution"]
EXC & INH --> FR["Population Firing Rate (Hz) & Spike Raster"]
end
1. Izhikevich 2D Dynamical System
The membrane potential $v$ and recovery variable $u$ are governed by:
$$\frac{dv}{dt} = 0.04 v^2 + 5v + 140 - u + I$$
$$\frac{du}{dt} = a(bv - u)$$
with the spike reset condition:
$$\text{if } v \ge 30\text{ mV}, \quad \text{then } \begin{cases} v \leftarrow c \ u \leftarrow u + d \end{cases}$$
Parameter configurations reproduce canonical cortical firing patterns:
- Regular Spiking (RS): $a=0.02, b=0.2, c=-65, d=8$
- Fast Spiking (FS): $a=0.1, b=0.2, c=-65, d=2$
- Intrinsic Bursting (IB): $a=0.02, b=0.2, c=-55, d=4$
- Chattering (CH): $a=0.02, b=0.2, c=-50, d=2$
2. Spike-Timing-Dependent Plasticity (STDP)
The synaptic weight change $\Delta w$ depends on the relative timing $\Delta t = t_{\text{post}} - t_{\text{pre}}$:
$$\Delta w = \begin{cases} A_+ \exp\left( -\frac{\Delta t}{\tau_+} \right) & \text{if } \Delta t > 0 \text{ (Causal / Potentiation)} \ -A_- \exp\left( \frac{\Delta t}{\tau_-} \right) & \text{if } \Delta t < 0 \text{ (Anti-causal / Depression)} \end{cases}$$
with eligibility traces evaluated on each time step:
$$\frac{dx_{\text{pre}}}{dt} = -\frac{x_{\text{pre}}}{\tau_+}, \quad \frac{dx_{\text{post}}}{dt} = -\frac{x_{\text{post}}}{\tau_-}$$
Installation
git clone https://github.com/ZengLLQ/synapse-spike.git
cd synapse-spike
pip install -e .
CLI Usage
1. Run Recurrent SNN Simulation with STDP
synapsespike simulate --exc 80 --inh 20 --duration 200.0
Output:
================================================================================
SynapseSpike: Recurrent SNN Simulation
================================================================================
Network Population : 80 Excitatory, 20 Inhibitory (Total: 100)
Connection Prob : 0.15
Plasticity (STDP) : Enabled
Duration : 200.0 ms (dt = 0.5 ms, Steps = 400)
--------------------------------------------------------------------------------
Time 40.0 ms | Spikes: 182 | Rate: Total= 45.5 Hz, Exc= 41.2 Hz, Inh= 62.5 Hz | Mean W=0.4120
Time 80.0 ms | Spikes: 394 | Rate: Total= 53.0 Hz, Exc= 48.8 Hz, Inh= 70.0 Hz | Mean W=0.4285
Time 200.0 ms | Spikes: 1042 | Rate: Total= 52.1 Hz, Exc= 47.9 Hz, Inh= 69.1 Hz | Mean W=0.4610
--------------------------------------------------------------------------------
Total Spikes Emitted : 1042
================================================================================
2. Simulate Izhikevich Cortical Presets
synapsespike izhikevich
3. Scalability Benchmark
synapsespike benchmark --steps 200
Python API Example
from synapsespike import SpikingNetwork, NetworkConfig
# Configure balanced cortical microcircuit
config = NetworkConfig(
n_excitatory=80,
n_inhibitory=20,
connection_prob=0.2,
enable_stdp=True,
)
net = SpikingNetwork(config)
for _ in range(100):
fired_neuron_indices = net.step()
print(f"Total simulated time: {net.time:.1f} ms, Spikes: {len(net.spike_history)}")
Testing
Run unit test suite:
pytest -v
License
MIT License. Copyright © 2026 ZengLLQ.
评论