1 | ;; |
---|
2 | ;; Simple Model of Spiking Neurons, Izhikevich E |
---|
3 | ;; |
---|
4 | ;; IEEE Transactions on Neural Networks (2003) 14:1569- 1572 |
---|
5 | ;; |
---|
6 | ;; |
---|
7 | |
---|
8 | (use signal-diagram signal-diagram-dynamics mathh srfi-1 ) |
---|
9 | |
---|
10 | (define (Izhikevich03:construct t V U k1 k2 k3 theta a b c d Isyn ) |
---|
11 | |
---|
12 | `((f . ,(let* ((subthreshold-eq (ODE (variable h) t |
---|
13 | (V (+ (* k1 V V) (* k2 V) k3 (neg U) Isyn)) |
---|
14 | (U (* a (- (* b V) U))))) |
---|
15 | |
---|
16 | (threshold-detect (ASSIGN (spike (- V theta)))) |
---|
17 | |
---|
18 | (refractory-eq (ASSIGN (t (+ t h) ) |
---|
19 | (h h) |
---|
20 | (V c) |
---|
21 | (U (+ U d)))) |
---|
22 | ) |
---|
23 | |
---|
24 | (TRANSIENT subthreshold-eq refractory-eq 'spike threshold-detect) |
---|
25 | |
---|
26 | )) |
---|
27 | |
---|
28 | (initial . |
---|
29 | ((h 1e-2) |
---|
30 | (t ,t) |
---|
31 | (V ,V) |
---|
32 | (U ,U) |
---|
33 | (k1 ,k1) |
---|
34 | (k2 ,k2) |
---|
35 | (k3 ,k3) |
---|
36 | (theta ,theta) |
---|
37 | (a ,a) |
---|
38 | (b ,b) |
---|
39 | (c ,c) |
---|
40 | (d ,d) |
---|
41 | (Isyn ,Isyn) |
---|
42 | )) |
---|
43 | )) |
---|
44 | |
---|
45 | |
---|
46 | (define (dataflow model) |
---|
47 | (let* ((f (alist-ref 'f model)) |
---|
48 | (initial (alist-ref 'initial model)) |
---|
49 | (input (map car initial))) |
---|
50 | (print "input = " input) |
---|
51 | (print "dataflow f: " (dataflow (construct f) input)) |
---|
52 | )) |
---|
53 | |
---|
54 | |
---|
55 | (define (codegen name model #!key (language 'scheme) (random #f) (pre #t) (post #t) (solver 'rkdp)) |
---|
56 | (let* ((f (alist-ref 'f model)) |
---|
57 | (initial (alist-ref 'initial model))) |
---|
58 | (case language |
---|
59 | ((octave Octave) (codegen/Octave name (construct f) initial: initial pre: pre solver: solver)) |
---|
60 | ((scheme Scheme) (codegen/scheme name (construct f) initial: initial pre: pre solver: solver)) |
---|
61 | ((ML) (codegen/ML name (construct f) initial: initial random: random pre: pre post: post solver: solver))) |
---|
62 | )) |
---|
63 | |
---|
64 | |
---|
65 | ;; Parameters common to all spiking regimes |
---|
66 | (define k1 0.04) |
---|
67 | (define k2 5.0) |
---|
68 | (define k3 140.0) |
---|
69 | (define theta 30.0) |
---|
70 | (define Isyn 10.0) |
---|
71 | |
---|
72 | ;; State initial values |
---|
73 | (define t 0.0) |
---|
74 | (define V -65.0) |
---|
75 | |
---|
76 | |
---|
77 | ;; Regular spiking (RS) parameters |
---|
78 | (define RS |
---|
79 | (let ((a 0.02) |
---|
80 | (b 0.2) |
---|
81 | (c -65.0) |
---|
82 | (d 8.0)) |
---|
83 | (Izhikevich03:construct |
---|
84 | ;; t V U k1 k2 k3 theta a b c d Isyn |
---|
85 | t V (* b V) k1 k2 k3 theta a b c d Isyn))) |
---|
86 | |
---|
87 | ;; Intrinsically bursting (IB) parameters |
---|
88 | (define IB |
---|
89 | (let ((a 0.02) |
---|
90 | (b 0.2) |
---|
91 | (c -55.0) |
---|
92 | (d 4.0)) |
---|
93 | (Izhikevich03:construct |
---|
94 | ;; t V U k1 k2 k3 theta a b c d Isyn |
---|
95 | t V (* b V) k1 k2 k3 theta a b c d Isyn))) |
---|
96 | |
---|
97 | |
---|
98 | ;; Chattering (CH) parameters |
---|
99 | (define CH |
---|
100 | (let ((a 0.02) |
---|
101 | (b 0.2) |
---|
102 | (c -50.0) |
---|
103 | (d 2.0)) |
---|
104 | (Izhikevich03:construct |
---|
105 | ;; t V U k1 k2 k3 theta a b c d Isyn |
---|
106 | t V (* b V) k1 k2 k3 theta a b c d Isyn))) |
---|
107 | |
---|
108 | |
---|
109 | ;; Fast-spiking (FS) parameters |
---|
110 | (define FS |
---|
111 | (let ((a 0.1) |
---|
112 | (b 0.2) |
---|
113 | (c -65.0) |
---|
114 | (d 2.0)) |
---|
115 | (Izhikevich03:construct |
---|
116 | ;; t V U k1 k2 k3 theta a b c d Isyn |
---|
117 | t V (* b V) k1 k2 k3 theta a b c d Isyn))) |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | ;; Thalamo-cortical (TC) parameters |
---|
122 | (define TC |
---|
123 | (let ((a 0.02) |
---|
124 | (b 0.25) |
---|
125 | (c -65.0) |
---|
126 | (d 0.05)) |
---|
127 | (Izhikevich03:construct |
---|
128 | ;; t V U k1 k2 k3 theta a b c d Isyn |
---|
129 | t V (* b V) k1 k2 k3 theta a b c d Isyn))) |
---|
130 | |
---|
131 | |
---|
132 | ;; Resonator (RZ) parameters |
---|
133 | (define RZ |
---|
134 | (let ((a 0.1) |
---|
135 | (b 0.26) |
---|
136 | (c -65.0) |
---|
137 | (d 2.0)) |
---|
138 | (Izhikevich03:construct |
---|
139 | ;; t V U k1 k2 k3 theta a b c d Isyn |
---|
140 | t V (* b V) k1 k2 k3 theta a b c d Isyn))) |
---|
141 | |
---|
142 | |
---|
143 | |
---|
144 | ;; Low-threshold spiking (LTS) parameters |
---|
145 | (define LTS |
---|
146 | (let ((a 0.02) |
---|
147 | (b 0.25) |
---|
148 | (c -65.0) |
---|
149 | (d 2.0)) |
---|
150 | (Izhikevich03:construct |
---|
151 | ;; t V U k1 k2 k3 theta a b c d Isyn |
---|
152 | t V (* b V) k1 k2 k3 theta a b c d Isyn))) |
---|
153 | |
---|
154 | |
---|
155 | (define models `((RS . ,RS))) ; (IB . ,IB) (CH . ,CH) (FS . ,FS) (RZ . ,RZ) (LTS . ,LTS) )) |
---|
156 | |
---|
157 | |
---|
158 | (with-output-to-file "Izhikevich03_solver.sml" |
---|
159 | (lambda () |
---|
160 | (let recur ((models models) (pre #t)) |
---|
161 | (if (pair? models) |
---|
162 | (let* ((name.model (car models)) |
---|
163 | (name (car name.model)) |
---|
164 | (model (cdr name.model))) |
---|
165 | (codegen name model language: 'ML solver: 'rkdp random: #f pre: pre post: (null? (cdr models))) |
---|
166 | (recur (cdr models) #f) |
---|
167 | ))) |
---|
168 | )) |
---|
169 | |
---|
170 | (with-output-to-file "Izhikevich03_solver.m" |
---|
171 | (lambda () |
---|
172 | (let recur ((models models) (pre #t)) |
---|
173 | (if (pair? models) |
---|
174 | (let* ((name.model (car models)) |
---|
175 | (name (car name.model)) |
---|
176 | (model (cdr name.model))) |
---|
177 | (codegen name model language: 'octave pre: pre solver: 'lsode) |
---|
178 | (recur (cdr models) #f) |
---|
179 | ))) |
---|
180 | )) |
---|
181 | |
---|
182 | (with-output-to-file "Izhikevich03_solver.scm" |
---|
183 | (lambda () |
---|
184 | (let recur ((models models) (pre #t)) |
---|
185 | (if (pair? models) |
---|
186 | (let* ((name.model (car models)) |
---|
187 | (name (car name.model)) |
---|
188 | (model (cdr name.model))) |
---|
189 | (codegen name model language: 'scheme pre: pre) |
---|
190 | (recur (cdr models) #f) |
---|
191 | ))) |
---|
192 | )) |
---|
193 | |
---|
194 | |
---|
195 | |
---|