1# encoding: utf-8
2"""
3Standard base_cells for the neuron module.
4
5:copyright: Copyright 2006-2021 by the PyNN team, see AUTHORS.
6:license: CeCILL, see LICENSE for details.
7
8"""
9
10from pyNN.standardmodels import cells as base_cells, build_translations
11from pyNN.neuron.cells import (StandardIF, SingleCompartmentTraub,
12                               RandomSpikeSource, VectorSpikeSource,
13                               RandomGammaSpikeSource,
14                               RandomPoissonRefractorySpikeSource,
15                               BretteGerstnerIF, GsfaGrrIF, Izhikevich_,
16                               GIFNeuron)
17import logging
18
19logger = logging.getLogger("PyNN")
20
21
22class IF_curr_alpha(base_cells.IF_curr_alpha):
23
24    __doc__ = base_cells.IF_curr_alpha.__doc__
25
26    translations = build_translations(
27        ('tau_m',      'tau_m'),
28        ('cm',         'c_m'),
29        ('v_rest',     'v_rest'),
30        ('v_thresh',   'v_thresh'),
31        ('v_reset',    'v_reset'),
32        ('tau_refrac', 't_refrac'),
33        ('i_offset',   'i_offset'),
34        ('tau_syn_E',  'tau_e'),
35        ('tau_syn_I',  'tau_i'),
36    )
37    model = StandardIF
38    extra_parameters = {'syn_type': 'current',
39                        'syn_shape': 'alpha'}
40
41
42class IF_curr_exp(base_cells.IF_curr_exp):
43
44    __doc__ = base_cells.IF_curr_exp.__doc__
45
46    translations = build_translations(
47        ('tau_m',      'tau_m'),
48        ('cm',         'c_m'),
49        ('v_rest',     'v_rest'),
50        ('v_thresh',   'v_thresh'),
51        ('v_reset',    'v_reset'),
52        ('tau_refrac', 't_refrac'),
53        ('i_offset',   'i_offset'),
54        ('tau_syn_E',  'tau_e'),
55        ('tau_syn_I',  'tau_i'),
56    )
57    model = StandardIF
58    extra_parameters = {'syn_type': 'current',
59                        'syn_shape': 'exp'}
60
61
62class IF_cond_alpha(base_cells.IF_cond_alpha):
63
64    __doc__ = base_cells.IF_cond_alpha.__doc__
65
66    translations = build_translations(
67        ('tau_m',      'tau_m'),
68        ('cm',         'c_m'),
69        ('v_rest',     'v_rest'),
70        ('v_thresh',   'v_thresh'),
71        ('v_reset',    'v_reset'),
72        ('tau_refrac', 't_refrac'),
73        ('i_offset',   'i_offset'),
74        ('tau_syn_E',  'tau_e'),
75        ('tau_syn_I',  'tau_i'),
76        ('e_rev_E',    'e_e'),
77        ('e_rev_I',    'e_i')
78    )
79    model = StandardIF
80    extra_parameters = {'syn_type': 'conductance',
81                        'syn_shape': 'alpha'}
82
83
84class IF_cond_exp(base_cells.IF_cond_exp):
85
86    __doc__ = base_cells.IF_cond_exp.__doc__
87
88    translations = build_translations(
89        ('tau_m',      'tau_m'),
90        ('cm',         'c_m'),
91        ('v_rest',     'v_rest'),
92        ('v_thresh',   'v_thresh'),
93        ('v_reset',    'v_reset'),
94        ('tau_refrac', 't_refrac'),
95        ('i_offset',   'i_offset'),
96        ('tau_syn_E',  'tau_e'),
97        ('tau_syn_I',  'tau_i'),
98        ('e_rev_E',    'e_e'),
99        ('e_rev_I',    'e_i')
100    )
101    model = StandardIF
102    extra_parameters = {'syn_type': 'conductance',
103                        'syn_shape': 'exp'}
104
105
106class IF_facets_hardware1(base_cells.IF_facets_hardware1):
107
108    __doc__ = base_cells.IF_facets_hardware1.__doc__
109
110    translations = build_translations(
111        ('v_rest',     'v_rest'),
112        ('v_thresh',   'v_thresh'),
113        ('v_reset',    'v_reset'),
114        ('g_leak',     'tau_m',    "0.2*1000.0/g_leak", "0.2*1000.0/tau_m"),
115        ('tau_syn_E',  'tau_e'),
116        ('tau_syn_I',  'tau_i'),
117        ('e_rev_I',    'e_i')
118    )
119    model = StandardIF
120    extra_parameters = {'syn_type':  'conductance',
121                        'syn_shape': 'exp',
122                        'i_offset':  0.0,
123                        'c_m':       0.2,
124                        't_refrac':  1.0,
125                        'e_e':       0.0}
126
127
128class HH_cond_exp(base_cells.HH_cond_exp):
129
130    __doc__ = base_cells.HH_cond_exp.__doc__
131
132    translations = build_translations(
133        ('gbar_Na',    'gbar_Na',   1e-3),   # uS -> mS
134        ('gbar_K',     'gbar_K',    1e-3),
135        ('g_leak',     'g_leak',    1e-3),
136        ('cm',         'c_m'),
137        ('v_offset',   'v_offset'),
138        ('e_rev_Na',   'ena'),
139        ('e_rev_K',    'ek'),
140        ('e_rev_leak', 'e_leak'),
141        ('e_rev_E',    'e_e'),
142        ('e_rev_I',    'e_i'),
143        ('tau_syn_E',  'tau_e'),
144        ('tau_syn_I',  'tau_i'),
145        ('i_offset',   'i_offset'),
146    )
147    model = SingleCompartmentTraub
148    extra_parameters = {'syn_type': 'conductance',
149                        'syn_shape': 'exp'}
150
151
152class IF_cond_exp_gsfa_grr(base_cells.IF_cond_exp_gsfa_grr):
153
154    __doc__ = base_cells.IF_cond_exp_gsfa_grr.__doc__
155
156    translations = build_translations(
157        ('v_rest',     'v_rest'),
158        ('v_reset',    'v_reset'),
159        ('cm',         'c_m'),
160        ('tau_m',      'tau_m'),
161        ('tau_refrac', 't_refrac'),
162        ('tau_syn_E',  'tau_e'),
163        ('tau_syn_I',  'tau_i'),
164        ('v_thresh',   'v_thresh'),
165        ('i_offset',   'i_offset'),
166        ('e_rev_E',    'e_e'),
167        ('e_rev_I',    'e_i'),
168        ('tau_sfa',    'tau_sfa'),
169        ('e_rev_sfa',  'e_sfa'),
170        ('q_sfa',      'q_sfa'),
171        ('tau_rr',     'tau_rr'),
172        ('e_rev_rr',   'e_rr'),
173        ('q_rr',       'q_rr')
174    )
175    model = GsfaGrrIF
176    extra_parameters = {'syn_type': 'conductance',
177                        'syn_shape': 'exp'}
178
179
180class SpikeSourcePoisson(base_cells.SpikeSourcePoisson):
181
182    __doc__ = base_cells.SpikeSourcePoisson.__doc__
183
184    translations = build_translations(
185        ('start',    'start'),
186        ('rate',     '_interval',  "1000.0/rate",  "1000.0/_interval"),
187        ('duration', 'duration'),
188    )
189    model = RandomSpikeSource
190
191
192class SpikeSourcePoissonRefractory(base_cells.SpikeSourcePoissonRefractory):
193
194    __doc__ = base_cells.SpikeSourcePoissonRefractory.__doc__
195
196    translations = build_translations(
197        ('start',      'start'),
198        ('rate',       'rate'),
199        ('tau_refrac', 'tau_refrac'),
200        ('duration',   'duration'),
201    )
202    model = RandomPoissonRefractorySpikeSource
203
204
205class SpikeSourceGamma(base_cells.SpikeSourceGamma):
206    __doc__ = base_cells.SpikeSourceGamma.__doc__
207
208    translations = build_translations(
209        ('alpha',    'alpha'),
210        ('beta',     'beta',    0.001),
211        ('start',    'start'),
212        ('duration', 'duration'),
213    )
214    model = RandomGammaSpikeSource
215
216
217class SpikeSourceArray(base_cells.SpikeSourceArray):
218
219    __doc__ = base_cells.SpikeSourceArray.__doc__
220
221    translations = build_translations(
222        ('spike_times', 'spike_times'),
223    )
224    model = VectorSpikeSource
225
226
227class EIF_cond_alpha_isfa_ista(base_cells.EIF_cond_alpha_isfa_ista):
228
229    __doc__ = base_cells.EIF_cond_alpha_isfa_ista.__doc__
230
231    translations = build_translations(
232        ('cm',         'c_m'),
233        ('tau_refrac', 't_refrac'),
234        ('v_spike',    'v_spike'),
235        ('v_reset',    'v_reset'),
236        ('v_rest',     'v_rest'),
237        ('tau_m',      'tau_m'),
238        ('i_offset',   'i_offset'),
239        ('a',          'A',        0.001),  # nS --> uS
240        ('b',          'B'),
241        ('delta_T',    'delta'),
242        ('tau_w',      'tau_w'),
243        ('v_thresh',   'v_thresh'),
244        ('e_rev_E',    'e_e'),
245        ('tau_syn_E',  'tau_e'),
246        ('e_rev_I',    'e_i'),
247        ('tau_syn_I',  'tau_i'),
248    )
249    model = BretteGerstnerIF
250    extra_parameters = {'syn_type': 'conductance',
251                        'syn_shape': 'alpha'}
252
253
254class EIF_cond_exp_isfa_ista(base_cells.EIF_cond_exp_isfa_ista):
255
256    __doc__ = base_cells.EIF_cond_exp_isfa_ista.__doc__
257
258    translations = EIF_cond_alpha_isfa_ista.translations
259    model = BretteGerstnerIF
260    extra_parameters = {'syn_type': 'conductance',
261                        'syn_shape': 'exp'}
262
263
264class Izhikevich(base_cells.Izhikevich):
265    __doc__ = base_cells.Izhikevich.__doc__
266
267    translations = build_translations(
268        ('a',        'a_'),
269        ('b',        'b'),
270        ('c',        'c'),
271        ('d',        'd'),
272        ('i_offset', 'i_offset')
273    )
274    model = Izhikevich_
275
276
277class GIF_cond_exp(base_cells.GIF_cond_exp):
278    translations = build_translations(
279        ('v_rest', 'v_rest'),
280        ('cm', 'c_m'),
281        ('tau_m', 'tau_m'),
282        ('tau_refrac', 't_refrac'),
283        ('tau_syn_E', 'tau_e'),
284        ('tau_syn_I', 'tau_i'),
285        ('e_rev_E', 'e_e'),
286        ('e_rev_I', 'e_i'),
287        ('v_reset', 'v_reset'),
288        ('i_offset', 'i_offset'),
289        ('delta_v', 'dV'),
290        ('v_t_star', 'vt_star'),
291        ('lambda0', 'lambda0'),
292        ('tau_eta', 'tau_eta'),
293        ('tau_gamma', 'tau_gamma'),
294        ('a_eta', 'a_eta'),
295        ('a_gamma', 'a_gamma'),
296    )
297    model = GIFNeuron
298    extra_parameters = {'syn_type': 'conductance',
299                        'syn_shape': 'exp'}
300