Simulator of the nervous system

Hello, I want to share my work on creating a system that allows you to model the reflex and cognitive processes that occur in the nervous system.

The system is embodied in a simple program, created on the game engine Unity3D. It is a kind of simulator of the nervous system, thanks to which it is possible to simulate not only simple reflexes, but also to demonstrate various phenomena in the nervous system, such as habituation, sensitization and the formation of conditioned reflexes. And also it is possible to emulate temporary and long-term memory and its consolidation, emotions and emotional behavior, and as simple emotions, for example, hunger and satiety, and more complex, such as curiosity, fear or affection. I plan to talk about all this in a series of articles. The first three articles are devoted to the basics in which I will talk about the main components of the system — model neurons.

In the system, we can distinguish three basic types of model neurons: a simple adder, a modulated neuron, an associative neuron. Model neurons are divided in complexity, each next neuron has an additional set of properties. This separation allows for a better understanding of the operating principles of the system, and in simpler examples, use simpler neurons.

Simple adder

The simplest neuron in the system is a simple adder. This is an element that can have inputs and outputs. And in the system there are several types of connections, first, these are signals from the receptors, there is a block of receptor-buttons that work in real time. Secondly, model neurons are interconnected through synapses.

Model neuron - Simple adder

Synapses are of three types: synapses of direct action, synapses of modulating action and electrical synapses. All these types of synapses have analogues in the biological nervous system.

Synapses of direct action (1) are characterized by their strength (F), which is represented in the system as a real number. The sign of this number indicates which synapse has an inhibitory or stimulating action.
All signals are processed in real time, and can enter the neuron independently of each other, as occurs in a biological neuron. First of all, the signals of the synapses of direct action enter the adder (2).

The adder as test tube

The adder can be represented as follows, it is similar to a test tube in which all the portions of the mediator are collected. But when the neurotransmitter is allocated to the synaptic cleft in the biological nervous system, its continuous loss occurs. The neurotransmitter in the synaptic cleft is destroyed by a special enzyme, it can be absorbed back by a synapse or go beyond the synaptic cleft. Therefore, in our test tube there is a hole, due to which there is a permanent decrease in the total mass of the neurotransmitter (3). Parameter D (damper) characterizing the rate of decrease of the sum modulus in the adder.

If the total mass of the neurotransmitter exceeds a certain threshold (4), then the neuron is activated, but if the portions of the neurotransmitter turn out to be less than the threshold, then in time its summation level on the adder may fall to zero and no activation of the neuron.

For synapses of direct action, there are two types of neurotransmitters: stimulating and inhibitory. In the system, this is determined by the sign of the strength of the synapse. And the action of synapses different in sign are mutually neutralized. The total amount can be negative, then it will increase to zero at the set speed.

When a neuron is activated, it enters an activity state in which it stops responding to external signals and, through a certain time delay, activates all its outgoing synapses. Further, like a biological neuron, a temporary delay in recovery takes place in the neuron, at which time the neuron does not respond to external stimuli.
Contact synapses (7) activate a neuron if it is not in the active state or in the recovery period. It can be said that the signal, from the contact synapses, activates the neuron, if it is possible at the moment, otherwise ignored.

Let’s look at how the neuroelements work with the example of the simplest reflex: the knee reflex. The knee reflex consists of only three neurons, the receptor neuron receives a signal from the tendon receptors, then passes the signal to the intercalary neuron and then the motor neuron transmits the signal to the extensor muscle.

Knee-jerk reflex

So the reflex looks like in a simulation:

Knee-jerk reflex in simulation

Example with inhibitory action. The model neuron bound to the receptor “E” has an inhibitory effect:

An example of competition of reflexes. Mutual inhibition of two different reflexes:

Transformation of the rhythm of excitation

Single impulses for the nervous system are a rarity. In most cases, the signals from the receptors are a series of pulses, and the intensity of these pulses can be used to indicate the extent of the effect on the receptor. The more often the pulses are reproduced, the stronger the effect on the receptor, the stronger the pressure, if it is the pressure receptor, the higher the temperature, if it is the temperature receptor, etc.

And one of the observed phenomena in the nervous system is the transformation of the rhythm of excitation — a change in the frequency of nerve impulses when passing through the nerve center.

With the help of a model neuron it is possible to increase the frequency of nerve impulses. In the case when the level of a single exposure to a neuron is significantly higher than its activation threshold and the neuron has time to work several times before the value of the adder decreases to a level lower than the threshold.

