Skip to content

Handling of SpikeSourceArrays with pyNN.nest and min_delay='auto' #536

@philipsgithub

Description

@philipsgithub

Hello,

my setup: PYNN 0.9.1, NEST 2.12.0.

The following example code shows how the use of min_delay='auto' together with the creation of SpikeSourceArray-Populations can cause wrong simulation results.

I assume after a debugging session that the reason is the following:

  1. sim.setup() is called with the default settings: min_delay='auto', in nest this causes min_delay=max_delay=sim_step
  2. When creating a SpikeSourceArray-Population the actual min_delay is used to adjust the spike_times-Sequence (substract min_delay) for the later use with parrot neurons.
  3. When connecting the population to another population (Projection) the synapse delay will be used to set the new value of min_delay. The min_delay is considered as set now. (Caution: It might be reduced if other connections have lower synapse delays!!)
  4. When sim.run() is called the parrot neurons belonging to the SpikeSourceArrays are connected to the source neurons of the SpikeSourceArrays with a synapse delay that equals the actual min_delay at this exact moment. That min_delay is not the same that was taken into account when creating the source-neurons of the SpikeSourceArray-Population. So the sum of both delays (source->parrot->***) will not be as desired by the user.
import pyNN.nest as sim

sim.setup(timestep=0.2, spike_precision="on_grid")

p_in = sim.Population(1, sim.SpikeSourceArray(spike_times=[3.]))
p_out= sim.Population(1, sim.IF_curr_exp())

con = sim.AllToAllConnector()
syn1 = sim.StaticSynapse(delay=2., weight=7.)
syn2 = sim.StaticSynapse(delay=1., weight=7.)

print("MinDelay before Projection:   ", sim.get_min_delay())
prj = sim.Projection(p_in, p_out, con, syn1)
print("MinDelay after Projection 1:  ", sim.get_min_delay())

p_in2 = sim.Population(1, sim.SpikeSourceArray(spike_times=[3.]))
prj2 = sim.Projection(p_in2, p_out, con, syn2)
print("MinDelay after Projection 2:  ", sim.get_min_delay())

p_in.record('spikes')
p_in2.record('spikes')

# Note: In run() the SourceNeurons of the SpikeSourceArray
# are connected to the ParrotNeurons of the SpikeSourceArray
# using the current min_delay as a synapse delay.
sim.run(20)

data_in = p_in.get_data()
data_in2 = p_in2.get_data()

print("In-Spikes at (should be 3.):  ", data_in.segments[0].spiketrains[0].as_array().tolist())
print("In2-Spikes at (should be 3.): ", data_in2.segments[0].spiketrains[0].as_array().tolist())
print("MinDelay: ", sim.get_min_delay())
print("MaxDelay: ", sim.get_max_delay())

Produces following output:

('MinDelay before Projection:   ', 0.2)
('MinDelay after Projection 1:  ', 2.0)
('MinDelay after Projection 2:  ', 1.0)
('In-Spikes at (should be 3.):  ', [3.8000000000000003])
('In2-Spikes at (should be 3.): ', [2.0])
('MinDelay: ', 1.0)
('MaxDelay: ', 2.0)

Relevant settings:
-Timestep is 0.2ms
-SpikeTime of the SpikeSourceArrays is 3ms
-Delay of StaticSynapse is 2ms and 1ms

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions