Connectome Editor

Greetings, dear friends! I want to tell you about my project. My hobby is researching the nervous system and the brain as a whole and trying to reverse engineer these systems. This is actually what my articles on habr are dedicated to. And now I’ve come to the idea that I need to develop some kind of tool that would simplify the work on my searches and research, and make them more accessible. Yes, there are many frameworks on this topic, but none of this suits me, firstly, I have a somewhat alternative view of the problem, and secondly, I think I can do it better and more accessible.)

More than six years ago, I presented my OpenTadpole project with an article on habr. This was the editor of the connectome of a certain spike neural network that controlled the body of a frog tadpole in a simulated environment. This project shows the possibility of forming complex reflex behavior using fairly simple neurons. Here we are talking, of course, only about unconditioned reflexes, without any training. An interesting point for me was that many were interested in whether there was a web version (this is a project made on unity) or whether there was a version for Mac or Linux. Essentially, even people who were interested in the project’s topic and were Windows owners were in no hurry to download, unpack, or try something. And this is understandable; it is much more convenient to simply follow the link and get the necessary experience working with the editor. Unfortunately, I could not imagine the web version, since I used third-party plugins to simulate liquids that conflicted with the compiler for WebGL unity, well, this compiler is very capricious. From that moment on, the idea was born to make a similar editor and make it even more accessible.

Moreover, we came to an understanding of how to scale a simple connectome editor, because initially the OpenTadpole project was very limited by both the lack of learning mechanics and the ability to work with a large array of neurons. It is important to consider the nervous system from many angles, and an equally important factor is its evolutionary development. Using the laws and rules by which the nervous system functions, if we understand them correctly, should make it possible to describe the nervous activity of both the simplest animals and highly cognitive activity. From here comes the ideology that using the same basic elements – neurons, it is possible to build both simple nervous systems and neural systems that perform cognitive functions.

So, I set out to create an accessible, web-based connectome editor on which it will be possible to create a simple control circuit for a virtual animal or robot, as well as expand the capabilities of this circuit and add various cognitive functions, learning, image recognition, speech commands, etc. The task is not easy, so it will require a lot of time and motivation. What is the best source of motivation? – This is your support, my dear friends! The editor is far from complete, but it still implements some important mechanics. Open source code (even if not professional, unstructured), runs in the browser, available via link.

Connectome editor: https://belkinandrey.github.io/

Source: https://github.com/BelkinAndrey/belkinandrey.github.io

As we add functionality to the editor, I will share how it works, a kind of developer diary with a dive into the theory of reverse engineering of the brain.

Initially, the task was to repeat the functionality that had already been worked out in OpenTadpole, a simple editor that allows you to create neural circuits of unconditioned reflexes, but with an emphasis on versatility and performance. Performance in such systems is of course determined by the use of GPU computing resources. I had to learn a new stack along the way (web, javaScript, html, css), fortunately now there are all sorts of GPT helpers to whom you can ask the most stupid and naive questions without hesitation, they have nowhere to go and they will answer anyway. At first, I honestly tried to force the editor to write the AI ​​chat for me, but I quickly realized that the AI ​​didn’t want to take this work away from me at all.

The first implementation still confronted me with the issue of optimization, although the calculation logic was implemented on the GPU. Initially, I used the very convenient GPU.js library, but for optimization purposes I even rewrote it to a lower-level WebGPU. As a result, the weak point in optimization was the interface; in my principles, I strive to visualize everything as much as possible, I wanted to see the activity of neurons and spikes. In principle, spiking networks require high performance. The idea has matured to reconsider the concept.

!(Pulse network)

Spike networks stand somewhat apart in machine learning; there is a whole layer of scientific works devoted to them, many apologists and ideologists. Many call this direction very promising; large companies are developing special chips and processors. Although, so far, such networks themselves have not shown any outstanding results. Compared to classical artificial neural networks, spiking networks are at the level of MNIST-type problems. But their prospects are considered in terms of energy efficiency and proximity to a biological analogue. Essentially, it all comes down to the thesis: “Once we find an algorithm that allows us to achieve the same high quality as backprop (after all, the brain runs on spike networks), then in combination with high efficiency and parallelism, spike networks will become a breakthrough, on specialized hardware, of course.” Another factor in favor of spike networks is the idea that spike networks contain mechanisms that bring them closer to biological networks. We cannot yet reliably say on what principles the brain works, and by omitting such physical mechanics as the impulse of signal transmission between neurons, when creating models, we can miss an important component of the principles of brain operation.

When modeling such a complex system as the brain, we can identify arbitrary levels of detail. For example, the highest level of detail is modeling down to individual molecular mechanisms and the detailed topology of the neuron body, commissures are described by a detailed Hodgkin-Huxley model. A lower level of detail is to accept the neuron’s body as conditional, but take into account the adhesiveness, types of neurotransmitters (of which there are about 200), and some aspects of metabolism. An even lower level is to take into account not individual impulses, but to set the characteristics of their frequency; the type of synaptic transmission is divided only functionally (stimulating, inhibitory, modulating). An even lower level is to model at the level of interaction between different areas of the brain. Any level of detail can fully reflect the real processes occurring in the system. But, the higher the detail, the more difficult it is to implement and the more expensive it is in resources. It is always possible to take on the implementation of a model at a low level of detail, but in this case we need to have a very good understanding of which processes at a higher level are of key importance.

