Our model consists of two ensembles (called A and B) that receive inputs from a common sine wave signal generator.
Ensemble A is gated using the output of a node, while Ensemble B is gated using the output of a third ensemble (C). This is to demonstrate that ensembles can be gated using either node outputs, or decoded outputs from ensembles.
In [ ]:
    
import nengo
model = nengo.Network(label="Inhibitory Gating")
n_neurons = 30
with model:
    A = nengo.Ensemble(nengo.LIF(n_neurons), dimensions=1)
    B = nengo.Ensemble(nengo.LIF(n_neurons), dimensions=1)
    C = nengo.Ensemble(nengo.LIF(n_neurons), dimensions=1)
    
In [ ]:
    
import numpy as np
from nengo.utils.functions import piecewise
with model:
    sin = nengo.Node(output=np.sin)
    inhib = nengo.Node(output=piecewise({0: 0, 2.5: 1, 5: 0, 7.5: 1, 10: 0, 12.5: 1}))
    
In this model, we need to make the following connections:
In [ ]:
    
with model:
    nengo.Connection(sin, A)
    nengo.Connection(sin, B)
    nengo.Connection(inhib, A.neurons, transform=[[-2.5]] * n_neurons)
    nengo.Connection(inhib, C)
    nengo.Connection(C, B.neurons, transform=[[-2.5]] * n_neurons)
    
In [ ]:
    
with model:
    sin_probe = nengo.Probe(sin, 'output')
    inhib_probe = nengo.Probe(inhib, 'output')
    A_probe = nengo.Probe(A, 'decoded_output', synapse=0.01)
    B_probe = nengo.Probe(B, 'decoded_output', synapse=0.01)
    C_probe = nengo.Probe(C, 'decoded_output', synapse=0.01)
    
In [ ]:
    
# Create our simulator
sim = nengo.Simulator(model)
# Run it for 15 seconds
sim.run(15)
    
In [ ]:
    
import matplotlib.pyplot as plt
# Plot the decoded output of Ensemble A
plt.plot(sim.trange(), sim.data[A_probe], label='Decoded output')
plt.plot(sim.trange(), sim.data[sin_probe], label='Sine input')
plt.plot(sim.trange(), sim.data[inhib_probe], label='Inhibitory signal')
plt.legend()
    
In [ ]:
    
# Plot the decoded output of Ensemble B and C
plt.plot(sim.trange(), sim.data[B_probe], label='Decoded output of B')
plt.plot(sim.trange(), sim.data[sin_probe], label='Sine input')
plt.plot(sim.trange(), sim.data[C_probe], label='Decoded output of C')
plt.plot(sim.trange(), sim.data[inhib_probe], label='Inhibitory signal')
plt.legend()