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

ToRead
build and run a first networkGetting started
learn by example: neurons, plasticity, save and rerunTutorials: Populations, Plasticity, Simulations
understand populations, connections, stimuliPopulations, Stimuli
run, train, change precision or threads, saveRunning simulations
record and plotRecordings, Visualization
add plasticityPlasticity
find a model and its equationsModel catalogue
write a new modelModel extensions
upgrade from 1.xWhat 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_plasticity or change_plasticity(model, :name; LTP, STP); update_plasticity! keeps the type.
  • vSTDPParameter is event-driven: read its weights with plasticity_value(syn, :W); the 1.9 rule is vSTDPDenseParameter.
  • STDP traces are stored lazily: read them with trace_values(syn, :tpre) or after sync_traces!(syn).
  • iSTDPTime is removed: use iSTDPRate or iSTDPPotential.

Synapse fields

  • syn.J, syn.index: call SNNModels.ensure_transpose!(syn) first.
  • syn.ρ: read with SNNModels.efficacy(syn), call SNNModels.materialize_efficacy!(syn) before writing.
  • syn.param.delaytime has 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: pass flush_subnormals = false for IEEE behaviour.

Custom code

  • Positional constructors of the changed structs need the new fields; keyword constructors are unchanged.
  • Do not write pop.fire of an integrate-and-fire population after its integrate! within a step.
  • For Float64 build populations with VFT = Vector{Float64} and rules with FT = Float64.

Every change, with its migration: V2 changelog and CHANGELOG_2.0.0.md of SNNModels.