‘Average spike activity’ is a little more nuanced so I’ll add the caveat that this is how you get the average activity given your input.
When you probe
ens.neurons and read the data after running the simulation you will get an array of shape
(n_steps, n_neurons). Since the neurons will react differently to different inputs, this array will give the activity given the specific input signal passed in during the simulation.
What Kris wrote above gives you the total number of spikes for each neuron because you are summing across the time dimension where the activity is greater than zero.
To get the average number of steps of activity, given the current input, you need to divide by the total number of steps, which is determined by how long you run your sim for and what you set
dt on your
For example, if you set up your simulation as:
You will run the simulation for 500 steps
(1 sec / 0.002 sec). More simply, you can get the total number of steps from