1# -*- coding: utf-8 -*- 2# 3# tsodyks_depressing.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""" 23Tsodyks depressing example 24-------------------------- 25 26This scripts simulates two neurons. One is driven with dc-input and 27connected to the other one with a depressing Tsodyks synapse. The membrane 28potential trace of the second neuron is recorded. 29 30This example reproduces Figure 1A of [1]_. 31This example is analog to ``tsodyks_facilitating.py``, except that different 32synapse parameters are used. Here, a large facilitation parameter ``U`` 33causes a fast saturation of the synaptic efficacy (Eq. 2.2), disabling a 34facilitating behavior. 35 36References 37~~~~~~~~~~ 38 39.. [1] Tsodyks M, Pawelzik K, Markram H (1998). Neural networks with dynamic synapses. Neural 40 computation, http://dx.doi.org/10.1162/089976698300017502 41 42See Also 43~~~~~~~~ 44 45:doc:`tsodyks_facilitating` 46 47""" 48 49############################################################################### 50# First, we import all necessary modules for simulation and plotting. 51 52import nest 53import nest.voltage_trace 54import matplotlib.pyplot as plt 55from numpy import exp 56 57############################################################################### 58# Second, the simulation parameters are assigned to variables. The neuron 59# and synapse parameters are stored into a dictionary. 60 61resolution = 0.1 # simulation step size (ms) 62Tau = 40.0 # membrane time constant 63Theta = 15.0 # threshold 64E_L = 0.0 # reset potential of membrane potential 65R = 0.1 # 100 M Ohm 66C = Tau / R # Tau (ms)/R in NEST units 67TauR = 2.0 # refractory time 68Tau_psc = 3.0 # time constant of PSC (= Tau_inact) 69Tau_rec = 800.0 # recovery time 70Tau_fac = 0.0 # facilitation time 71U = 0.5 # facilitation parameter U 72A = 250.0 # PSC weight in pA 73f = 20.0 / 1000.0 # frequency in Hz converted to 1/ms 74Tend = 1200.0 # simulation time 75TIstart = 50.0 # start time of dc 76TIend = 1050.0 # end time of dc 77I0 = Theta * C / Tau / (1 - exp(-(1 / f - TauR) / Tau)) # dc amplitude 78 79neuron_param = {"tau_m": Tau, 80 "t_ref": TauR, 81 "tau_syn_ex": Tau_psc, 82 "tau_syn_in": Tau_psc, 83 "C_m": C, 84 "V_reset": E_L, 85 "E_L": E_L, 86 "V_m": E_L, 87 "V_th": Theta} 88 89syn_param = {"tau_psc": Tau_psc, 90 "tau_rec": Tau_rec, 91 "tau_fac": Tau_fac, 92 "U": U, 93 "delay": 0.1, 94 "weight": A, 95 "u": 0.0, 96 "x": 1.0} 97 98############################################################################### 99# Third, we reset the kernel and set the resolution using the corresponding 100# kernel attribute. 101 102nest.ResetKernel() 103nest.resolution = resolution 104 105############################################################################### 106# Fourth, the nodes are created using ``Create``. We store the returned 107# handles in variables for later reference. 108 109neurons = nest.Create("iaf_psc_exp", 2) 110dc_gen = nest.Create("dc_generator") 111volts = nest.Create("voltmeter") 112 113################################################################################ 114# Fifth, the ``iaf_psc_exp`` neurons, the ``dc_generator`` and the ``voltmeter`` 115# are configured using ``SetStatus``, which expects a list of node handles and 116# a parameter dictionary or a list of parameter dictionaries. 117 118neurons.set(neuron_param) 119dc_gen.set(amplitude=I0, start=TIstart, stop=TIend) 120volts.set(label="voltmeter", interval=1.) 121 122############################################################################### 123# Sixth, the ``dc_generator`` is connected to the first neuron 124# (`neurons[0]`) and the ``voltmeter`` is connected to the second neuron 125# (`neurons[1]`). The command ``Connect`` has different variants. Plain 126# ``Connect`` just takes the handles of pre- and postsynaptic nodes and uses 127# the default values for weight and delay. Note that the connection 128# direction for the ``voltmeter`` reflects the signal flow in the simulation 129# kernel, because it observes the neuron instead of receiving events from it. 130 131nest.Connect(dc_gen, neurons[0]) 132nest.Connect(volts, neurons[1]) 133 134############################################################################### 135# Seventh, the first neuron (`neurons[0]`) is connected to the second 136# neuron (`neurons[1]`). The command ``CopyModel`` copies the 137# ``tsodyks_synapse`` model to the new name ``syn`` with parameters 138# ``syn_param``. The manually defined model ``syn`` is used in the 139# connection routine via the ``syn_spec`` parameter. 140 141nest.CopyModel("tsodyks_synapse", "syn", syn_param) 142nest.Connect(neurons[0], neurons[1], syn_spec="syn") 143 144############################################################################### 145# Finally, we simulate the configuration using the command ``Simulate``, 146# where the simulation time `Tend` is passed as the argument. We plot the 147# target neuron's membrane potential as a function of time. 148 149nest.Simulate(Tend) 150nest.voltage_trace.from_device(volts) 151plt.show() 152