SpikingNeuralNetworks.jl
Simulate networks of spiking neurons in Julia: point and dendritic neuron models, conductance and receptor synapses, delays, long- and short-term plasticity, Poisson and spike-time inputs, and recording, analysis and plotting of the results.
using SpikingNeuralNetworks
SNN.@load_units
E = SNN.IF(N = 100)
EE = SNN.SpikingSynapse(E, E, :ge; conn = (p = 0.1, μ = 2nS))
drive = SNN.Stimulus(SNN.PoissonFixed(rate = 2kHz), E, :ge)
model = SNN.compose(; E, EE, drive, silent = true)
SNN.monitor!(E, [:fire])
SNN.sim!(model, 1s)
SNN.firing_rate(E; interval = 0:10ms:1s, pop_average = true)([0.0, 2.2834244929254055, 40.68338715471327, 112.88480533286929, 198.40709987096488, 281.3806691765785, 355.169330900535, 416.5934706898406, 465.56828362401575, 504.06117463018745 … 615.1572279437823, 615.0196040605078, 614.9559256672364, 615.2577079700131, 615.2575325480575, 614.9025860342954, 615.0801803523427, 615.0424437279071, 614.9120085004324, 614.753795725992], 0.0f0:10.0f0:1000.0f0)Install with ] add SpikingNeuralNetworks, then follow Getting started.
Packages
SpikingNeuralNetworks loads and re-exports three packages of the JuliaSNN organisation, and defines the alias SNN:
- SNNModels: models and simulation engine;
- SNNPlots: plots of the recordings (Makie);
- SNNUtils: stimulation protocols and analysis.
Where to go
| To | Read |
|---|---|
| build and run a first network | Getting started |
| learn by example: neurons, plasticity, save and rerun | Tutorials: Populations, Plasticity, Simulations |
| understand populations, connections, stimuli | Populations, Stimuli |
| run, train, change precision or threads, save | Running simulations |
| record and plot | Recordings, Visualization |
| add plasticity | Plasticity |
| find a model and its equations | Model catalogue |
| write a new model | Model extensions |
| upgrade from 1.x | What changes from v1 to v2, V2 changelog |
What changes from v1 to v2
Version 2 is faster (an E/I network runs 8 to 12 times faster than 1.9, synapses use a third of the memory) and adds Float64 models, opt-in threads and rule switching. Keyword-built models run unchanged; what needs attention:
Saved files
- Files saved with version 1 cannot be loaded: rebuild the model from its configuration and save it again.
Plasticity
- Rule types are part of the synapse type: install another rule with
with_plasticity,without_plasticityorchange_plasticity(model, :name; LTP, STP);update_plasticity!keeps the type. vSTDPParameteris event-driven: read its weights withplasticity_value(syn, :W); the 1.9 rule isvSTDPDenseParameter.- STDP traces are stored lazily: read them with
trace_values(syn, :tpre)or aftersync_traces!(syn). iSTDPTimeis removed: useiSTDPRateoriSTDPPotential.
Synapse fields
syn.J,syn.index: callSNNModels.ensure_transpose!(syn)first.syn.ρ: read withSNNModels.efficacy(syn), callSNNModels.materialize_efficacy!(syn)before writing.syn.param.delaytimehas length 1 when all delays are equal; delays round up to whole steps.
Results
- Seeded runs with Poisson inputs, delays at
dt = 0.1ms, or STDP weights differ from 1.9 (same statistics). sim!/train!flush subnormal numbers to zero: passflush_subnormals = falsefor IEEE behaviour.
Custom code
- Positional constructors of the changed structs need the new fields; keyword constructors are unchanged.
- Do not write
pop.fireof an integrate-and-fire population after itsintegrate!within a step. - For
Float64build populations withVFT = Vector{Float64}and rules withFT = Float64.
Every change, with its migration: V2 changelog and CHANGELOG_2.0.0.md of SNNModels.