1# -*- coding: utf-8 -*- 2# 3# brette_gerstner_fig_2c.py 4# 5# This file is part of NEST. 6# 7# Copyright (C) 2004 The NEST Initiative 8# 9# NEST is free software: you can redistribute it and/or modify 10# it under the terms of the GNU General Public License as published by 11# the Free Software Foundation, either version 2 of the License, or 12# (at your option) any later version. 13# 14# NEST is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with NEST. If not, see <http://www.gnu.org/licenses/>. 21 22""" 23Testing the adapting exponential integrate and fire model in NEST (Brette and Gerstner Fig 2C) 24---------------------------------------------------------------------------------------------- 25 26This example tests the adaptive integrate and fire model (AdEx) according to 27Brette and Gerstner [1]_ reproduces Figure 2C of the paper. 28Note that Brette and Gerstner give the value for `b` in `nA`. 29To be consistent with the other parameters in the equations, `b` must be 30converted to `pA` (pico Ampere). 31 32References 33~~~~~~~~~~ 34 35.. [1] Brette R and Gerstner W (2005). Adaptive exponential integrate-and-fire model as an effective 36 description of neuronal activity J. Neurophysiology. https://doi.org/10.1152/jn.00686.2005 37 38""" 39 40 41import nest 42import nest.voltage_trace 43import matplotlib.pyplot as plt 44 45nest.ResetKernel() 46 47############################################################################### 48# First we make sure that the resolution of the simulation is 0.1 ms. This is 49# important, since the slop of the action potential is very steep. 50 51nest.resolution = 0.1 52neuron = nest.Create("aeif_cond_alpha") 53 54############################################################################### 55# `a` and `b` are parameters of the adex model. Their values come from the 56# publication. 57 58neuron.set(a=4.0, b=80.5) 59 60############################################################################### 61# Next we define the stimulus protocol. There are two DC generators, 62# producing stimulus currents during two time-intervals. 63 64dc = nest.Create("dc_generator", 2) 65dc.set(amplitude=[500.0, 800.0], start=[0.0, 500.0], stop=[200.0, 1000.0]) 66 67############################################################################### 68# We connect the DC generators. 69 70nest.Connect(dc, neuron, 'all_to_all') 71 72############################################################################### 73# And add a ``voltmeter`` to sample the membrane potentials from the neuron 74# in intervals of 0.1 ms. 75 76voltmeter = nest.Create("voltmeter", params={'interval': 0.1}) 77nest.Connect(voltmeter, neuron) 78 79############################################################################### 80# Finally, we simulate for 1000 ms and plot a voltage trace to produce the 81# figure. 82 83nest.Simulate(1000.0) 84 85nest.voltage_trace.from_device(voltmeter) 86plt.axis([0, 1000, -80, -20]) 87plt.show() 88