.. 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 Click :ref:`here ` 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 --------------------- 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:: default import nest import nest.voltage_trace import matplotlib.pyplot as plt 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:: default 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:: default 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:: default 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:: default 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:: default nest.voltage_trace.from_device(voltmeter) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _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-python :download:`Download Python source code: one_neuron_with_noise.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: one_neuron_with_noise.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_