# Enforce single neuron spiking constraint

**URL:** <https://brian.discourse.group/t/enforce-single-neuron-spiking-constraint/1207>\
**Category:** Science, Projects, and Showcases\
**Tags:** synapses, equations\
**Created:** [3 May 2024 10:41 UTC](https://brian.discourse.group/t/enforce-single-neuron-spiking-constraint/1207 "2024-05-03T10:41:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elnaz91](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/elnaz91/32/703_2.png) [@elnaz91](https://brian.discourse.group/u/elnaz91)\
**Post date:** [3 May 2024 10:41 UTC](https://brian.discourse.group/t/enforce-single-neuron-spiking-constraint/1207/1 "2024-05-03T10:41:50Z")

</div>

Is there a way to enforce a constraint in Brian2 such that only one neuron can spike at each time point within a population?

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [3 May 2024 15:19 UTC](https://brian.discourse.group/t/enforce-single-neuron-spiking-constraint/1207/2 "2024-05-03T15:19:08Z")

</div>

Hi @elnaz91, this is indeed possible, but not very “natural” in Brian. The easiest way to implement it is via a [`@network_operation`](https://brian2.readthedocs.io/en/stable/user/input.html#arbitrary-python-code-network-operations) that runs before the threshold and only gives a single neuron the “right” to fire. What this looks like depends on the details of what you have in mind, but this thread has one possible implementation that lets only the neuron with the highest membrane potential spike: [Winner Take All mechanism using lateral inhibition - #6 by mstimberg](https://brian.discourse.group/t/winner-take-all-mechanism-using-lateral-inhibition/609/6)

Alternatively, this could for example select one of the neurons randomly. Hope that gets you going!

---

<div class="post-metadata">

**Author:** ![elnaz91](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/elnaz91/32/703_2.png) [@elnaz91](https://brian.discourse.group/u/elnaz91)\
**Post date:** [3 May 2024 23:22 UTC](https://brian.discourse.group/t/enforce-single-neuron-spiking-constraint/1207/3 "2024-05-03T23:22:10Z")

</div>

Thank you so much, @mstimberg. The network\_operation command works perfectly fine for me.
