One neuron with noise

This script simulates a neuron with input from the poisson_generator, and records the neuron’s membrane potential.

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.

import nest
import nest.voltage_trace

nest.set_verbosity("M_WARNING")
nest.ResetKernel()

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.

neuron = nest.Create("iaf_psc_alpha")
noise = nest.Create("poisson_generator", 2)
voltmeter = nest.Create("voltmeter")

Third, the voltmeter and the Poisson generator are configured using SetStatus, which expects a list of node handles and a list of parameter dictionaries. Note that we do not need to set parameters for the neuron, since it has satisfactory defaults. We set each Poisson generator to 8000 Hz and 15000 Hz, respectively. For the voltmeter, we want to record the global id of the observed nodes and set the withgid flag of the voltmeter to True. We also set its property withtime so it will also record the points in time at which it samples the membrane voltage.

nest.SetStatus(noise, [{"rate": 80000.0}, {"rate": 15000.0}])
nest.SetStatus(voltmeter, {"withgid": True, "withtime": True})

Fourth, the neuron is connected to the poisson_generator and to the voltmeter. We also specify the synaptic weight and delay in this step.

nest.Connect(noise, neuron, syn_spec={'weight': [[1.2, -1.0]], 'delay': 1.0})
nest.Connect(voltmeter, neuron)

Now we simulate the network using Simulate, which takes the desired simulation time in milliseconds.

nest.Simulate(1000.0)

Finally, we plot the neuron’s membrane potential as a function of time.

nest.voltage_trace.from_device(voltmeter)

Total running time of the script: ( 0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery