OPENTadpole: the first cybernetic animal

Hello, dear community GeekTimes! After my long silence, I want to present my new project. OPENTadpole is an application consisting of a full-fledged editor of the nervous system of the frog tadpole and physical emulation of the tadpole's body and the external environment. The ability to create, adjust and edit the animal from scratch and immediately see how your creation is reflected in its behavior.
About a year ago, a series of articles on the development of a nervous system simulator was completed, and the application I developed had a number of flaws, and the amateurish code did not allow the application to be extended and developed. It is worth noting that the application developed at that time allowed us to demonstrate and develop the basic mechanisms and theoretical platform of the simulation system, which I adhere to. It was decided to rework the code again, from the standpoint of a more accurate representation of which entities and their functionality will be present in the final version of the application.
Firstly, I used my favorite Unity game engine for my development, and connected the essence of the neuroelement with the GameObject, its logic was run on corundines, that as the network scale grows, it becomes a fatal problem, the application creeps terribly due to the close connection of the neural network graphic part of the application. Of course, the decision was to separate the graphic part from the system logic, the logic should be executed in separate threads, and the graphic part will only be able to periodically refer to the network elements to reflect the changes taking place. This approach gives another advantage, the ability to not only monitor the processes occurring in the network, but also to interact with the results of its calculations, for example, to immerse the network in a certain virtual agent and observe
Secondly, it was decided to revise the concept of the editor, despite the fact that 3D is considered to be a more effective visualization method, I decided to switch to 2D. I used to think that in a three-dimensional organization of the nervous system there was a certain key meaning, and, fearing to lose sight of something, I was striving for a three-dimensional organization of the editor and system. But now, I understand that it is enough to apply a constructive flat editor with levels or layers, because even the bark of the big hemispheres has a layered structure, and working in a plane allows the end user to more conveniently navigate and organize their work with the editor, especially when it comes to large arrays of elements.
Considering that I work alone, and developing applications in the field of cybernetics is not my main activity, development began to go slowly, and at the same time I have long wanted to demonstrate how my ideas can be applied to animals with a simple nervous system, such as clams, a worm or some kind of insect. I really like the OpenWorm project to create a computer model of the Caenorhabditis elegans worm, whose nervous system consists of 302 neurons, and whose connection has been completely made up. The project consists of two parts: modeling the neural electrical properties of the nervous system of the worm and modeling the mechanical properties of its body during the swim. I applied this concept to my project, a reference to what can be seen in the name of the project. The choice of the simulated animal was influenced by the recording of the speech of Roman Matveyevich Borisyuk, in which, he talked about a project to model the nervous system of a two-day frog tadpole. Inspired by this video, I decided to make some branch in the work on the nervous system simulator, which I gave the name OPENTadpole.
A theoretical platform claiming to explain the mechanisms of the nervous system should work both on the scale of simple nervous systems and on the scale of nervous systems performing cognitive functions. You can often find remarks addressed to the authors of new-fangled theories on the brain's work, that before simulating large-scale neural networks, it may be worthwhile to show how their theories can be applied to the simplest animals and their nervous systems. One can hear an evasive answer to these remarks, that the properties of neural systems manifest themselves only on very large, gigantic scales, and the life of primitive creatures does not matter when it comes to solving cognitive problems. Such injustice and delusions have become for me another reason for a while to concentrate on the life and behavior of the two-day tadpole of the frog.
Cybernetic animals with the nervous system
Of course, Man has already created quite a few cybernetic mechanisms that imitate certain aspects of animal behavior, for example, Wacanson mechanical ducks, which not only flapped their wings, pecked scattered food, but also had a similarity to the digestive system with all the accompanying processes. But artificial animals with a nervous system similar to their biological counterpart are quite rare. Let's take a brief overview of the world of cybernetic animals, so that it becomes clear to you where I got so much audacity to call my tadpole the first cybernetic animal with an artificial nervous system.
And we will begin not with an animal, but with a legendary personality - Henry Markram. Henry Markham is a scientist, known to many as a pioneer in the study of synaptic connections, he was one of the first to systematically study the sequential version of Hebb's rule. But Henry Markram gained real fame as the creator of the world's most expensive brain imitation. At the disposal of the scientist and his colleagues, not only the largest funding ever allocated for such purposes, but also the most powerful computing resources of the Blue Gene Supercomputerfrom IBM. The name of the computer and gave the first name of the project: "Blue Brain Project", in 2013 renamed to "The Human Brain Project". Despite the fact that now in the title of the project they speak about the human brain, work is being done on a model of a small fragment of the cortex of the mouse brain. Project managers have big plans, starting with a small fragment of the mouse brain to reach the full model of the human brain. Back in 2009, Markam, the project's chief curator, promised that in ten years a computer imitation of the entire human brain would appear. Many people think Henry Markram is a charlatan. Indeed, if you listen to his speeches, they are aimed more at wealthy investors who are poorly versed in neurosciences than at their fellow scientists.
In the entire history of the project, in addition to beautiful graphic materials, flashing neuron garlands, there is one practically useful study. Approximately twenty 3D-models of neurons of certain types were created, completely repeating the topology of real neurons, taking into account all the bends and branches of dendrites. Then, a small area of the cortex was configured, in which the prepared neuron models were located, according to certain rules, but the neuron models were chosen randomly, then statistics were collected from the resulting model: where the dendrites intersect, at what distance from the cell body, what type of contacts.
The obtained statistics was compared with similar statistics, but obtained from the biological nervous system and obtained very important results: the formation of 80% of synaptic connections in the cortex is subject to randomness. Those. where free-growing dendrites, axons, collaterals meet, synapses can form, and no chemical markers. Of course, in some cases the selectivity of the formation of synapses is not excluded, and it is also impossible to conclude that the quality of connections is random. A synapse can be formed randomly, in the process of neuron growth, but its strength (weight) can be determined by the vital activity of the nervous system and the animal.
While it is impossible to talk about a cybernetic virtual mouse within the Human Brain Project, it’s still far from a full-scale mouse brain model. At the expense of IBM's resources, another researcher Dharmendra Mohda in 2009 announced the launch of a project to create a digital imitation of the cat's brain. This statement caused a lot of outrage at Markram, which resulted in an angry open letter to the chief technology officer of IBM. Nobody likes the competition, but we'd rather see it in the fight of virtual cats and mice than in attracting the attention of IBM heads, leaders of costly imitations. After so many years, there have been no significant changes and developments in the field of imitations of the mammalian brain.
Openworm- a very famous project to create an imitation model of a nematode (roundworm) of the species Caenorhabditis elegans, this worm is notable for the fact that it is the only animal species for which the complete connection of its nervous system, consisting of 302 neurons and about 7,000 synaptic connections, is made. Even for such a small nervous system as in c. elegans making a connectoma turned out to be a titanic work. First, the worm was subjected to a complex procedure - serial microscopy, the creation of a series of photographs of transverse sections of the body. It was necessary to make very thin sections of a few microns, then using an electron microscope to create high-resolution images. With an adult worm's length of 1-2 mm, this turned out to be a difficult task, the available atlas of photos is made up of 3 worms, since the nervous system c. elegans has amazing structure stability and repeatability. Secondly, it took more than seven years of painstaking study of images, the team of scientists, to map the connections of the nervous system, the resulting database is still being adjusted.
Unfortunately, in the photo it is impossible to determine the type and strength of synaptic connections, as a result we have a description of connections without any idea about their functional purposes.
The next step in understanding the nature of the nervous system c. elegans becomes an attempt to create a computer simulation of a worm. The digital model is convenient in that the experimenter can change and select the settings of its elements, so that the work of the whole model is comparable to the biological analogue, so that it is possible to identify some laws of organization and operation of the nervous system of a living organism using a method of empirical selection. Of course, without a general theory of the nervous system, without a theoretical platform, such a search for laws is a very difficult task, the solution of which can naturally be delayed.
The project became especially famous during the company on kickstarter in 2014 . The OpenWorm community is very fruitful: a three-dimensional atlas of nematodes has been created , in which the nervous system has been worked out in detail - each neuron is designated; a geppetto modeling and visualization system has been created and widely developed ; Simulation of the mechanical properties of the worm's body and the external environment - Sibernetic, on which our compatriots work. But free-moving cybernetic nematodes controlled by the nervous system have not yet appeared. Some simple reflexes associated with locomotion (displacement) and detaching when touched to the front of the body are modeled, but most of the neural circuits and the nematodes associated with them remain unexplored.
One of the latest Sibernetic videos from the Andrey Palyanov channel, swimming of nematodes in two different environments, controlled by simple periodic signals, without the participation of virtual neurons.
The next project made a big impression on me, it was after watching the next video with the performance of Roman Matveyevich Borisyuk, I decided to choose a tadpole model animal in my project.
The little-known project tadpoles.org.uk modestly explains some of the fundamental principles and laws of the organization of the nervous system. Scientists have created a model of the development of the nervous system, the formation of it in the initial period of development of the animal. First, a model is generated: dendrites and axons grow from neurons according to certain rules, taking into account some parameters of the tadpole’s body with some probability affecting the growth direction of the processes, then synapses form in the places of contact between dendrites and axons of different cells. In the final, the model can be activated and it will demonstrate activity similar to the activity of the nervous system of a living tadpole in the part responsible for swimming.
It turns out that in order for the nervous system to form with all the innate reflexes and mechanisms it is necessary that the nerve cells follow fairly simple instructions. Depending on its location and belonging to certain clusters of cells - ganglia, the cell must grow its dendrites and axons in certain directions, as well as form synoptic contacts with cells and their processes located nearby on these processes, without any selectivity. The resulting error in the structure of the neural network due to deviations in the direction of growth of the processes while overcoming possible obstacles is compensated by the excessive presence of neurons and processes.
For the act of swimming, wave-like contraction of muscles along the body, a tadpole requires about 1,500 neurons, for nematodes less than three hundred. A frog's tadpole is a more complex and evolutionary animal, compared to a roundworm, and the increase in the number of neurons is connected here, not with the need to increase computing power, but with the reliability of the system and compensation for the inaccuracy of neurons as computational elements. Some researchers attribute the properties of quantum computers or complex computers to individual neurons, but this is fundamentally wrong, a neuron is primarily a biological cell, with an inherent error in its work and instability. Therefore, it does not make sense to spend time on the reconstruction of all 86 billion neurons of the human brain,
The main right approach
You can spend a lot of time, money and effort to create the most complex models of complex systems without getting practically significant results, if the basis is not an accurate idea of the operation of each element of the system, and what functions these elements perform within the system as a whole. Ideally, you need to know the result of the model’s work before it begins to be recreated, that’s what determines the success in solving the set tasks, and not the availability of a supercomputer and great financial assistance.
Now much attention is paid to neural networks that demonstrate high efficiency and great practical benefits. Initially, neural networks were positioned as certain models of biological neural networks, but over time and the development of neurobiology, it became clear that the formal neuron used in the National Assembly and biological only have a name in common. Modern neural networks are a powerful mathematical tool for statistical analysis. It is this positioning of the NA when they are developed that will provide greater efficiency. Statistical analysis and processing of a large number of data, not a model of the nervous system. It is possible that on the platform of the National Assembly some kind of artificial intelligence may appear, but if we are striving to create intelligence like human, we should pay attention to biological neural networks.
Neural networks have already proven to be more effective in solving certain problems compared to humans, and it is desirable that their development continues. As a brain explorer, I would have more confidence in a machine controlled by a well-developed neural network than a machine controlled by a virtual nervous model of a biological tissue. The fact is that in the mechanisms of the brain, elements of inaccuracy and limited perception are inherently laid out, naturally leading to errors, but on the other hand, these same mechanisms provide great potential for creativity and adaptation.
The dominant mathematical model used in the creation of biologically similar neural systems is the Hodgkin-Huxley model, described as far back as 1952. Anyway, this model is used in the Human Brain Project, in the OpenWorm, and in tadpoles.org.uk. The Hodgkin-Huxley model is a system of equations describing charge oscillations arising on the surface of a neuron's membrane, the system of equations was adopted and adapted from electrical engineering in terms of descriptions of self-oscillations in an electric oscillatory circuit. Alan Lloyd Hodgkin and Andrew Huxley added some additional elements and a number of coefficients to the system of equations, selecting them so that the result of their work was compared with the experimental data obtained by them in the study of squid axons.

