-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathalpha_syn.py
80 lines (60 loc) · 1.89 KB
/
alpha_syn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
"Alpha function" synapse of Rall. Chapter 12.2
"""
from __future__ import division
from PyDSTool import *
from PyDSTool.Toolbox.phaseplane import *
from common_lib import *
icdict = {'a1': 0, 'a2': 0}
pardict = {'tau_syn': 2, 'vthresh': -10,
'vpre': -80}
DSargs = args()
DSargs.name = 'alpha_syn'
DSargs.ics = icdict
DSargs.pars = pardict
DSargs.tdata = [0, 3]
DSargs.auxvars = ['vpre_aux']
DSargs.algparams = {'init_step': 1e-3}
# PyDSTool has a built-in Heaviside function
DSargs.varspecs = {'a1': '(-a1+heav(vpre-vthresh))/tau_syn',
'a2': '(-a2+a1)/tau_syn',
'vpre_aux': 'vpre'}
syn = Generator.Vode_ODEsystem(DSargs)
# primitive protocol for mimicking the pre-synaptic voltage's
# action potential for 1 ms starting at t = 5ms
t1 = 5
s1 = args(pars={'vpre': -80},
tdata=[0, t1])
t2 = 1
s2 = args(pars={'vpre': 50},
tdata=[0, t2])
t3 = 40
s3 = args(pars={'vpre': -80},
tdata=[0, t3])
def alpha(t):
"""Explicit solution of alpha function for Dirac delta function impulse
for presynaptic spike.
Uses current value of tau_syn in model.
Accepts scalar or vector t.
"""
tau = syn.pars['tau_syn']
return t/(tau*tau)*exp(-t/tau)
def test(tau):
syn.set(pars={'tau_syn': tau})
traj, pts = pcw_protocol(syn, [s1,s2,s3])
plt.figure(1)
plt.clf()
plt.plot(pts['t'], pts['vpre_aux']*0.001, 'k', linewidth=3, label='pre-syn v /1000')
plt.plot(pts['t'], pts['a2'], 'g', linewidth=2, label='a2 (output)')
plt.plot(pts['t'], pts['a1'], 'r:', label='a1')
ts = linspace(0, 30, 500)
ss = alpha(ts)
# offset ts for alpha function by onset of pre-synaptic spike
plt.plot(ts+t1, ss, 'g--', label='s (explicit)')
plt.xlabel('t')
plt.legend(loc='upper right')
plt.title('tau syn = %.2f ms' % tau)
plt.ylim([-0.1, 0.9])
plt.xlim([0, max(pts['t'])])
plt.show()
test(0.5)