Hi everyone, I am a novice. In the process of using nengo, I have a question, how to draw an image of the relationship between time and firing rate? I would be very grateful if you can answer my question.
I’ve made a short script here that shows you how you can plot the firing rates against time, or if the neurons are spiking, how you can make a raster plot showing when spikes occur over time from each of the neurons.
import matplotlib.pyplot as plt import numpy as np import nengo spiking = False if spiking: neuron_type = nengo.LIF() else: neuron_type = nengo.RectifiedLinear() with nengo.Network() as net: input = nengo.Node(np.cos) ens = nengo.Ensemble( n_neurons=10, dimensions=1, neuron_type=neuron_type, ) nengo.Connection(input, ens) probe = nengo.Probe(ens.neurons) with nengo.Simulator(net) as sim: sim.run(3) if spiking: from nengo.utils.matplotlib import rasterplot rasterplot(sim.trange(), sim.data[probe]) plt.ylabel('Neuron #') else: plt.plot(sim.trange(), sim.data[probe]) plt.ylabel('Firing rate (Hz)') plt.xlabel('Time (s)') plt.show()
Does this answer your question?
Thank you very much for answering my question!