.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/one_neuron_with_noise.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_with_noise.py: One neuron with noise --------------------- .. 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_with_noise.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 with input from the ``poisson_generator``, and records the neuron's membrane potential. .. GENERATED FROM PYTHON SOURCE LINES 32-39 First, we import all necessary modules needed to simulate, analyze and plot our example. Additionally, we set the verbosity to only show warnings and reset the kernel. Resetting the kernel removes any nodes we may have created previously and resets the internal clock to zero. This allows us to execute the script several times in a Python shell without interference from previous NEST simulations. .. GENERATED FROM PYTHON SOURCE LINES 39-47 .. 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 48-51 Second, the nodes (the neuron, poisson generator (two of them), and the voltmeter) are created using the ``Create`` function. We store the returned handles in variables for later reference. .. GENERATED FROM PYTHON SOURCE LINES 51-56 .. code-block:: Python neuron = nest.Create("iaf_psc_alpha") noise = nest.Create("poisson_generator", 2) voltmeter = nest.Create("voltmeter") .. GENERATED FROM PYTHON SOURCE LINES 57-62 Third, the Poisson generator is configured using ``SetStatus``, which expects a list of node handles and a list of parameter dictionaries. We set the Poisson generators to 8,000 Hz and 15,000 Hz, respectively. Note that we do not need to set parameters for the neuron and the voltmeter, since they have satisfactory defaults. .. GENERATED FROM PYTHON SOURCE LINES 62-66 .. code-block:: Python noise[0].rate = 80000.0 noise[1].rate = 15000.0 .. GENERATED FROM PYTHON SOURCE LINES 67-69 Fourth, the neuron is connected to the ``poisson_generator`` and to the ``voltmeter``. We also specify the synaptic weight and delay in this step. .. GENERATED FROM PYTHON SOURCE LINES 69-73 .. code-block:: Python nest.Connect(noise, neuron, syn_spec={"weight": [[1.2, -1.0]], "delay": 1.0}) nest.Connect(voltmeter, neuron) .. GENERATED FROM PYTHON SOURCE LINES 74-76 Now we simulate the network using ``Simulate``, which takes the desired simulation time in milliseconds. .. GENERATED FROM PYTHON SOURCE LINES 76-79 .. code-block:: Python nest.Simulate(1000.0) .. GENERATED FROM PYTHON SOURCE LINES 80-82 Finally, we plot the neuron's membrane potential as a function of time. .. GENERATED FROM PYTHON SOURCE LINES 82-85 .. code-block:: Python nest.voltage_trace.from_device(voltmeter) plt.show() .. _sphx_glr_download_auto_examples_one_neuron_with_noise.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_with_noise.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: one_neuron_with_noise.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_