The Hodgkin-Huxley system of equations describes a change in potential only at one point of the membrane, to obtain a picture of the propagation of excitation along the membrane and processes of a neuron, you can divide the neuron model into some primitives, or choose equidistant points on it and read the system of equations at each such point. The Hodgkin-Huxley model is very realistic, demonstrates the spread of the action potential over the body of the cage, but the model requires large computational resources.
In my work, I perform a certain reengineering of the nervous system, isolate the significant and discard or simplify certain related processes and phenomena. The nature of the nervous system and nerve cells is very diverse and complex, there are many chemical reactions, intracellular processes and phenomena, but you should not transfer everything to the model, you first need to understand the meaning and functional purpose of the phenomenon, otherwise it will be a meaningless complication of the model.
What is the functional significance of the action potential spread across the neuron membrane? - The transfer of information from one part of the nerve cell to another. Information that the nerve cell has been activated through receptors or synapses, should arrive at the tips of the axon endings, overcoming its entire length, which can reach up to a meter in the human body. What is important in this process? - The time from the start of activation, until the transfer of information about it, the target area of the nervous tissue. On average, the speed of propagation of an action potential of 1 m / s, it depends on various factors, for example, on the degree of axon myelination. Accordingly, under various conditions, the delay time may be different. The Hodgkin-Huxley model very realistically models the process of nerve impulse propagation along the membrane,
If we can simplify something, it means that we understand something. The idea of simplifying simple laws and functions, highlighting the main thing and separating it from the minor, can be called a functional approach.

