In [ ]:
import nengo
from nengo.objects import Uniform
model = nengo.Network(label='A Single Neuron')
with model:
neuron = nengo.Ensemble(nengo.LIF(1),
dimensions=1, # Represent a scalar
intercepts=Uniform(-.5, -.5), # Set intercept to 0.5
max_rates=Uniform(100, 100), # Set the maximum firing rate of the neuron to 100hz
encoders=[[1]]) # Sets the neurons firing rate to increase for positive input
In [ ]:
import numpy as np
with model:
cos = nengo.Node(lambda t: np.cos(8 * t))
In [ ]:
with model:
# Connect the input signal to the neuron
nengo.Connection(cos, neuron)
In [ ]:
with model:
cos_probe = nengo.Probe(cos, 'output') # The original input
spikes = nengo.Probe(neuron, 'spikes') # The raw spikes from the neuron
# voltages = nengo.Probe(neuron, 'voltages') # Subthreshold soma voltage of the neuron # TODO
filtered = nengo.Probe(neuron, 'decoded_output', synapse=0.01) # Spikes filtered by a 10ms post-synaptic filter
In [ ]:
sim = nengo.Simulator(model) # Create the simulator
sim.run(1) # Run it for 1 seconds
In [ ]:
import matplotlib.pyplot as plt
# Plot the decoded output of the ensemble
plt.plot(sim.trange(), sim.data[filtered])
plt.plot(sim.trange(), sim.data[cos_probe])
plt.xlim(0, 1)
# Plot the spiking output of the ensemble
from nengo.utils.matplotlib import rasterplot
plt.figure(figsize=(10, 8))
plt.subplot(221)
rasterplot(sim.trange(), sim.data[spikes])
plt.ylabel("Neuron")
plt.xlim(0, 1)
# Plot the soma voltages of the neurons
#plt.subplot(222)
#plt.plot(t, sim.data['Neuron.voltages'][:,0], 'r')
#plt.xlim(0, 1)
The top graph shows that the input signal in green and the filtered output spikes from the single neuron population in blue. The spikes (that are filtered) from the neuron are shown in the bottom graph on the left. On the right is the subthreshold voltages for the neuron.