@@ -147,10 +147,65 @@ the same time:
147147
148148.. todo:: in the above, give current source examples, and Projection examples
149149
150- Time series parameters
151- ======================
150+ Time series and array-valued parameters
151+ =======================================
152+
153+ For certain neuron models (:class:`SpikeSourceArray`, :class:`GIF_cond_exp`)
154+ and current sources, the individual parameter values are not single numbers
155+ (with physical units), but arrays, e.g.:
156+
157+ .. code-block:: python
158+
159+ celltype = SpikeSourceArray(np.array([5.0, 15.0, 45.0, 99.0]))
160+
161+ to set the same spike times for the entire population.
162+ To set different spike times for each cell in the population requires an array of arrays.
163+ To avoid ambiguities in this situation, the inner arrays should be wrapped by the
164+ :class:`Sequence` class, e.g.:
165+
166+ .. code-block:: python
167+
168+ celltype = SpikeSourceArray([Sequence([5.0, 15.0, 45.0, 99.0]),
169+ Sequence([2.0, 5.3, 18.9]),
170+ Sequence([17.8, 88.2, 100.1])
171+ ])
172+
173+ Such an array-of-Sequences can also be provided by a generator function, e.g.:
174+
175+ .. code-block:: python
176+
177+ number = int(2 * simtime * input_rate / 1000.0)
178+
179+ def generate_spike_times(i):
180+ gen = lambda: Sequence(numpy.add.accumulate(numpy.random.exponential(1000.0 / input_rate, size=number)))
181+ if hasattr(i, "__len__"):
182+ return [gen() for j in i]
183+ else:
184+ return gen()
185+
186+ celltype = SpikeSourceArray(spike_times=generate_spike_times)
187+
188+
189+ As a generalization of :class:`Sequence`, some models require array-valued parameters,
190+ expressed as tuples or :class:`ArrayParameter` instances, e.g.:
191+
192+ .. code-block:: python
193+
194+ cell_type = GIF_cond_exp(
195+ ...
196+ # this parameter has the same value in all neurons in the population
197+ tau_gamma=(1.0, 10.0, 100.0), # Time constants for spike-frequency adaptation in ms.
198+ # the following parameter has different values for each neuron
199+ a_eta=[(0.1, 0.1, 0.1), # Post-spike increments for spike-triggered current in nA
200+ (0.0, 0.0, 0.0),
201+ (0.0, 0.0, 0.0),
202+ (0.0, 0.0, 0.0)]
203+ ...)
152204
153- .. todo:: discuss spike trains, current sources, Sequence class
205+ .. note:: The reason for defining :class:`Sequence` and :class:`ArrayParameter`
206+ rather than just using a plain NumPy array is to avoid the ambiguity of
207+ "is a given array a single parameter value (e.g. a spike train for one cell)
208+ or an array of parameter values (e.g. one number per cell)?".
154209
155210
156211Setting initial values
0 commit comments