If you try to model the human brain with all 86 billion neurons, with repetition of the topology of the processes, and even miscalculation of the Hodgkin-Huxley system of equations in a dense grid of points on the neuron surface, then all the computing resources on planet Earth are not enough. And making predictions about the appearance of such models can be guided twenty years ahead, and after these years, another twenty years. Well, the spread of action potential is not everything, you still need to understand the logic of the interaction of neurons. To solve this problem, you have to concentrate on fairly simple nervous systems, such as the nervous system of a worm or a tadpole of a frog.
Development
You do not expect that the use of the game engine in scientific models can cause a sense of wariness among the public? - I was asked a similar question by one great Internet user. Yes, I have not resorted to any standardization system, I have not used languages for describing biological structures, only for the reason that it requires a lot of time to study related material. I am not a doer of science, but an ordinary bang with a dynamic and fussy life, but with a lot of ideas, creativity and the desire for realizations. Therefore, the time between family life, work and sleep is given to modeling by the means that are available. The Unity game engine is just a tool in my work, and it is very good and convenient in terms of visualization.
The entire OPENTadpole project consists of only two scenes: the editor of the connectom and the simulation of the environment. With the editor in the development process there were no serious problems, since I already had experience working on a previous version of the nervous system simulator .
Connect Connect Editor .gif

