The concept of transferring worm consciousness to a robot

The main task is to realize the nervous system of the roundworm c. elegans in the body of the robot in such a way that all behavior is controlled by this neural network.
Why c. elegans?
A widely known and best-studied organism with detailed information about neurons and a complete description of the structure of connections in the nervous system.

Figure 1. Nematode model in NeuroConstruct .
What is the fan?
The idea of transferring the nervous system of this nematode to a robot is not new and has appeared repeatedly.
For example, popular connectom implementations in Raspberry Pi GoPiGo or Lego EV3 robots.
Usually, a similar problem is solved with the help of an adder with selected weights of braking links, which allow changing the trajectory when an obstacle is detected.
Which, of course, is already a victory.
But, for the sake of interest, (and the availability of free time) I wanted to understand a little deeper the morphology and behavior of the nematode. And the very idea of implementing a simplified biological model for controlling a robot does not cease to fascinate.
Behavior
Based on real behavior c. elegans would be nice to simulate the following activity:
1. Moving forward.
2. Change of direction in case of detection of an obstacle.
3. Turns left / right.
Connect
A nematode connection is a simple list of neurons and the connections between them with already given weights and the type of connection. In general, we are only interested in exciting and inhibiting types of bonds.
You can view the links here or here or in the Celegans NeuroConstruct distribution .
Unfortunately, it is not so easy to find inhibitory neurons in the list. To do this, it was necessary to study both the neurons themselves and the neurotransmitters. Here is an example of a inhibitory neuron (inhibitory neuron).
(It is worth noting that I still have many questions, for example, why there are so few inhibitory neurons in the connection, although the articles write about the “inhibitory effect” of one group of neurons on others. For example, RIMneurons inhibit AVB, but the connection between them is not inhibitory. Etc. There are also neurons whose role is not entirely clear or the nature of the connections is not clear.)
Neuron
The basis of the entire model should be an artificial neuron. For greater drama, it was decided to use the spike model of the Izhikevich neuron , which not only visualizes neural activity, but also has a number of interesting properties, such as synaptic currents, membrane potentials and generally models neural phenomena that are not far from the present.
Hebb’s differential training was added to the implementation of the Izhikevich neuron to strengthen the connections between neurons.

Fig 2. Visualization of a spike model of a neuron. Membrane potentials.
Neural network and behavior
Now a neural network based on a connection is easily organized.
Based on the expected behavior, we find groups of neurons whose stimulation will lead to the required activity.
For example, activation of sensory neurons responsible for detecting food leads to movement:
ADFL, ADFR, ASGL, ASGR, ASIL, ASIR, ASJL, ASJR, AWCL, AWCR, AWAL, AWAR.
Usually they say that moving forward, but in reality the direction of movement can suddenly change.
When stimulating sensory neurons responsible for detecting obstacles, it leads to a change in direction of movement :
ASHL, ASHR, FLPL, FLPR, OLQDL, OLQDR, OLQVL, OLQVR, IL1VL, IL1VR, IL1L, IL1R, IL1DL, IL1DR.
Indeed, when stimulating food search receptors, both the rhythm and the specific pattern of activation on muscular neurons are noticeable.
But the excitation of nasal receptors, which should lead to a change in direction of movement, also activates muscle neurons with a characteristic pattern.
d: - - 1 - - - - - - - 1 1 1 - - - 1 - - - - - - - v: - - - - - - - - - - - - - - - - - - - - - - - - - - v: - - 1 - - - - - - - - - - - - - - - - - - - - - - - d: 1 - 1 - - - - - - - 1 1 1 - - - 1 - - - - - - -
D and v mean spinal and abdominal muscles, respectively. A pattern of activation of muscle neurons using a spike model of a neuron.

Fig. 3. Joy to the eyes or the difference between the activity of the abdominal and spinal muscular neurons. In dynamics, forms a wave-like motion.
Muscular neurons are also active when moving forward, as well as when moving backwards.
But how to determine in which direction the movement is going, or at least the moment of change of direction?
It is described here that forward movement is caused by a signal from AVB and PVC neurons to B neurons, and backward movement from AVA, AVD and AVE to A neurons.
Also reportedthat back and forth movements are all kinds of activity and are caused by different areas of the nervous system. Although it is noticed that these areas interact with each other. And the neurons responsible for moving forward play some role in moving backward. Those. active when driving.
But here it is shown that B neurons are active when moving forward, while A neurons are active when moving backward.

Figure 4. Change in the activity of VA and VB neurons and their dependence. More details here .
In essence, it means that motor neurons VB and VA should not be simultaneously active when moving.
It only gave us that we need to watch the activity of VA neurons.
After analyzing the activity during stimulation of food neurons (food sensors) and neurons of the nose (nose touch sensors), it turned out that in the latter case, the frequency of spikes increases.

Figure 5. Average activity of VA neurons. At 900,000, the pulse frequency has increased. This is the moment onset of stimulation of nasal neurons.
This made it possible to find a way when to change the direction of movement:
In general, this is a calculation of the average frequency of oscillations during movement and with an obstacle. If at the moment of time the average frequency is closer to the movement, then there is movement, if closer to the obstacle, accordingly, the direction must be changed.

Figure 6. Nose stimulation stops at 980000, which leads to a sharp drop in the average activity of both VA and VB neurons.

Fig 7. We hope for a change of direction from the moment of 980000.
Simulation
To simulate a robot, the open-source Enki project was chosen , which provides the ability to simulate robots on a flat surface with basic physics support.
Enki includes the implementation of several academic robots, of which the choice fell on E-puck , to implement a connection on its basis.
E-puck has a number of infrared sensors.

Figure 8. Sensor circuitry on the robot.
Sensors 0, 7, 3, 4 were chosen to stimulate neuron obstruction (nose touch).
As a result, the robot became able to change its direction when stimulating a given group of neurons and, as a result, all three patterns of behavior were achieved: forward movement, change of direction and turns.

Fig. 8. Simulation of an extended version of the E-puck robot with integration of the implemented connection based on the spike model of the Izhikevich neuron.

Figure 9. Handsome and well done E-puck robot.
Conclusion
Thanks to those who have mastered, but really brave and desperate, they will also get acquainted with this implementation closer, and the title humor is taken from here .