.. 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.verbosity = nest.VerbosityLevel.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-61 Third, the rates of the Poisson generator are configured. We set the generators to 80,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 61-65 .. code-block:: Python noise[0].rate = 80000.0 noise[1].rate = 15000.0 .. GENERATED FROM PYTHON SOURCE LINES 66-68 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 68-72 .. 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 73-75 Now we simulate the network using ``Simulate``, which takes the desired simulation time in milliseconds. .. GENERATED FROM PYTHON SOURCE LINES 75-78 .. code-block:: Python nest.Simulate(1000.0) .. GENERATED FROM PYTHON SOURCE LINES 79-81 Finally, we plot the neuron's membrane potential as a function of time. .. GENERATED FROM PYTHON SOURCE LINES 81-84 .. 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 ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: one_neuron_with_noise.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_