The main task at this stage was the separation of the execution of the logic of neuroelements and visualization, which was realized.
At the next stage, I turned to work on the environment simulator, and quickly realized the tadpole body from standard Unity components. The body of a tadpole consists of 9 segments, interconnected by joints, some virtual kinematic pairs and a pair of virtual muscles on both sides. Virtual muscles have a certain elasticity, which provides elasticity to the whole body.

Muscle work was subordinated to the virtual nervous system, which is loaded via save files that are common to the editor and to the simulation environment.
Spherical tadpole in vacuum .gif

Further development required the addition of a system simulating the physical properties of the medium, which was not an easy task for me. At some point I even regretted that the waterfowl was chosen as a model animal. And of course, the great advantage of using a very popular game engine is that it has created and developed many add-ons, libraries and assets. I tried working with several libraries, but LiquidPhysics2D was the best. There is no official link to the library, the website of the company-developer no longer works, but if you wish, you can find it, Google to help. This library is based on the well-known Box2D engine and is very optimized and easy to use, with many examples, so I managed to use it, although I had to put a lot of persistence in it.
Particles .gif

Calculation of the physical properties of a fluid in real time requires high computational power, so even using a well-optimized library, stable operation of the application can be obtained by limiting it to only a couple thousand particles.
I wanted to see a free-floating tadpole within a sufficiently large area, the strong limitations of space would not allow to fully appreciate the work of the model. It was decided to dynamically create and remove particles in the area of the surrounding tadpole, had to divide the space into special square areas and regulate the appearance and removal of particles in them depending on the position of the tadpole.
Squares .gif



So that the user was not confused by the dancing squares, the area of visibility of the particles was limited, as a result there was a certain aura that displayed particles around the body of the tadpole, which can be turned off with the F12 key.
Aura .gif

