SpiNNakerManchester / sPyNNaker8

The PyNN 0.8 interface to sPyNNaker.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting population v after a run gives InvalidParameterType exception

ej159 opened this issue · comments

commented

I'm trying to set the voltage of population to a value after a run. It is suggested that this should work on the SpiNNaker Users Group. I receive the following exceptions:

spynnaker.pyNN.exceptions.InvalidParameterType: Population IF_curr_exp does not have parameter v

It then tries to do an intialize() instead but falls over there with this exception:

Exception: initialize can only be called before the first call to run, or before the first call to run after a reset

Here is an example script:

import pyNN.spiNNaker as sim

sim.setup()

pop = sim.Population(1, sim.IF_curr_exp)

sim.run(2)
pop.set(v=0.0)

sim.run(2)

This shouldn't work with standard PyNN functions, so I think the advice in that message on the users group is somewhat out of date. The argument from the PyNN side as I understand it is that if you want to change the voltage mid-run then you should by definition have to call reset() as well. Is there a reason why you can't call reset() at this point? (Also: the voltage is not a parameter, it's a state variable, so you shouldn't really be calling set(v=..) in the first place).

[I can say that we do also have a non-standard PyNN function pop.set_initial_value(...) which I think is intended to do what you're requesting, but it doesn't work properly for me at the moment; I can work on fixing this if you need it for what you're doing.]

commented

I am using a variable rate Poisson spike source. The way I understand this is that I if I were to call reset() it would reset the simulation time and so begin the simulation from t=0, resetting the VRPSS too. I could reset() and then supply new parameters to the Poisson source. The reason that I didn't do this initially was because reset() was unreliable (I believe this has been improved). I imagine that setting v=0 after each run would be quicker than uploading the rate variables after each run but probably not by much?

You're correct that reset() has recently been improved so it should work better. I think you're right in terms of setting v=0 being quicker as well but as you say I don't think it would make that much difference. Certainly as long as the change of the rate variables doesn't affect the graph, it shouldn't make that much difference.

If you use the fix in #332 and SpiNNakerManchester/sPyNNaker#765 then you should now be able to do pop.set_initial_value(variable="v", value=0) in your example script.

commented

I have just found out this problem still exists. When running the example below, the voltage does not get reset to -65.0mV at 50ms as expected (see the output graph). If I try and use Population.set() I get the same InvalidParameterType and initialize can only be called before the first call to run exceptions as I saw before. Is it possible to make set()s between runs work?

import spynnaker8 as p
from pyNN.utility.plotting import Figure, Panel
import matplotlib.pyplot as plt

p.setup(time_scale_factor=1, timestep=1)

pop1 = p.Population(1, p.SpikeSourceArray([10, 100]))
pop2 = p.Population(1, p.IF_curr_exp())

p.Projection(pop1, pop2, p.AllToAllConnector(), p.StaticSynapse(weight=1.0, delay=1.0))

pop2[0].record(['v'])

p.run(50)
pop2.set_initial_value(variable="v", value=-65) #The line in question that falls over with pop2.set(variable="v", value=-65.0))
p.run(200)

v = pop2.get_data('v')

p.end()

Figure(
    # membrane potential of the postsynaptic neuron
    Panel(v.segments[0].filter(name='v')[0],
          ylabel="Membrane potential (mV)",
          data_labels=[pop2.label], yticks=True, xlim=(0, 250), xticks=True),
    annotations="Simulated with {}".format(p.name())
)

plt.show()``` 

Confirming this is an issue - fix on the way.