Given an initialized nengo.Lowpass()
object, how do I apply it to an input stream at each time-step? I assumed I was supposed to call the make_step
method of the object and use the function it returned, but it doesn’t seem to be filtering at all… Am I using the function incorrectly?
import nengo
import numpy as np
import matplotlib.pyplot as plt
# make some spikes
n_neurons = 10
with nengo.Network() as model:
sin = nengo.Node(lambda t: np.sin(t * 10))
ens = nengo.Ensemble(n_neurons, 1)
nengo.Connection(sin, ens)
p_spikes = nengo.Probe(ens.neurons, synapse=None)
with nengo.Simulator(model) as sim:
sim.run(1.)
spikes = sim.data[p_spikes]
# filter those spikes
lp = nengo.Lowpass(0.01)
lps = lp.make_step(n_neurons, n_neurons, 0.001, None, dtype=np.float64)
res = []
for t_i, sim_t in enumerate(list(sim.trange())):
res.append(lps(sim_t, spikes[t_i]))
res = np.array(res)
plt.plot(res)
plt.show()