Result
The purpose of such projects is to identify some common rules of the organization of the nervous system and the laws of interaction of neurons that determine the behavior of the animal. The OPENTadpole project in this regard can be called fully completed, everyone can try himself as a Creator and fill the empty virtual tadpole’s body with a nervous system from scratch, allowing him to actively move in space and interact with the environment, and live in his own strict and limited world. Indeed, while the development was going on, I got a lot of positive emotions, seeing how my actions make the tadpole's behavior more and more alive.
The archive with the application has an excellent, colorful guide that describes the main aspects of the program, and also describes a number of saving examples that will help to understand the principles of the nervous system (link at the end of the article). The model is based on the same principles that I talked about in my previous publications ( part 1 , part 2 ), and there was no speculation about the electromagnetic interaction of neurons, only what great minds wrote and received Nobel prizes. Everything within the framework of scientific doctrine, but embodied in a new concise form, can be used as a teaching tool.
Swimming
At the heart of the neural chain responsible for swimming is the generator of ordered activity, such generators are found in all the nervous systems of simple animals, these are closed neuron chains capable of generating rhythmic excitation without feedback.

The generator circuit of the frog's ordered tadpole activity is represented by four neurons located symmetrically in the body of the tadpole. Two neurons (dIN, purple) in this scheme have a specific feature, they come out of a state of inhibition, creating a spike of activity. Each such neuron activates an inhibitory (inhibitory) neuron, which in turn has a cross effect on the neuron dIN. Thus, a certain circuit of circulation of nervous excitement turns out. It is possible to start this generator with a single activation of one of the neurons of the generator, and it is possible to stop the operation of the generator if one of the neurons in the chain is prevented from being activated by a stronger inhibitory effect.
In order to carry out experiments in the OPENTadpole system, 4 receptor keys F1, F2, F3 and F4 were allocated, in examples-saving the F1 receptor starts the generator, F2 suppresses activity in it.
The generator activity spreads alternately along the right and left side along the body of the tadpole, up to each motor neuron starting from the head to the tip of the tail, excitement comes with a delay of 100 milliseconds, this is because the propagation of the excitation has a finite speed. The speed of propagation of excitation in different axons can vary, in axons with a higher degree of myelination (a thicker layer of myelin) the speed will be higher. For example, in the body of squid there are some of the largest axons, practically up to 1 mm in diameter, which participate in the protective runaway reflex, when the squid backs away from the fast and powerful fungus of the tail, runs away from possible danger, a high signal transmission rate is required here.
In the nervous system of a biological tadpole there are many similar generators, they are located along the body and are connected in series with each other. If only a single generator was present in the nervous system of a tadpole, this would create a big risk, damage to one neuron, or even one synapse from this scheme would lead to loss of movement. There are no similar problems for computer simulation, therefore, a single generator is enough for a model.
Maneuvers
The tadpole has the ability to change the direction of its voyage, to perform some maneuvers; for this, at the time of the voyage, it is necessary that the muscles from the side in which the tadpole intends to turn, contract more strongly or intensively, while maintaining the same frequency of contractions.
The signals in the nervous system, for all animals, are, one may say, discrete. The amplitude of the action potential is always and everywhere stable, the signal itself has a short, pico-like character, but at the same time we can easily change the degree of tension in the muscles, quite smoothly and precisely, everything is determined by the frequency of commands sent to muscle groups. The more often the impulses, the stronger the contraction of the muscle. Thus, controlling the frequency of activating impulses, the nervous system controls the muscle groups, and quite flexibly.
A simple mechanism for the temporal summation of a neuron allows you to simply control the pulse frequency by changing the adder's threshold. The level of summation threshold in a biological neuron is determined by its overall configuration, neuron size, number and density of receptors on the postsynaptic membrane, number and density of ion channels on the membrane, in general, from the metabolism of the nerve cell. And all these parameters can actively change in a living cell under the influence of a modulating effect on it.
We have long been accustomed to the fact that in describing the work of the nervous system they speak only of two types of synaptic effects: stimulant and inhibitory. But in reality this is a fatal inaccuracy distorting the understanding of the principles of the nervous system. In his work, the American scientist neurobiologist Eric Kandel described the molecular mechanism of the synaptic effect leading to metabolic changes in the cell and synapse, for which in 2000 he was awarded the Nobel Prize. Modulating neurons and modulating mechanisms have long been used in the description of the principles of the nervous system, since these mechanisms play a significant role in its work.
The model has a separate type of synaptic connection, which can affect the level of the adder's threshold, for some period of time - a modulating synapse. If you modulate, reduce the adder threshold on the inserted modulated neuron (green in the following diagram), this will increase its sensitivity, and when activated, it will generate not one spike, but a whole series of pulses. Thus, by transforming the signal from the generator, it is possible to carry out maneuvers, turns while swimming. If thus modulated neurons on both sides at the same time, then the tadpole will simply be more active to swim forward.

