.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/one_neuron.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_one_neuron.py: One neuron example ------------------ .. 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%2Fone_neuron.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. ---- This script simulates a neuron driven by a constant external current and records its membrane potential. See Also ~~~~~~~~ :doc:`twoneurons` .. GENERATED FROM PYTHON SOURCE LINES 37-45 First, we import all necessary modules for simulation, analysis and plotting. Additionally, we set the verbosity to suppress info messages and reset the kernel. Resetting the kernel allows you to execute the script several times in a Python shell without interferences from previous NEST simulations. Thus, without resetting the kernel the network status including connections between nodes, status of neurons, devices and intrinsic time clocks, is kept and influences the next simulations. .. GENERATED FROM PYTHON SOURCE LINES 45-53 .. code-block:: Python import matplotlib.pyplot as plt import nest import nest.voltage_trace nest.set_verbosity("M_WARNING") nest.ResetKernel() .. GENERATED FROM PYTHON SOURCE LINES 54-63 Second, the nodes (neurons and devices) are created using ``Create``. We store the returned handles in variables for later reference. The ``Create`` function also allow you to create multiple nodes e.g. ``nest.Create('iaf_psc_alpha',5)`` Also default parameters of the model can be configured using ``Create`` by including a list of parameter dictionaries e.g. `nest.Create("iaf_psc_alpha", params=[{'I_e':376.0}])`. In this example we will configure these parameters in an additional step, which is explained in the third section. .. GENERATED FROM PYTHON SOURCE LINES 63-67 .. code-block:: Python neuron = nest.Create("iaf_psc_alpha") voltmeter = nest.Create("voltmeter") .. GENERATED FROM PYTHON SOURCE LINES 68-69 Third, we set the external current of the neuron. .. GENERATED FROM PYTHON SOURCE LINES 69-72 .. code-block:: Python neuron.I_e = 376.0 .. GENERATED FROM PYTHON SOURCE LINES 73-82 Fourth, the neuron is connected to the voltmeter. The command ``Connect`` has different variants. Plain ``Connect`` just takes the handles of pre- and postsynaptic nodes and uses the default values for weight and delay. Note that the connection direction for the voltmeter is reversed compared to the spike recorder, because it observes the neuron instead of receiving events from it. Thus, ``Connect`` reflects the direction of signal flow in the simulation kernel rather than the physical process of inserting an electrode into the neuron. The latter semantics is presently not available in NEST. .. GENERATED FROM PYTHON SOURCE LINES 82-85 .. code-block:: Python nest.Connect(voltmeter, neuron) .. GENERATED FROM PYTHON SOURCE LINES 86-88 Now we simulate the network using ``Simulate``, which takes the desired simulation time in milliseconds. .. GENERATED FROM PYTHON SOURCE LINES 88-91 .. code-block:: Python nest.Simulate(1000.0) .. GENERATED FROM PYTHON SOURCE LINES 92-94 Finally, we plot the neuron's membrane potential as a function of time and display the plot using pyplot. .. GENERATED FROM PYTHON SOURCE LINES 94-97 .. code-block:: Python nest.voltage_trace.from_device(voltmeter) plt.show() .. _sphx_glr_download_auto_examples_one_neuron.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: one_neuron.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: one_neuron.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_