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([1].neurons)

plt.subplot(6, 1, 2)                                                            
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"
        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.sym.START), vision >> cortex)
        spa.ifmax("A to B",, spa.sym.A), spa.sym.B >> cortex)
        spa.ifmax("B to C",, spa.sym.B), spa.sym.C >> cortex)
        spa.ifmax("C to D",, spa.sym.C), spa.sym.D >> cortex)
        spa.ifmax("D to E",, spa.sym.D), spa.sym.E >> cortex)
        spa.ifmax("E to A",, spa.sym.E), spa.sym.A >> cortex)

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

with nengo.Simulator(model) as sim:

vocab = model.vocabs[dimensions]


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: