.. 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 Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_vinit_example.py: Initial membrane voltage ------------------------ 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:: default import nest import numpy import matplotlib.pyplot as plt .. 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-86 .. code-block:: default 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 87-88 Set the legend and the labels for the plot outside of the loop. .. GENERATED FROM PYTHON SOURCE LINES 88-93 .. code-block:: default plt.legend(loc=4) plt.xlabel("time (ms)") plt.ylabel("V_m (mV)") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _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-python :download:`Download Python source code: vinit_example.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: vinit_example.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_