Simulate a Worm Brain

Simulate a Worm Brain

In this project, we show you how to simulate a worm brain with the GoPiGo and a Raspberry Pi.  We’ll show how to build a Raspberry Pi robot with a worm brain.  This project was developed by Timothy Busbice and the Connectome Project.

Why Simulate a Worms Brain?

Robotics and computer science have contributed an enormous amount to brain research.  As computers grow more complex, they are used more and more to simulate the way our brains work.  To use a computer to study the brain, scientists have developed models of the brain and how they work with software.

C Elegans. Courtesy of Wikimedia.

C Elegans. Courtesy of Wikimedia.

For medical research, worms are a very simple brain model.  The tiny worm Caenorhabditis elegans has only 302 neurons but exhibits some complex behaviors. When the worm senses food through a variety of sensory neurons, the worm will move forward towards that food source. When the worm’s nose senses a blocking object, the worm will stop, backup and change direction to move around the object or avoid it all together. After successfully simulating the worm’s brain in a more complex environment, the project attempts to build a similar application in a Raspberry Pi robot.

The GoPiGo with a Raspberry Pi was the perfect answer.

The goal of this project was to write a single Python application that could run on a Raspberry Pi and the GoPiGo and be able to traverse its environment, avoiding obstacles, only using a simulated nervous system of the C elgans nematode. This project does not use any programming to stop the GoPiGo robot or make it change direction – only the simulated nervous system guides the robot and creates the behavior that allows the robot to stop and change direction when it encounters an obstacle. This project uses a sonar sensor on the GoPiGo robot to stimulate nose touch sensory neurons and a timing mechanism to activate food sensing neurons to move the robot forward.

C elegans Neuro Map

The C Elegans Neuron map. Courtesty of http://www.connectomeengine.com/

Some Background: C elegans Biology

The C Elegans is one of the most studied animals in science.

The C elegans worm has approximately 1000 cells that make up the entire organism and is the most studied animal in science. 302 of those cells are neurons. Neurons come in basically three types: Sensory, Interneuron and Motor. Sensory neurons are stimulated when conditions in the worm’s environment changes. These include touch, chemical, odor, pain, osmotic, oxygen changes, temperature and mechanical changes such as body pressure. Interneurons connect the sensory and motor neurons and might be thought of as a proto-brain of sorts. Motor neurons connect to the body muscles that are on either side of the worm body.

Many Muscles

Motor neurons connect to muscles to either excite or inhibit. The worm’s neural-motor circuit using excitatory and inhibitory connections gives the worm an undulating movement in that it can contract some muscles while relaxing others, then contract the relaxed muscles while relaxing the ones it just contracted. There are 95 body muscles that run the length of the worm’s body: 24 muscles along the upper left, 23 along the lower left, 24 along the upper right and 24 along the lower right.

It should be noted that this worms nervous system is ideal to simulate because the connections from neuron to neuron and neuron to muscle are well mapped, they never change throughout the life of the worm and are the same from worm to worm. Therefore, the connectomic structure contained on the Python program is the same as every C elegans worm.

Combining Worm and GoPiGo Robot

The project created the connectome of the worm in a Python 2.7 program utilizing the GoPiGo commands for sensory input and motor output. The program essentially does the following to simulate the worm brain:

  • If no other sensory input is happening, stimulate food sensing neurons
  • If an object is within 25cm of the sonar sensor, stimulate nose touch sensory neurons
Neuron

Neuron. Courtesy of Wiki Commons.

Each stimulation of sensory neurons, runs the connectome whereby each sensory neuron has added weights within a dictionary of the entire worms neural structure (i.e. dendriteAccumulate function). After each sensory neuron is activated and weights added, the programs run through all the neurons (i.e. runnconnectome function) and anywhere the accumulated weights of a neuron is greater than a predefined threshold, the neuron fires (i.e. fireNeuron function) and additional weights are added throughout the connectome which include neurons and muscles.

Each time the Connectome is run, muscles, which are part of the same dictionary as the neurons, are accumulated as Right and Left muscle weights (weights for muscles can be negative as well as positive) and the wheels on the robot are activated according to the weighted values.

Each time a neuron or muscle is activated, the weights are set to zero so that accumulation can start again.

The Code

connectome codeThe above section is all boiled down into a simple Python program that can be found on github.  The Python program uses a Postsynaptic dictionary based on the C Elegans Connectome Model.  The code (or model if you will) starts with almost 5000 lines of definitions of neurons.

These definitions make up the brain library, and simulate what each neuron is doing, when.  The “neurons” are all interconnected.

As the GoPiGo wheels around, the Ultrasonic sensor is checked for distance.  If food is detected, this counts as a simulation, 

Nuts and Bolts: Building A Raspberry Pi Robot With a Worm Brain

Step 1:  Build the GoPiGo.  We have step by step instructions on building the GoPiGo here.
Step 2: Build the GoPiGo Servo Controller.  See our building instructions here.
Step 3: Attach the GoPiGo Ultrasonic Sensor.  See our building instructions here.
Step 4: Connect the GoPiGo to the internet.
Step 5: Clone the Github repository to your desktop.

sudo git clone https://github.com/Connectome/GoPiGo

Step 6: Run the python program.

sudo Python GoPiGoConnectome.py

When the program is run, your GoPiGo will start to behave like a worm.   Now with a worms brain, it will start moving around and looking for food!

Worm’s Brain Controls the GoPiGo Robot

To be clear, there is no programming that is directing the robot to stop or rotate a wheel in one direction or another. It is only the collective weighted values being generated from the simulated worm connectome that guides the actions of the robot. It was very difficult to contain the connectome into a single application and make it run on a Raspberry Pi but this is a very good attempt. This is truly a totally autonomous robot that is reacting to its environment through a simulated brain of a nematode.

The Connectome Project wants to encourage others to use the connectome program and try to change the methods to make the program run more efficiently and react better to the environment. Changes to the connectome, however, means you are creating your own simulated nervous system that will differ from the worms nervous system, which might be fun to explore as well.

You can find more information and the Python program on the Connectome Website.

You can see video of the GoPiGo robot running with the simulated connectome here.

This article was originally written by Timothy Busbice (@interintel) of the Connectome project, and adapted by John Cole.