Description of problem
Hello Community, I am trying to plot the spiking activity of each neuron in a neuron group using SpikeMonitor. My question is how to plot the activity of each neuron in a single manner among the rest of the neurons using SpikeMonitor. For example:
G = NeuronGroup (20, .....)
spikemon = SpikeMonitor(G)
I would like to plot the activity of neuron with index = 0 (G[0]
) solely without including the activity of the rest of the neurons.
Hi @Haydar. There are two ways to do this. Either you filter the spike trains manually like this:
spikes_for_0 = spikemon.t[spikemon.i == 0]
(spikes_for_0
now contains the spike times for neuron 0)
or you use the spike_trains
method which gives you a dictionary of spike times:
spike_trains = spike_mon.spike_trains()
You can then use spike_trains[0]
to get the spike times for neuron 0.
The second approach is more efficient if you want to look at the spike times separately for many neurons, since it only has to filter the list of spikes once. For smaller networks/number of spikes, this won’t make any noticeable difference, though.
it works, thanks a million !
1 Like