I need to set initial value for membrane potential for an experiment, Is there a way to do it. Any thoughts?
This isn’t something we support through the API. However, for the default
nengo backend (i.e.
nengo.Simulator), you can set the value of the membrane voltage signal yourself.
import nengo import numpy as np with nengo.Network(seed=0) as net: ens = nengo.Ensemble( 5, 1, gain=nengo.dists.Choice([1.0]), bias=nengo.dists.Choice([0.0]) ) probe = nengo.Probe(ens.neurons, "voltage") with nengo.Simulator(net) as sim: # get the signal that contains the voltage for the ensemble signal = sim.model.sig[ens.neurons]["voltage"] # manually change its initial value in the simulator. Here I use a linear range of values for the # voltages, but you can set them to whatever you want. Note that for most of our neuron types, # the voltages lie between 0 and 1, so you should choose values in this range (the LIF neuron # type does have a `min_voltage` parameter that you can use to allow negative voltages). sim.signals[signal][:] = np.linspace(0, 0.99, signal.size) sim.run_steps(10) print(sim.data[probe][:10])
When you run this code, you should get something like this
[[0. 0.23542928 0.47085857 0.70628785 0.94171713] [0. 0.22394726 0.44789452 0.67184178 0.89578904] [0. 0.21302522 0.42605045 0.63907567 0.8521009 ] [0. 0.20263586 0.40527172 0.60790758 0.81054345] [0. 0.19275319 0.38550639 0.57825958 0.77101278] [0. 0.18335251 0.36670502 0.55005753 0.73341004] [0. 0.1744103 0.3488206 0.52323091 0.69764121] [0. 0.16590421 0.33180842 0.49771263 0.66361685] [0. 0.15781297 0.31562594 0.4734389 0.63125187] [0. 0.15011634 0.30023268 0.45034901 0.60046535]]
where each column is a different neuron’s voltage, and each row is a different timestep. You can see that the voltages start around the values I set, and then they decay because due to the LIF neuron’s “leak” (they actually start at exactly the values I set, but the first row shows the voltages after they have already decayed for one timestep).
Note that this is not guaranteed to work with other backends (e.g.
nengo_loihi), in fact it most likely will not.
I’m also hoping to modify the membrane potential, and not sure on the best approach. My intention is to give realistic trial-to-trial response variability to firing rates, which I read is reasonably modeled when Gaussian noise is added to the membrane potential. So my thought is, ideally, to use the default LIF model, but right before the step that checks if membrane potential has crossed threshold, modify that membrane potential with Gaussian noise (but not alter the saved variable). – Is there a way to do that? (Or do you have other recommendations for simulating response variability that increases with spike rate?).
Thanks very much,
Hello and welcome! Great questions.
The variance of a Poisson distribution is equal to its own rate. Therefore, the simplest model that I can imagine that fits this requirement would be to use the output of the
LIF response curve as the input to a Poisson spike generator.
An example of how to do this can be found here: https://github.com/nengo/nengo/issues/1487#issue-378474524. An implementation that is more efficient for large time-steps (i.e., if each neuron is often spiking more than once per time-step) is further down in the same thread: https://github.com/nengo/nengo/issues/1487#issuecomment-513273782.
The team is planning to expose this as a core feature.
You could also do something like this with a custom neuron model. However it is not clear to me whether this would directly accomplish what you want in regards to scaling variability with frequency of spikes. If you could provide some code in Numpy/Python, to demonstrate / test this mechanism, we could assist in converting that code into a Nengo model.
Let us know if you have any issues or similar requests here (or a new thread if you have a different question). Thanks!