One neuron example

This script simulates a neuron driven by a constant external current and records its membrane potential.

See Also

Two neuron example

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.

import nest
import nest.voltage_trace

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}]) or nest.Create("voltmeter", [{"withgid": True, "withtime": True}]). In this example we will configure these parameters in an additional step, which is explained in the third section.

neuron = nest.Create("iaf_psc_alpha")
voltmeter = nest.Create("voltmeter")

Third, the neuron and the voltmeter are configured using SetStatus, which expects a list of node handles and a list of parameter dictionaries. In this example we use SetStatus to configure the constant current input to the neuron. We also want to record the global id of the observed nodes and set the withgid flag of the voltmeter to True.

nest.SetStatus(neuron, "I_e", 376.0)
nest.SetStatus(voltmeter, [{"withgid": True}])

Fourth, the neuron is connected to the voltmeter. The command Connect has different variants. Plain Connect just takes the handles of pre- and post-synaptic nodes and uses the default values for weight and delay. Note that the connection direction for the voltmeter is reversed compared to the spike detector, 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.

nest.Connect(voltmeter, neuron)

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


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


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

Gallery generated by Sphinx-Gallery