nest / nestml

A domain specific language for neuron and synapse models in spiking neural network simulation
GNU General Public License v2.0
45 stars 46 forks source link

Check NEST initialization of state/parameters/internals #982

Open clinssen opened 8 months ago

clinssen commented 8 months ago

Check that state/parameters/internals obtain the right initial values, at different stages, e.g. after Create(), after CopyModel().

Upon model creation, parameters, internals and state are initialized to their default values defined in the NESTML model (in that order). What if there is a state variable, dependent on a parameter value, that is set to a non-default value? Could NEST CopyModel() be used for this?

clinssen commented 8 months ago

Including the relevant report from @tomtetzlaff here about the ignore_and_fire neuron model.

In my original version, I had defined the variable

phase_steps integer = steps( max(0.,phase) / firing_rate )

in the internals block. It's just the integer version of the state variable "phase". In the above NESTML version, you moved the definition of "phase_steps" to the state block, probably because it is not a fixed parameter, but a quantity which changes over time.

However, instead of calculating its initial value from the initial phase, you set it to

phase_steps integer = firing_period_steps / 2

This is a problem because now one cannot control the initial value of "phase_steps" by setting the initial value of "phase". If I create a population of ignore_and-fire neurons, they all fire the first spike at the same time, even if the initial "phase" is randomized. The idea was that by randomizing the initial phase, one can generate asynchronous firing, as described here:

https://jugit.fz-juelich.de/aca_requirements_validation_and_benchmarking/development-of-test-and-science-cases/-/blob/master/testcases/utils/nestml_models/doc/ignore_and_fire.md?ref_type=heads

In

https://jugit.fz-juelich.de/aca_requirements_validation_and_benchmarking/development-of-test-and-science-cases/-/blob/master/testcases/utils/nestml_models/ignore_and_fire.nestml

and in the attached script, you'll find a revised version of the model. Here, I declare "phase_steps" in line 25 as a state variable with initial value zero, but then it is recalculated in line 41 at the beginning of each update step according to the current value of the phase. This generates the correct behavior, but I find this solution somewhat suboptimal. In principle, line 41 needs to be executed only during the initialization. At all later steps, "phase_steps" is already in sync with "phase" according to line 52. Do you see a better solution? Having line 41 in the state block doesn't work because then "phase_steps" is set according to the default initial value of "phase", rather than according to the initial "phase" set by the user.

ignore_and_fire.txt