nengo.Probe in Basal Ganglia and Action selection model

Hello! I am working on a Basal Ganglia and Action Selection model using nengo_spa. I tried to use nengo.probe for strD1 neuron group 1 and plot the spikes in that neuron group via a raster plot. However, it does not plot it and gives an error saying: “KeyError: <Probe at 0x7fc5167beb10 of ‘output’ of <Neurons of <Ensemble ‘Striatal D1 neurons_1’>>>”. Could you help me understand why this happens?

You can see the code for this part (creating the probe for strD1 neurons and plotting it) down below.

p_utility_spikes = nengo.Probe(action_sel.bg.strD1.all_ensembles[1].neurons)

plt.subplot(6, 1, 2)                                                            
plot_spikes(sim.trange(), sim.data[p_utility_spikes])    
plt.xlabel("Time [s]")
plt.ylabel("Neuron number")

Hi @cansukucuksozen,

I would need to see the rest of the code (or, if you could replicate the issue in a minimal working example) to know exactly what is causing this issue. The following code, for example, shows how to probe the spikes from the strD1 population of the basal ganglia network:

import matplotlib.pyplot as plt
import nengo
import nengo_spa as spa
from nengo.utils.matplotlib import rasterplot

seed = 0


def start(t):
    if t < 0.1:
        return "0.8*START+D"
    else:
        return "0"


# Number of dimensions for the Semantic Pointers
dimensions = 16

# Make a model object with the SPA network
model = spa.Network(label="Routed_Sequence", seed=seed)

with model:
    # Specify the modules to be used
    vision = spa.Transcode(start, output_vocab=dimensions)
    cortex = spa.State(dimensions)

    # Specify the action mapping
    with spa.ActionSelection() as action_sel:
        spa.ifmax("Start", spa.dot(vision, spa.sym.START), vision >> cortex)
        spa.ifmax("A to B", spa.dot(cortex, spa.sym.A), spa.sym.B >> cortex)
        spa.ifmax("B to C", spa.dot(cortex, spa.sym.B), spa.sym.C >> cortex)
        spa.ifmax("C to D", spa.dot(cortex, spa.sym.C), spa.sym.D >> cortex)
        spa.ifmax("D to E", spa.dot(cortex, spa.sym.D), spa.sym.E >> cortex)
        spa.ifmax("E to A", spa.dot(cortex, spa.sym.E), spa.sym.A >> cortex)

    p_bg0 = nengo.Probe(action_sel.bg.strD1.all_ensembles[0].neurons)
    p_bg1 = nengo.Probe(action_sel.bg.strD1.all_ensembles[1].neurons)
    p_bg2 = nengo.Probe(action_sel.bg.strD1.all_ensembles[2].neurons)
    p_bg3 = nengo.Probe(action_sel.bg.strD1.all_ensembles[3].neurons)

with nengo.Simulator(model) as sim:
    sim.run(0.5)

vocab = model.vocabs[dimensions]

plt.figure()
plt.subplot(411)
rasterplot(sim.trange(), sim.data[p_bg0])
plt.subplot(412)
rasterplot(sim.trange(), sim.data[p_bg1])
plt.subplot(413)
rasterplot(sim.trange(), sim.data[p_bg2])
plt.subplot(414)
rasterplot(sim.trange(), sim.data[p_bg3])
plt.tight_layout()
plt.show()

And this is the result of the plotting code:

If I were to hazard a guess though, I think you may have forgotten to run the simulation before attempting to plot the spike rasters? Or, you may not have defined the probe within the with model context? Seeing your actual code would help figure this out. :grinning: