Phase 34.1 — SpikingNeuronModel
Component: asi.neuromorphic.spiking_neuron_model
Phase: 34 — Neuromorphic Computing & Spiking Neural Network Integration
Sub-phase: 34.1 — Biologically-Inspired Spiking Neuron Models
Overview
The SpikingNeuronModel module provides a family of biologically-inspired spiking neuron implementations that form the computational foundation of the neuromorphic computing subsystem. Unlike rate-coded artificial neurons that output continuous activation values, spiking neurons communicate through discrete spike events with precise temporal dynamics — enabling event-driven, energy-efficient computation with biologically plausible learning rules.
This module implements four canonical neuron models spanning the biological fidelity–computational cost spectrum: from the minimal Leaky Integrate-and-Fire (LIF) to the biophysically detailed Hodgkin–Huxley model, each with configurable membrane dynamics, synaptic integration, spike-timing-dependent plasticity (STDP), and refractory period handling.
Data Classes (frozen dataclasses)
@dataclass(frozen=True)
class SpikingNeuronConfig:
"""Configuration for a spiking neuron model."""
neuron_type: str # "lif" | "izhikevich" | "hodgkin_huxley" | "adex"
membrane_capacitance: float # C_m in nF (default: 1.0)
resting_potential: float # V_rest in mV (default: -65.0)
threshold_potential: float # V_thresh in mV (default: -50.0)
reset_potential: float # V_reset in mV (default: -65.0)
refractory_period: float # t_ref in ms (default: 2.0)
leak_conductance: float # g_L in μS (default: 0.025)
time_constant: float # τ_m in ms (default: 20.0)
integration_method: str # "euler" | "rk4" (default: "euler")
dt: float # simulation timestep in ms (default: 0.1)
stdp_enabled: bool # whether STDP learning is active (default: True)
record_trace: bool # whether to record full membrane trace (default: False)
@dataclass(frozen=True)
class NeuronState:
"""Snapshot of neuron state at a given timestep."""
membrane_potential: float # V_m in mV
recovery_variable: float # u (Izhikevich) or adaptation current (AdEx)
is_refractory: bool # currently in refractory period
refractory_timer: float # remaining refractory time in ms
last_spike_time: Optional[float] # timestamp of most recent spike (ms)
input_current: float # total synaptic + external current (nA)
timestep: int # simulation step counter
gate_states: Optional[Dict[str, float]] # HH ion channel gates (m, h, n)
@dataclass(frozen=True)
class SpikeEvent:
"""Discrete spike event emitted by a neuron."""
neuron_id: str # unique identifier of the spiking neuron
timestamp: float # spike time in ms
layer_id: Optional[str] # layer/population this neuron belongs to
amplitude: float # spike amplitude in mV (typically fixed)
metadata: Dict[str, Any] # extensible metadata (firing pattern, burst index, etc.)
@dataclass(frozen=True)
class SynapticCurrent:
"""Represents synaptic input current to a neuron."""
source_neuron_id: str # presynaptic neuron ID
target_neuron_id: str # postsynaptic neuron ID
weight: float # synaptic weight (dimensionless, [0, w_max])
current: float # instantaneous synaptic current in nA
synapse_type: str # "excitatory" | "inhibitory"
delay: float # axonal delay in ms (default: 1.0)
timestamp: float # time of current injection
@dataclass(frozen=True)
class STDPRule:
"""Spike-Timing-Dependent Plasticity configuration."""
a_plus: float # LTP amplitude (default: 0.01)
a_minus: float # LTD amplitude (default: -0.012)
tau_plus: float # LTP time constant in ms (default: 20.0)
tau_minus: float # LTD time constant in ms (default: 20.0)
w_max: float # maximum synaptic weight (default: 1.0)
w_min: float # minimum synaptic weight (default: 0.0)
learning_rate: float # global scaling factor (default: 0.001)
rule_type: str # "additive" | "multiplicative" | "log"
@dataclass(frozen=True)
class SpikeTrain:
"""Collection of spike events for analysis."""
neuron_id: str # neuron that produced this train
spike_times: Tuple[float, ...] # ordered spike timestamps in ms
duration: float # total recording duration in ms
mean_rate: float # average firing rate in Hz
cv_isi: float # coefficient of variation of inter-spike intervals
burst_count: int # number of detected bursts
pattern_label: Optional[str] # classified firing pattern (e.g., "tonic", "bursting")
Protocol Class
class SpikingNeuronProtocol(Protocol):
"""Interface for all spiking neuron model implementations."""
def step(self, dt: float, input_current: float) -> NeuronState:
"""Advance neuron dynamics by one timestep.
Integrates the membrane equation using the configured method (Euler/RK4),
applies refractory period logic, and returns the updated state.
Args:
dt: timestep duration in ms
input_current: total input current in nA
Returns:
Updated NeuronState after integration
"""
...
def check_spike(self) -> Optional[SpikeEvent]:
"""Check if membrane potential crossed threshold.
Returns:
SpikeEvent if a spike occurred, None otherwise
"""
...
def reset_after_spike(self) -> None:
"""Apply post-spike reset: set V_m to V_reset, start refractory timer.
For Izhikevich: also applies recovery variable update (u += d).
For HH: triggers sodium channel inactivation cascade.
For AdEx: applies adaptation current increment.
"""
...
def apply_stdp(self, pre_spike: SpikeEvent, post_spike: SpikeEvent) -> float:
"""Compute STDP weight update from pre/post spike timing.
Implements the asymmetric STDP learning window:
Δw = A+ * exp(-Δt/τ+) if Δt > 0 (pre before post → LTP)
Δw = A- * exp(Δt/τ-) if Δt < 0 (post before pre → LTD)
Args:
pre_spike: presynaptic spike event
post_spike: postsynaptic spike event
Returns:
Weight change Δw (positive for potentiation, negative for depression)
"""
...
def get_membrane_potential(self) -> float:
"""Return current membrane potential in mV."""
...
Concrete Implementations
| Class |
Model |
Equations |
Biological Fidelity |
Compute Cost |
Parameters |
LIFNeuron |
Leaky Integrate-and-Fire |
τ_m dV/dt = -(V - V_rest) + R·I(t) |
★☆☆☆☆ |
★☆☆☆☆ |
5 |
IzhikevichNeuron |
Izhikevich (2003) |
dv/dt = 0.04v² + 5v + 140 - u + I; du/dt = a(bv - u) |
★★★☆☆ |
★★☆☆☆ |
4 (a,b,c,d) |
HodgkinHuxleyNeuron |
Hodgkin-Huxley (1952) |
C dV/dt = I - g_Na·m³h(V-E_Na) - g_K·n⁴(V-E_K) - g_L(V-E_L) |
★★★★★ |
★★★★★ |
12+ |
AdaptiveExponentialNeuron |
AdEx (Brette & Gerstner 2005) |
C dV/dt = -g_L(V-E_L) + g_L·Δ_T·exp((V-V_T)/Δ_T) - w + I; τ_w dw/dt = a(V-E_L) - w |
★★★★☆ |
★★★☆☆ |
9 |
LIFNeuron
- Simplest model: single ODE for membrane potential with leak and threshold
- Fixed threshold → deterministic spike at V = V_thresh
- Useful for large-scale network simulations where individual neuron detail is less important
IzhikevichNeuron
- Two coupled ODEs (v, u) reproducing 20+ biological firing patterns
- Parameter presets for regular spiking (RS), intrinsically bursting (IB), chattering (CH), fast spiking (FS), thalamo-cortical (TC), resonator (RZ), low-threshold spiking (LTS)
- Best balance of biological fidelity and computational efficiency
HodgkinHuxleyNeuron
- Four coupled ODEs modeling Na⁺, K⁺ ion channels with voltage-dependent gates (m, h, n)
- Temperature-dependent rate constants (Q₁₀ factors)
- Gold standard for biophysical accuracy; computationally expensive
AdaptiveExponentialNeuron (AdEx)
- Two ODEs with exponential spike initiation + subthreshold/suprathreshold adaptation
- Captures adaptation, bursting, irregular spiking, delayed spiking, transient spiking
- 9-parameter model; good compromise for cortical neuron modeling
Key Algorithms
1. Membrane Dynamics Integration
Euler Method (first-order, fast):
V(t+dt) = V(t) + dt * f(V(t), I(t))
RK4 Method (fourth-order, accurate):
k1 = f(V, I)
k2 = f(V + dt/2 * k1, I)
k3 = f(V + dt/2 * k2, I)
k4 = f(V + dt * k3, I)
V(t+dt) = V(t) + dt/6 * (k1 + 2k2 + 2k3 + k4)
For HH, the gating variables (m, h, n) are integrated simultaneously using the same method with their own rate equations:
dm/dt = α_m(V)(1-m) - β_m(V)m
dh/dt = α_h(V)(1-h) - β_h(V)h
dn/dt = α_n(V)(1-n) - β_n(V)n
2. STDP Weight Update Rule
Asymmetric Hebbian learning window:
Δt = t_post - t_pre
if Δt > 0: # pre before post → Long-Term Potentiation (LTP)
Δw = A+ * exp(-Δt / τ+)
elif Δt < 0: # post before pre → Long-Term Depression (LTD)
Δw = A- * exp(Δt / τ-)
# Additive rule:
w_new = clip(w + η * Δw, w_min, w_max)
# Multiplicative rule:
if Δw > 0: w_new = w + η * Δw * (w_max - w)
if Δw < 0: w_new = w + η * Δw * (w - w_min)
3. Refractory Period Handling
if neuron.is_refractory:
neuron.refractory_timer -= dt
if neuron.refractory_timer <= 0:
neuron.is_refractory = False
neuron.refractory_timer = 0.0
# During refractory: V_m is clamped to V_reset, no integration
else:
# Normal integration proceeds
neuron.step(dt, I)
Metrics
| Metric |
Target |
Description |
spike_rate_accuracy |
> 0.98 |
Correlation between model and analytical firing rate (f-I curve) |
membrane_potential_rmse |
< 0.5 mV |
RMSE of V_m trace vs reference implementation (NEURON/Brian2) |
stdp_weight_convergence |
< 100 epochs |
Epochs to reach stable weight distribution in STDP learning |
firing_pattern_classification_accuracy |
> 0.95 |
Accuracy classifying Izhikevich patterns by ISI statistics |
spike_timing_precision |
< 0.1 ms |
Maximum spike time deviation from reference at dt=0.01ms |
integration_stability |
100% |
No NaN/Inf values across all test scenarios |
throughput_neurons_per_sec |
> 100K (LIF) |
Neurons simulated per second (1000ms window, dt=0.1ms) |
Test Targets
- Line coverage: ≥ 95%
- Spike timing precision: < 0.1 ms deviation from analytical/reference solutions
- Izhikevich firing patterns: 20+ patterns reproduced (RS, IB, CH, FS, TC, RZ, LTS, phasic spiking, phasic bursting, tonic bursting, mixed mode, spike frequency adaptation, Class 1/2 excitable, spike latency, subthreshold oscillation, resonator, integrator, rebound spike, rebound burst, threshold variability, bistability, DAP, accommodation, inhibition-induced spiking, inhibition-induced bursting)
- HH action potential shape: peak amplitude within 5% of 100mV overshoot
- STDP curve: weight change sign matches theoretical prediction for all Δt in [-50, +50] ms
- Numerical stability: no overflow/NaN for dt ∈ {0.001, 0.01, 0.1, 0.5, 1.0} ms
- Edge cases: zero current, maximum current, simultaneous pre/post spikes (Δt=0)
File Structure
src/asi/neuromorphic/
├── __init__.py
├── spiking_neuron_model.py # Main module
├── neuron_configs.py # SpikingNeuronConfig presets
├── neuron_types/
│ ├── __init__.py
│ ├── lif.py # LIFNeuron
│ ├── izhikevich.py # IzhikevichNeuron
│ ├── hodgkin_huxley.py # HodgkinHuxleyNeuron
│ └── adaptive_exponential.py # AdaptiveExponentialNeuron
├── plasticity/
│ ├── __init__.py
│ └── stdp.py # STDP rule implementations
├── integration/
│ ├── __init__.py
│ └── solvers.py # Euler, RK4 integration
└── analysis/
├── __init__.py
├── spike_train.py # SpikeTrain analysis
└── firing_patterns.py # Pattern classification
tests/neuromorphic/
├── test_spiking_neuron_model.py # Unit tests
├── test_lif.py # LIF-specific tests
├── test_izhikevich.py # 20+ pattern tests
├── test_hodgkin_huxley.py # Biophysical accuracy tests
├── test_adex.py # AdEx model tests
├── test_stdp.py # STDP learning rule tests
└── test_integration_solvers.py # Numerical method tests
Dependencies
- Internal: None (foundational module — other Phase 34 components depend on this)
- Downstream consumers:
- Phase 34.2
EventDrivenProcessor — receives SpikeEvent streams
- Phase 34.3
SynapticPlasticityEngine — uses STDPRule and apply_stdp()
- Phase 34.4
NeuromorphicHardwareInterface — maps neuron configs to hardware
- Phase 34.5
NeuromorphicOrchestrator — manages neuron populations
- External:
numpy (array operations), typing / typing_extensions
References
- Hodgkin, A.L. & Huxley, A.F. (1952). "A quantitative description of membrane current and its application to conduction and excitation in nerve." The Journal of Physiology, 117(4), 500–544. — The foundational biophysical neuron model.
- Izhikevich, E.M. (2003). "Simple model of spiking neurons." IEEE Transactions on Neural Networks, 14(6), 1569–1572. — The 4-parameter model reproducing 20+ cortical firing patterns.
- Gerstner, W. & Kistler, W.M. (2002). Spiking Neuron Models: Single Neurons, Populations, Plasticity. Cambridge University Press. — Comprehensive textbook on spiking neuron theory.
- Brette, R. & Gerstner, W. (2005). "Adaptive exponential integrate-and-fire model as an effective description of neuronal activity." Journal of Neurophysiology, 94(5), 3637–3642. — The AdEx model.
- Bi, G. & Poo, M. (1998). "Synaptic modifications in cultured hippocampal neurons: dependence on spike timing, synaptic strength, and postsynaptic cell type." Journal of Neuroscience, 18(24), 10464–10472. — Experimental basis for STDP.
- Dan, Y. & Poo, M. (2004). "Spike timing-dependent plasticity of neural circuits." Neuron, 44(1), 23–30. — Review of STDP mechanisms and implications.
- Maass, W. (1997). "Networks of spiking neurons: the third generation of neural network models." Neural Networks, 10(9), 1659–1671. — Theoretical foundations of spiking neural networks.
Acceptance Criteria
Phase 34.1 — SpikingNeuronModel
Component:
asi.neuromorphic.spiking_neuron_modelPhase: 34 — Neuromorphic Computing & Spiking Neural Network Integration
Sub-phase: 34.1 — Biologically-Inspired Spiking Neuron Models
Overview
The
SpikingNeuronModelmodule provides a family of biologically-inspired spiking neuron implementations that form the computational foundation of the neuromorphic computing subsystem. Unlike rate-coded artificial neurons that output continuous activation values, spiking neurons communicate through discrete spike events with precise temporal dynamics — enabling event-driven, energy-efficient computation with biologically plausible learning rules.This module implements four canonical neuron models spanning the biological fidelity–computational cost spectrum: from the minimal Leaky Integrate-and-Fire (LIF) to the biophysically detailed Hodgkin–Huxley model, each with configurable membrane dynamics, synaptic integration, spike-timing-dependent plasticity (STDP), and refractory period handling.
Data Classes (frozen dataclasses)
Protocol Class
Concrete Implementations
LIFNeuronIzhikevichNeuronHodgkinHuxleyNeuronAdaptiveExponentialNeuronLIFNeuron
IzhikevichNeuron
HodgkinHuxleyNeuron
AdaptiveExponentialNeuron (AdEx)
Key Algorithms
1. Membrane Dynamics Integration
Euler Method (first-order, fast):
RK4 Method (fourth-order, accurate):
For HH, the gating variables (m, h, n) are integrated simultaneously using the same method with their own rate equations:
2. STDP Weight Update Rule
Asymmetric Hebbian learning window:
3. Refractory Period Handling
Metrics
spike_rate_accuracymembrane_potential_rmsestdp_weight_convergencefiring_pattern_classification_accuracyspike_timing_precisionintegration_stabilitythroughput_neurons_per_secTest Targets
File Structure
Dependencies
EventDrivenProcessor— receivesSpikeEventstreamsSynapticPlasticityEngine— usesSTDPRuleandapply_stdp()NeuromorphicHardwareInterface— maps neuron configs to hardwareNeuromorphicOrchestrator— manages neuron populationsnumpy(array operations),typing/typing_extensionsReferences
Acceptance Criteria
SpikingNeuronProtocolwith all five methods