I have a population of more than one SpikeSourceArray and am running into some difficulties setting the spike times.
The following code:
import pyNN.spiNNaker as p
p.setup(timestep=1.0)
post_input = p.Population(2, p.SpikeSourceArray([[], []]))
yields
IndexError: list index out of range
If one of the lists is nonempty, this seems to work OK.
Furthermore, setting a list of spike times on these SpikeSourceArrays after they have been constructed seems not to work. The following script simulates n_post_neurons spike generators connected one-to-one to n_post_neurons neurons. The one spike at t=225 should yield a strong postsynaptic response and more than one spike being recorded. However, in actuality, it yields 0 recorded spikes.
import pyNN.spiNNaker as p
n_post_neurons = 2
post_spike_times = [[225], []]
assert len(post_spike_times) == n_post_neurons
p.setup(timestep=1.0)
exc_input = "excitatory"
post_input = p.Population(n_post_neurons, p.SpikeSourceArray(), label="post_input") # do not set spike times here
post_spiking = p.Population(n_post_neurons, p.IF_curr_exp(), label="post_spiking")
weight_post = 3000
p.Projection(post_input, post_spiking, p.OneToOneConnector(), receptor_type=exc_input, synapse_type=p.StaticSynapse(weight=weight_post))
post_spiking.record(["spikes"])
# ... but set spike times here
for idx_post in range(n_post_neurons):
print("For idx " + str(idx_post) + " setting spike times to " + str(post_spike_times[idx_post]))
post_input[idx_post].set(spike_times=post_spike_times[idx_post])
p.run(1000)
post_neo = post_spiking.get_data("spikes")
actual_post_spike_times = post_neo.segments[0].spiketrains
print("Number of actual post spikes, neuron 0: " + str(len(actual_post_spike_times[0])))
print("Number of actual post spikes, neuron 1: " + str(len(actual_post_spike_times[1])))
p.end()
even though the spike times seem to be set correctly when inspecting the values directly:
In [124]: post_input[0].spike_times
Out[124]: [225]
In [125]: post_input[1].spike_times
Out[125]: []
If, instead, I pass the spike times in the constructor as follows:
post_input = p.Population(n_post_neurons, p.SpikeSourceArray(post_spike_times), label="post_input")
everything seems to work as expected and 15 spikes are recorded from neuron 0.
I have a population of more than one SpikeSourceArray and am running into some difficulties setting the spike times.
The following code:
yields
If one of the lists is nonempty, this seems to work OK.
Furthermore, setting a list of spike times on these SpikeSourceArrays after they have been constructed seems not to work. The following script simulates
n_post_neuronsspike generators connected one-to-one ton_post_neuronsneurons. The one spike at t=225 should yield a strong postsynaptic response and more than one spike being recorded. However, in actuality, it yields 0 recorded spikes.even though the spike times seem to be set correctly when inspecting the values directly:
If, instead, I pass the spike times in the constructor as follows:
everything seems to work as expected and 15 spikes are recorded from neuron 0.