The decrease in the pulsation frequency of nerve impulses is due to an increase in the resting time of the neuron, as noted earlier, during rest the neuron does not respond to external signals.

An example of converting pulses from rare to more frequent ones. In this case, the level of single exposure to a neuron is significantly higher than its activation threshold and it has time to work several times before the value of the adder decreases to a level lower than the threshold:

An example of a decrease in the pulse frequency. Here it is carried out due to the increase in the rest time of the neuron, as I already noted, during rest the neuron does not respond to external signals:

Spatial and temporal summation

Image source (

The presented model of a neuron is allowed to explain how temporal and spatial summation occurs in a biological neuron. The temporal summation is manifested in the fact that a number of subthreshold pulses from this synapse, if these pulses occur frequently enough, can lead to activation of the neuron. This is due to the fact that the rate of decrease in the amount of impact may be less than the rate of replenishment of this amount.

In biological neurons, there is a phenomenon that indicates that the summation is not only temporal, but also spatial. Even if the sum of the subthreshold signals exceeds a threshold, but these signals are fed to synapses located at a sufficient distance from each other, activation may not occur. Such a phenomenon can be modeled using several neurons, for example, each dendritic neuron may have dendrites.

Modulated neuron

There are three types of reflex activity: habituation, sensitization, and the formation of conditioned reflexes. These types of activities identified academician Ivan Pavlov and if our model does not emulate this, it means that it is not a model of the nervous system, but a model of something else.

Image source: In search of memory — Eric R. Kandel


Habituation is a phenomenon associated with the fact that after a repeated action of an indifferent stimulus, both the animal and the cell cease to react to it. For example, the background sound to which we can get used and after a while almost cease to hear it, or if you wear the ring for a long time, you may not feel its pressure on the skin, etc.

Habituation is implemented in the following way. When the neuron is activated, it enters the state of activity, in which it ceases to react to activating factors, such as a signal, from contact synapses or exceeding the threshold of the total sum on the adder. After a while, the neuron activates all the transmitting synapses it has. After signal transmission, the time passes, which is designated as the recovery time. Then the state of activity is replaced by a state of expectation, in which the neuron can react to activating factors and again enter the state of activity. For a modulated neuron after the activity phase, there is an evaluation time over which it is determined whether the neuron will be activated again.

If re-activation occurs during this period, then repeats are counted. That is, every time the activation occurs during the evaluation, the repeat count is incremented by one, but if the activation does not take place during the evaluation, the counter is reset. This is how the activation counts, if they are committed quite often.

And if the number of repetitions is above a certain limit, then the threshold of the neuron adder increases by a certain value. Thus, the neuron increases its threshold until it stops responding to the level of exposure that activated it.

An example of habituation:


In contrast to habituatio, it is necessary to distinguish the mechanism of adaptation. Adaptation is the ability of the cell to return to the previous level of sensitivity over time. If there is no stimulus for a long time, the force of habituation decreases, and can disappear altogether.

The speed with which the recovery takes place can be different in different cases, and sometimes it can last hours or even days, and in some cases it happens very quickly.

Adaptation example:

The mechanism of habituation can be represented as a defense mechanism, with very frequent activation of the nervous tissue, there is a high probability of its exhaustion, death and damage. Therefore, in order to protect the sensitivity of the neuron decreases, and it rarely begins to respond to stimulation.

On the other hand, if the neuron is not activated, then it will not perform its tasks and therefore, it would be a useless energy consumption. Therefore, there is a mechanism of adaptation, which increases the sensitivity to external stimuli, which increases the probability of activation of the neuron.

Habituation and adaptation solve the problem of cyclic transmission of excitation in the nervous tissue. Often in neural tissue, neurons are combined in such a way that they form neural excitatory transmission loops, but when ring excitation transfers do not endlessly loop, these transmissions also cease with time, due to rapid habituation.


The second type of reflex activity is sensitization. Sensitization is an increase in sensitivity to the effects of irritants, even indifferent, if this was preceded by an important event for the body.

For example, for a dog, a certain sound is an indifferent stimulus, to which it previously did not react. Then, if an unpleasant stimulus comes, for example, an electric shock, the dog will be disturbed for a while, and even an indifferent sound will cause a characteristic behavior, a protective reaction.

In order to simulate sensitization, let us turn to the works of Eric Kandel, the Nobel Prize winner in the field of physiology. He described in detail the effect of modulating synapses on the example of the nervous system of the mollusc Aplysia.

Eric Kandel

The mollusc has a defensive reaction in response to all kinds of touching this drawing of the gills. In his experiments Eric Kandel caused Aplysia to get used to the easy touch of her siphon so that the protective reflex did not work. The protective reflex is retained for strong effects on the siphon, but with a weak effect it was absent. But if the light touch of the siphon was preceded by an impact on the tail of the mollusk, then the protective reflex worked with the same force and the gills survived.

Illustrations from Eric Kandel book “In Search of Memory”

The nervous system of Aplysia consists of a relatively small number of cells that can be identified and therefore it is possible to compose patterns of reflexes. It is possible to completely isolate the reflex arc responsible for the defensive reaction when the siphon is irritated — this is the main circuit. And the neuron chain responsible for modulation is a modulating chain that is activated when exposed to the tail of a mollusk.

Eric Kandel described in detail how modulation occurs in this case, what chemicals are involved in this process, intracellular cascades of reactions. Let’s transfer this knowledge to our model.

And so in our system there is a certain type of synapses — modulating. This type of synapse has no direct activating or inhibitory action, it acts on the level of the activating threshold. The level of activation of the neuron consists of two parts of the main and modulated. The main part of the activation threshold is what will change when habituation and adaptive. The modulated part is similar to the adder, in it all the effects from the modulating synapses are added. The resulting sum gradually decreases in modulus and tends to zero. The rate of reduction of the modulating effect is much slower than the rate at which the overall effect of synapses of direct action decreases.

The strength of the modulating synapse can be different in sign, that is, it can raise the threshold, thereby reducing the sensitivity of the neuron, or lowering the threshold, increasing its sensitivity.

The threshold level by which the neuron will be activated is the sum of the main and modulating parts, this level can not be zero or below zero.

Let’s simulate the experiments of Eric Kandel with Aplysia.

The receptors “Q”, “W”, “E” and “R” are siphon receptors, each of which is associated with a receptor neuron. Each receptor neuron is connected by direct action synapses with an insertion modulated neuron. Which in turn is associated with the motor neuron, which signals the indicator “1”. Indicator “1” will be analogous to the action of reducing the gills in Aplysia.

Initially, the network is configured so that the activity of each of the siphon receptors will lead to the action of “1”. But with prolonged “tickling”, unhurried successive activation of the siphon receptors, after a while habituation to the intercalary neuron occurs and no response takes place. But, if the receptors of the siphon are affected more strongly, activate several receptors at once or do it more quickly, then we will see that the reaction “1” will still work. In this case, the adaptation mechanism will be very long in time, and we can neglect it.

Also in our scheme there is a receptor “F”, a receptor for the tail of a mollusk, which is associated with a neuron that has a synapse of modulating effect on an intercalary neuron. This synapse lowers the level of the neuron threshold for a certain time, which makes the neuron more sensitive and during this period the activation of even one receptor of the siphon leads to the reaction “1”.

The mechanism of sensitization in Aplisia is a prototype of the emotional state of anxiety and fear in animals with a more developed nervous system. In such animals, not individual chains of neurons participate in sensitization, but whole regions in the nervous system. The area responsible for fear and anxiety is the amygdala, with its activation occurs, the production of modulating mediators (epinephrine, norepinephrine). These mediators can exert an effect on the motor cortex, increasing the sensitivity of neurons, which increases activity in the motor cortex. This means that less internal motivation is required to accomplish certain actions, which allows you to escape from danger more quickly or more aggressively.


Modulated neurons also allow us to imagine how the behavior of an animal changes depending on external and internal circumstances. For example, Aplysia demonstrates a very complex behavior during the mating period, her behavior changes during this period, and possible responses to the same stimuli change. That is, we can say about the existence of a “switch” in the nervous system of the mollusk.


The network is configured so that when the receptor “R” is activated, a reflex response “1” occurs. But if we model this neur network by activating the receptor F, then the reflex response “2” will occur at the same receptor “R”. Modulating factor for the nervous system may be the presence of a certain hormone in the body, which explains how the behavior of the animal changes, for example, during fertility.

An example of gait switching in the nervous system:

The above mechanisms are sufficient for modeling simple nervous systems. An example of this may be my project OPENTadpole, a model of the nervous system of a tadpole frog.

Dowland for Windows

To be continued…