.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/vinit_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_vinit_example.py: Initial membrane voltage ------------------------ .. only:: html ---- Run this example as a Jupyter notebook: .. card:: :width: 25% :margin: 2 :text-align: center :link: https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fnest%2Fnest-simulator-examples&urlpath=lab%2Ftree%2Fnest-simulator-examples%2Fnotebooks%2Fnotebooks%2Fvinit_example.ipynb&branch=main :link-alt: JupyterHub service .. image:: https://nest-simulator.org/TryItOnEBRAINS.png .. grid:: 1 1 1 1 :padding: 0 0 2 0 .. grid-item:: :class: sd-text-muted :margin: 0 0 3 0 :padding: 0 0 3 0 :columns: 4 See :ref:`our guide ` for more information and troubleshooting. ---- Plot several runs of the ``iaf_cond_exp_sfa_rr`` neuron without input for various initial values of the membrane potential. References ~~~~~~~~~~ .. [1] Dayan, P. and Abbott, L.F. (2001) Theoretical neuroscience, MIT Press, page 166 .. GENERATED FROM PYTHON SOURCE LINES 38-39 First, the necessary modules for simulation and plotting are imported. .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: Python import matplotlib.pyplot as plt import nest import numpy .. GENERATED FROM PYTHON SOURCE LINES 45-68 A loop runs over a range of initial membrane voltages. In the beginning of each iteration, the simulation kernel is put back to its initial state using `ResetKernel`. Next, a neuron is instantiated with ``Create``. The used neuron model ``iaf_cond_exp_sfa_rr`` is an implementation of a spiking neuron with integrate-and-fire dynamics, conductance-based synapses, an additional spike-frequency adaptation and relative refractory mechanisms as described in [1]_. Incoming spike events induce a postsynaptic change of conductance modeled by an exponential function. ``SetStatus`` allows to assign the initial membrane voltage of the current loop run to the neuron. ``Create`` is used once more to instantiate a ``voltmeter`` as recording device which is subsequently connected to the neuron with ``Connect``. Then, a simulation with a duration of 75 ms is started with ``Simulate``. When the simulation has finished, the recorded times and membrane voltages are read from the voltmeter via ``get``. Finally, the time course of the membrane voltages is plotted for each of the different initial values. .. GENERATED FROM PYTHON SOURCE LINES 68-85 .. code-block:: Python for vinit in numpy.arange(-100, -50, 10, float): nest.ResetKernel() cbn = nest.Create("iaf_cond_exp_sfa_rr") cbn.V_m = vinit voltmeter = nest.Create("voltmeter") nest.Connect(voltmeter, cbn) nest.Simulate(75.0) t = voltmeter.get("events", "times") v = voltmeter.get("events", "V_m") plt.plot(t, v, label="initial V_m = %.2f mV" % vinit) .. GENERATED FROM PYTHON SOURCE LINES 86-87 Set the legend and the labels for the plot outside of the loop. .. GENERATED FROM PYTHON SOURCE LINES 87-92 .. code-block:: Python plt.legend(loc=4) plt.xlabel("time (ms)") plt.ylabel("V_m (mV)") plt.show() .. _sphx_glr_download_auto_examples_vinit_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: vinit_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: vinit_example.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_