Stimuli
After this page you can drive a population with Poisson, spike-time and current inputs, choose the neurons they reach, and change them between runs. Every stimulus model, with its equations, is in the stimulus catalogue.
Building a stimulus
A stimulus is built from a parameter object, a target population and a target variable:
stim = SNN.Stimulus(param, post, sym, [comp]; kwargs...)paramselects the stimulus model (PoissonFixed,PoissonLayer,SpikeTimeStimulusParameter,CurrentNoise, ...).postis the population that receives the input.symis the variable that receives it: a synaptic target (:ge,:gi, ...) for spiking inputs, a field of the population (by default:I) for currents.compis the compartment of a dendritic neuron (:s,:d1,:d2forTripod). Poisson stimuli take it as the keywordcomp, layer and spike-time stimuli as the fourth positional argument.
Add it to a model with compose, under any name:
using SpikingNeuralNetworks
SNN.@load_units
E = SNN.IF(N = 100)
noise = SNN.Stimulus(SNN.PoissonFixed(rate = 2kHz), E, :ge) # independent trains
layer = SNN.Stimulus(SNN.PoissonLayer(rate = 10Hz, N = 500), E, :gi; # shared input layer
conn = (p = 0.1, μ = 1.0))
model = SNN.compose(; E, noise, layer, silent = true)
SNN.monitor!(E, :fire)
SNN.sim!(; model, duration = 500ms)Stimuli are applied at the start of each step, before the populations are integrated.
Choosing the target neurons
PoissonStimulus(PoissonFixed,PoissonInterval,PoissonVariable): keywordneurons = :ALL(default), a vector or range of indices, orneurons = :p_postwithp_post = 0.2to target a random 20% of the population.CurrentStimulus: keywordneurons = :ALLor a vector of indices.PoissonStimulusLayerandSpikeTimeStimulus: the targets are given by the connectivityconn, either a NamedTuple passed tosparse_matrix(e.g.(p = 0.1, μ = 1.0, rule = :Fixed)) or, for spike-time stimuli, a weight matrix of sizepost.N x N.SpikeTimeStimulusIdentityconnects inputjto neuronj.
using SpikingNeuralNetworks
SNN.@load_units
E = SNN.IF(N = 100)
first20 = SNN.Stimulus(SNN.PoissonFixed(rate = 1kHz), E, :ge; neurons = 1:20)
random = SNN.Stimulus(SNN.PoissonFixed(rate = 1kHz), E, :ge; neurons = :p_post, p_post = 0.2)
SNN.neurons(random) # the sampled indices
current = SNN.Stimulus(SNN.CurrentNoise(E; I_base = 200pA), E; neurons = [1, 2, 3])Changing a stimulus during a simulation
Stimuli can be modified between sim! calls (or from a perturbation! function):
set_active!(stim, false)/set_active!(stim, true)switches aPoissonStimulusor aPoissonStimulusLayeroff and on.set_intervals!(stim, [[t1, t2], ...])replaces the activity intervals of aPoissonIntervalstimulus.set_variable!(stim, key, value)setsparam.variables[key]of aPoissonVariablestimulus, broadcastsvalueinto an array field of the parameter (e.g.:ratesofPoissonLayerHet,:I_baseofCurrentNoise), or replaces a scalar field of a mutable parameter (e.g.:rateofPoissonFixed,PoissonInterval,PoissonLayer).update_spikes!(stim, spikes, start_time)andshift_spikes!(stim, delay)replace (sorted by time) or shift the spike list of aSpikeTimeStimulus; empty lists are allowed.
All of them also accept a StimulusGroup and are then applied to every element.
using SpikingNeuralNetworks
SNN.@load_units
E = SNN.IF(N = 50)
f(t, v) = v[:rate]
stim = SNN.Stimulus(SNN.PoissonVariable(variables = Dict{Symbol,Any}(:rate => 1kHz), rate = f), E, :ge)
pulse = SNN.Stimulus(SNN.PoissonInterval(rate = 2kHz, intervals = [[50ms, 100ms]]), E, :ge)
model = SNN.compose(; E, stim, pulse, silent = true)
SNN.monitor!(E, :fire)
SNN.sim!(; model, duration = 200ms)
SNN.set_variable!(stim, :rate, 3kHz) # stronger background
SNN.set_intervals!(pulse, [[250ms, 300ms]]) # new pulse
SNN.sim!(; model, duration = 200ms)
SNN.set_active!(stim, false) # background off
SNN.sim!(; model, duration = 200ms)Multicompartment targets
MultiCompartmentStimulusGroup(param, post, sym, comps) creates one Poisson stimulus per compartment and bundles them in a StimulusGroup:
using SpikingNeuralNetworks
SNN.@load_units
E = SNN.Tripod(N = 10)
group = SNN.MultiCompartmentStimulusGroup(SNN.PoissonFixed(rate = 200Hz), E, :glu, [:d1, :d2])
soma = SNN.Stimulus(SNN.PoissonFixed(rate = 100Hz), E, :glu; comp = :s)
model = SNN.compose(; E, group, soma, silent = true)
SNN.sim!(; model, duration = 100ms)Recording stimuli
Stimuli that have their own spikes (PoissonStimulusLayer, SpikeTimeStimulus) can be monitored like populations: monitor!(stim, :fire), then spiketimes(stim).