Initial membrane voltage

Run this example as a Jupyter notebook:

See our guide for more information and troubleshooting.

Plot several runs of the iaf_cond_exp_sfa_rr neuron without input for various initial values of the membrane potential.


First, the necessary modules for simulation and plotting are imported.

import matplotlib.pyplot as plt
import nest
import numpy

A loop runs over a range of initial membrane voltages.

In the beginning of each iteration, the simulation kernel is put back to its initial state using ResetKernel.

Next, a neuron is instantiated with Create. The used neuron model iaf_cond_exp_sfa_rr is an implementation of a spiking neuron with integrate-and-fire dynamics, conductance-based synapses, an additional spike-frequency adaptation and relative refractory mechanisms as described in [1]. Incoming spike events induce a postsynaptic change of conductance modeled by an exponential function. SetStatus allows to assign the initial membrane voltage of the current loop run to the neuron.

Create is used once more to instantiate a voltmeter as recording device which is subsequently connected to the neuron with Connect.

Then, a simulation with a duration of 75 ms is started with Simulate.

When the simulation has finished, the recorded times and membrane voltages are read from the voltmeter via get.

Finally, the time course of the membrane voltages is plotted for each of the different initial values.

for vinit in numpy.arange(-100, -50, 10, float):

    cbn = nest.Create("iaf_cond_exp_sfa_rr")
    cbn.V_m = vinit

    voltmeter = nest.Create("voltmeter")
    nest.Connect(voltmeter, cbn)


    t = voltmeter.get("events", "times")
    v = voltmeter.get("events", "V_m")

    plt.plot(t, v, label="initial V_m = %.2f mV" % vinit)

Set the legend and the labels for the plot outside of the loop.

plt.xlabel("time (ms)")
plt.ylabel("V_m (mV)")

Gallery generated by Sphinx-Gallery