The topic of modulation in the nervous system is very extensive, despite the fact that in this model I limit myself only to controlling the level of activation threshold. Given the changes that can dynamically occur in the nervous system, we can say that the modulation can be very diverse, it changes the strength of synapses, and changes in plasticity, and the degree of addiction, and the time of synoptic delay, and metabolic properties of the cell.
Control using modulating synapses, as well as controlling the operation of the generator, allowed for some protective reflexes to be realized, for example, the beginning of swimming when the tadpole is touched and the deviation is in the opposite direction from contact, which allows the tadpole to freely float in the virtual aquarium, sailing away from its walls.
Where to swim something?
The tadpole has learned to swim, and he can freely choose a direction, but in order to choose this very direction he needs a goal, and such a goal is completely justified, perhaps food. For the detection of food in tadpoles, there are two special receptors of smell, separated by a special line, the “bridge of nose”, through which the receptor cannot sense the presence of food. The closer the food, the more often the receptor is activated taking into account the square of the distance.

Of course, such a model of smell is a strong simplification, but in the framework of the simulation it is quite acceptable.
In the examples, signals from two receptors first pass a chain of neurons in which mutual suppression occurs, and then have a modulating effect on motor neurons, controlling the swimming of a tadpole.
Food search .gif



Needs
I wanted the tadpole’s behavior to be somewhat more complicated than simply following the food, so it was decided to introduce a simulation of the mechanisms of needs. First, it is the need for food, hunger is a natural desire to consume the source of energy necessary for the movement and development of the body. And naturally hunger should have a different degree, if the animal is well fed, then the food should not greatly interest him. Secondly, a no less fundamental need for the conservation of energy, which was born evolutionarily very early and carries the key value in the behavior of all animals. Being lazy, woven into our essence, it allows us to optimize our behavior in terms of energy consumption, whoever achieves a result with less waste of energy resources is more successful.
To realize these two needs, two special receptors have been introduced, the higher the need, the more often they are activated. The saturation level decreases with time, the rate of this decrease is adjusted by the user, and the feeling of fatigue accumulates depending on the intensity of muscle contractions.

In the conservation examples, one can observe a certain competition between these two needs: fatigue can be suppressed by not strong hunger, but strong hunger is stronger than even severe fatigue.
Now the behavior of the tadpole has become even more alive, it depends on internal motives and desires:
Difficult behavior .gif

findings
The tadpole swims and eats, and a lot more: it reacts to the light, touches it, if you grab it by the head, tries to escape (it is provided in the simulator), searches and finds food, suffers from hunger and fatigue, and all this is controlled by virtual neurons .
The maximally complex tadpole has 63 neurons and 131 synaptic connections, recall that Caenorhabditis elegans has 302 neurons, and a biological tadpole requires 1,500 neurons only for normal swimming. The more an animal develops, the higher the redundancy of neurons in solving problems, which is due to evolutionary processes and the need for system reliability. It is still difficult to assess the redundancy of neurons in relation to the human brain, but, in my opinion, to implement a computer model close to the human brain will not require quantum computers or mainframes, a powerful enough home computer. This is a very bold statement, firstly, contrary to the opinion of many experts in this topic, and secondly, removing the areola of super-complexity from this task, without which it is difficult to beat out fabulous investments from investors.
Future plans
OPENTadpole is a small stage, on a long way to develop a tool for modeling complex nervous systems, which, in my opinion, has been successfully completed.
The next task: the creation of a model capable of distinguishing simple voice commands, just as pets do, also learn them and, if necessary, retrain, with an understanding of the command context. In the course of work, I will try to share my research with GT readers.
OPENTadpole dowland for Windows
Source Code