For a long time I built my models taking into account the impulse nature of signal transmission between neurons, but I do not see spiking as being of key importance for the construction of cognitive systems. Impulsivity itself imposes some restrictions and additional costs in terms of management. For example, the spike time in a biological system is approximately 1 ms, another 1 ms is needed for the refractory period, that is, the maximum possible is about 50 pulses per second for an individual neuron. If we want to control any parameter with a gradation of 1024, then we will need to either take into account a delay in control of more than 21 s (1024 / 50 = 20.48), or the control signal must be simultaneously removed from 21 neurons and somehow summed up. Our muscles have very precise and smooth operation not only due to the control of the frequency of incoming impulses, but also due to the presence of a large number of motor units (a neuron + a group of muscle fibers controlled by it), as well as a large number of neurons involved in the control itself. Precision control tasks require a large number of neurons in spiking networks.

If you call the setInterval() javaScript function (the specified function in the argument will be called with a given time interval) with a time parameter of 0, then the browser will be able to perform some events no more than once every 4 ms, take into account that network calculations can be loaded, this time will easily increase . It turns out that in order to accurately control any parameter in the editor, you will need to build a circuit from a very large number of neurons – this is inconvenient and unnecessarily loaded.

In my research work I already had experience (https://habr.com/ru/articles/709350/), when properties that seemed to manifest themselves only due to the impulsiveness of the neural network, I transferred to a simpler algorithm using tonic neurons whose output is expressed real number. Moreover, some aspects of these properties have become more understandable.

Summarizing all of the above, in relation to the editor, it was decided to abandon spiking and switch to tonic neurons, the output of which was determined by a real number from 0 to 1, but at the same time it was necessary to preserve the dynamics and some important aspects of the work of the spiking neuroelement. And it seems to me that I managed to come up with a truly universal element with which you can create any control schemes.

The spiked version of the editor running on WebGPU is available at: https://belkinandrey.github.io/spike/

Tonic neuroelement

The editor implements three elements or nodes: neuron (circle), sensor (pentagon) and actuator (square). These nodes can be connected by directed edges or links, of which four types are presented in the editor (we will consider only two now). The first type is direct-acting synapses; they store a weight value, which can be positive (stimulating, green) or negative (inhibitory, blue). The second type of connection is the one that modulates the sensitivity of the neuron and is indicated in gray. The tonic neuron is very similar to the McCulloch mathematical neuron Pitts. With its help, you can freely create neural circuits in the editor. All weights of direct action synapses multiplied by the activity value of the corresponding neurons of incoming connections are summed up. Then the resulting amount will be multiplied by the sensitivity characteristic of the neuron. This characteristic may change under the influence of a modulating connection, but cannot be less than zero. The result obtained will go through an analogue of the threshold function, which is determined by two adjustable parameters – the lower level (lower-level) and the upper level (top-level). Lower-level is the value up to which the output of the neuron will be strictly zero. Accordingly, the top level is the value of the sum above which the neuron will have a value strictly equal to one. Values ​​of the sum between these levels will produce the corresponding value in the range from 0 to 1.

A neuroelement can have a direct action connection closed on itself. A node in the editor with such a connection will be indicated by the symbol ⟲. Thanks to such feedback, the neuroelement is able to independently maintain a constant level of activity; it is also possible to configure this connection so that the excitation gradually flares up or gradually fades away.

This is enough to create various logical circuits. It is trivially possible to create something like a transistor where the collector will be a direct action connection, the base will be a connection that modulates the sensitivity of the neuroelectron, and the emitter will be the output value of the neuron. This suggests that it is theoretically possible to describe any control scheme using these elements.

Hexapod

We can already create schemes, but we need to be able to apply these schemes. To make this as versatile as possible, it was decided that the editor would run in a separate browser tab, with the simulation in the adjacent tab. The connecting link between the editor and various types of simulations are sensors and actuators. In the editor you can specify the id of these elements. Browser tabs in my implementation communicate via Local Storage – this is somewhat clumsy, but it works great and allows you to do without creating servers, which in turn simplifies working with the editor code. The managed tab page code can be anything, the main thing is to use Local Storage correctly.

I made a simulation of a hexapod robot in Unity with compilation in WebGL.

Here the actuators control the robot’s virtual drives, of which there are 18 pieces. 0 and 1 on the actuator set the extreme position of the virtual drives. Sensors are only required for keyboard control.

The basis of the hexapod’s neural circuit is the Periodic Activity Generator – this is a closed chain of sequentially connected neurons. Each neuron in the chain actually denotes a specific action in a locomotion cycle, for example, “raise legs 1, 4, 5”, “lower legs 2, 3, 6”, “move back legs 1, 4, 5” and so on.

There are two types of gait: walking – in fact, when walking, only two paws are raised, and running – when moving, three paws are raised. Each type of gait has its own Periodic Activity Generator; by controlling them, we control the locomotion of the hexapod.

In front of the actuators responsible for moving the leg forward/backward, a command inversion circuit has been formed, which can be activated on the left and right sides separately, which adds to the movement the ability to turn the robot left or right.

Caenorhabditis elegans

The nematode worm c.elegans is one of the most famous model animals in neurobiology. This is the first animal whose 302-neuron connectome has been fully mapped. Many different types of simulations of this worm have also been created. And this is also a gestalt that I needed to close.

It is known that the neural circuitry of c.elegans locomotion involves feedback from stretch receptors in the worm’s body walls. Therefore, I added receptors that respond to compression to the simulation so that I could experiment and assemble a feedback locomotion scheme. And there is a separate receptor that reacts to the worm’s head touching the walls of the “aquarium” or an object in order to add a backward movement reflex to the nervous circuit.

When developing a simulation of the environment, it seemed to me that the wave-like movement of the worm was enough to move it, but it turned out that on a simple flat surface the worm in this case simply kicks and there is no directional movement.

In nature, c.elegans moves in a thin layer of so-called agar – a jelly-like substance, in which, under the action of the body, it forms a groove, and the walls of this groove create additional force when repelled from them, and this is where wave-like movements will work.

Source: dissertation of Palyanov A.Yu.  about the nematode https://icmmg.nsc.ru/sites/default/files/sovet/files/dissertaciya_palyanov_a.yu_._final_podpis.pdf

At first I tried to repeat the physics of this agar, but it didn’t work out very well. The solution was to apply to each segment, there are 25 of them in the model, a force opposite to the movement of the segment across the body, which simulated the force arising from the walls of the groove in the agar.

Cognitive map

Many people have already heard about what cognitive maps are, about place cells and grid cells in the hippocampus. And of course, the fact that the brain has some kind of planar mini-map with a mark of the actual position of the subject on it is surprising. And it makes you think about how to get such a card. I have my own version. It all starts with the rotation orientation cells in space. Not far from the place cells, head rotation cells have been identified; I think there is also a place for orientation rotation cells in space. Every time the brain sends commands to turn the body in space, it duplicates these commands to a special network of neurons that regulates the operation of spatial orientation neurons. These can be only two types of commands, “turn left” and “turn right,” but the values ​​of the neurons will change based on the current position. Such a diagram is easy to create.

The meaning of orientation cells in space will work together with the mental map. Also, the brain, when forming commands to move forward, will transmit this command to our mental map. The logic of the mental map diagram is quite simple, the orientation cell in space “up” affects all planarly located cells of the mental map with an effect that tends to spread excitation upward. But this influence is not enough, it is necessary that the command to move forward is active and the cell of the current position (meta cell) is active in the map cell, only in this case the excitation will be transferred to the cell above. Next, the previous cell is suppressed so that only one cell/cell of the place is active on the mental map.

Actually, the impact on all cells/cells of space for different directions determines the need for grid cells.

This is the simplest cognitive map model that exists. A neural circuit that emerged at a very early stage of evolution should have a very simple logic.

This is a very simplified model of a cognitive map; it does not include images of a place received from the senses. The fact is that the cognitive map of the hippocampus is to some extent relative; these will still be the same place cells, but in different locations they will indicate different places. The image of a place essentially includes a set of sensations received in a given place and a link to some cell of the place on the mental map. When moving around the area, our sensations of the environment change, and also specified changes occur in the mental map; all this is compared and combined into a single complex image through which we can “travel” mentally. Well, what happens if we add time cells, which are also found in the hippocampus? – The ability to mentally manipulate not only space…

FLUX (fluxengine.ai)

By sharing my observations and developments on the habr pages, I receive feedback from people who are interested in my ideas. This is inspiring and there are very productive acquaintances. Thanks to the above-mentioned article about the OpenTadpole project, I started communicating with Albert Kaygorodov. He is a professional programmer and was very inspired by this tadpole simulator. He promoted the idea of ​​doing something similar, but on a more global level, to create some kind of web environment for the development of artificial nervous systems. To be honest, I initially did not think of working in this direction, but over time, Albert’s persistence and the development of my work convinced me that this was a very successful path. At some point I saw how this could work, how it would facilitate my searches and make the results of my research accessible. Already now the project can be considered as a visual programming tool. It is possible to write page code to control any peripheral and use the connectome editor to create control circuits.

In my open project cogFlux I implement the basic logic; I think my level of programming will not allow me to make a sufficiently powerful system with great functionality. But there is a project FLUX (fluxengine.ai), which is initially developed as a very productive and functional environment at the proper technical level.

And of course, the development of such an environment takes time; it is carried out on personal initiatives. As a demonstration of the possibilities, we are developing a hexapod robot. We have no experience in robotics, so so far work on the robot has been progressing with varying degrees of success

As always, I will share the significant results of my work with you, my dear habr readers. There is also an unobtrusive telegram channel (https://t.me/neuro_cyber) and a group on VK (https://vk.com/club137626673).

Connectome editor: https://belkinandrey.github.io/

Source: https://github.com/BelkinAndrey/belkinandrey.github.io

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *