nest / nest-simulator

The NEST simulator
http://www.nest-simulator.org
GNU General Public License v2.0
536 stars 364 forks source link

Finalize PyNEST examples #1504

Closed sarakonradi closed 3 years ago

sarakonradi commented 4 years ago

As with every release, all examples need to be tested and the documentation finalized before NEST 3.0 is released.

Following aspects need to be checked:

jimcost commented 4 years ago

Hi, I'm working on building a circuit with neurons based off Brette and Gerstner (2005). I've run the examples provided in the pynest directory ('brette_gerstner_fig_2c/3d.py') and the peak voltages do not line up (with parameter tweaking as well). It doesn't appear the neurons completely spike! The shape is similar but the voltages don't exceed roughly -30mV, see below.

Figure 2C - B&G (2005): image

brette_gerstner_fig_2c.py: image

If I set the current step to 8000pA and the peak voltage (V_peak) to 20mV - still unable to surmount a -25mV potential: image

The displayed figures come from Nest version 2.18.0 installed via NeuroFedora (on a Fedora 31 OS). Additionally, I tested this python script on a Ubuntu OS (18.04LTS) installed with Nest version 2.20.0 from source - the figures look identical.

This appears to be a "reasonably" place to post this issue, but I am not against moving it to a separate one. Also, not against helping. But, admittedly, ignorant where to begin looking into the 'aeif_cond/psc..." model code :/

heplesser commented 4 years ago

@jimcost Thank you for pointing this out. It is in part a feature (but a confusing one, see below), and in part indeed a little bug in the example.

The fact that the voltages traces produced by NEST never show values above ca -30 mV is an "optical" illusion: the NEST voltmeter only records subthreshold membrane potential values. Since the membrane potential grows exponentially fast towards a spike in the AdEx model by Brette and Gerstner, so within a single time step of 0.1 ms, the membrane potential shoots from, say, -30 mV to, e.g. +40 mV, a spike is detected, and the membrane potential reset, to -60 mV in the plots above. The voltmeter records only the -30 mV at the beginning of the time step and the -60 mV but never anything in between. If you set res = 0.001 in the example script and change line 77 to

voltmeter = nest.Create("voltmeter", params={'interval': res})

NEST will simulate and record with 0.001 ms resolution. Membrane potential tops will still be well below 0 mV at all times, but peaks get a little taller. For details on the AdEx model implementation see doc/model_details/aeif_models_implementation.ipynb.

@sarakonradi If we do not yet have any documentation of this non-intuitive behaviour of voltmeter/multimeter, we should add it.

Another interesting point is that the default parameter values of the aeif_conda_alpha model actually don't agree with the values in Brette & Gerstner. In particular, membrane potential is reset to -60 mV in the NEST example instead of to E_L = -70.6 mV in the paper. To simulate the model as in the paper, change line 52 to

neuron = nest.Create("aeif_cond_alpha", params={'V_peak': 20.0, 'V_reset': -70.6})

@sarakonradi We should probably create a separate issue for checking that examples directly referring to publications actually match those publications.

sarakonradi commented 4 years ago

@heplesser Thanks for your elaborate input! Do you suggest that we should add the documentation about the non-intuitive behavior of the voltmeter to example files such as brette_gestner_fig_2c or to the voltmeter/multimeter?

On a different note, I am facing difficulties with the run_examples.sh file for testing the PyNEST examples. The current version seems to only go through .sli files: https://github.com/nest/nest-simulator/blob/master/examples/run_examples.sh

Having checked the file's history, it seems that .py files were included in the past. However, they were removed at some point: https://github.com/nest/nest-simulator/commits/master/examples/run_examples.sh

Am I looking at the correct file for running the examples?

heplesser commented 4 years ago

@sarakonradi We should explain the behavior in the voltmeter/multimeter documentation and also add a note to examples that are affected.

Concerning the run_examples.sh script, I think @jougs @stinebuu @gtrensch @steffengraber might know more.

terhorstd commented 4 years ago

work on the example rewritng is going on in https://github.com/terhorstd/nest-simulator/tree/check-pynest-examples_1504 [edit] only NEST3-ification is done there

terhorstd commented 4 years ago

As @sarakonradi wrote in #1534, we'll use this issue to collect references to PRs and #1534 will not be the solving all of these. Instead each checkmark should probably be a seaparate PR.

terhorstd commented 4 years ago

removed link because #1534 solves only part of this issue and shouldn't close it.

jougs commented 3 years ago

Due to the merge of #1534, all remaining action items were resolved and I'm closing.