Replicated into ipython notebook form from http://www.nest-initiative.org/images/4/49/NEST_By_Example-2-6-0.pdf
Import numpy into our session
In [1]:
import numpy as np
You may need this extra step if you installed nest into an alternate path, e.g. /opt
In [2]:
import sys
sys.path.append('/opt/lib/python2.7/site-packages/')
Our first simulation investigates the response of one integrate-and-fire neuron to an alternating current and Poisson spike trains from an excitatory and an inhibitory source.
We record the membrane potential of the neuron to observe how the stimuli influence the neuron.
In this model, we inject a sine current with a frequency of 2 Hz and an amplitude of 100 pA into a neuron.
At the same time, the neuron receives random spiking input from two sources known as Poisson generators representing
The rates of each population is set as the product of its assumed number of neurons and their average firing rate. This network is simulated for 1000 milliseconds, and its membrane potential is plotted vs time.
In [3]:
import nest
import pylab
import nest.voltage_trace
In [4]:
neuron = nest.Create("iaf_neuron")
Create the sine current generator
In [5]:
sine = nest.Create('ac_generator', 1, {'amplitude': 100.0, 'frequency': 2.0})
Create a simulator of two large populations of neurons as poisson noise.
Rates here correspond to the total spikes/s of the population.
In [6]:
noise = nest.Create('poisson_generator', 2, [{'rate': 70000.0}, {'rate': 20000.0}])
Create a voltmeter to monitor membrane potentials
In [7]:
voltmeter = nest.Create('voltmeter', 1, {'withgid': True})
Make the connections
In [8]:
nest.Connect(sine, neuron)
nest.Connect(voltmeter, neuron)
nest.Connect(noise[:1], neuron, syn_spec={'weight': 1.0, 'delay': 1.0})
nest.Connect(noise[1:], neuron, syn_spec={'weight': -1.0, 'delay': 1.0})
Simulate the whole neuronal network for 1000 milliseconds
In [9]:
nest.Simulate(1000.0)
Plot the trace of the membrane potential
In [10]:
nest.voltage_trace.from_device(voltmeter)
pylab.show()
Print the network structure
In [11]:
nest.PrintNetwork()