BAAIWorm, live

A model C. elegans crawls on agar toward food. 136 neurons with their real shapes and connections drive 96 muscles in a soft body. It smells the food at its nose and steers the way real worms do. Your browser computes all of it, every step.

Click the agar to move the food. Drag to look around. Press Neurons to see the circuit inside the body, colored by voltage, and hover a dot to name a cell.

0.0 s——
———

Muscles, head → tail

Motor neurons, last 30 s

−30 s−60 mV … −20 mVnow

Smell at the nose, last 30 s

—reversal · omega turn—

Cut the wiring

The gait needs both. With the gap junctions at half strength, the worm hardly moves.

Loading…

How it works

This page runs BAAIWorm (Zhao et al., Nature Computational Science 2024), a model of C. elegans that connects a detailed brain to a soft body in water. The original runs on a Linux workstation with NEURON and a CUDA viewer. Here both halves are new code, compiled to WebAssembly, and checked against the original's own data.

BAAIWorm swims and does not find food. On this page the same brain and body crawl on agar and find food. The parts that make this possible are ours, not BAAIWorm's. They are described under Crawling on agar and Finding food, with the measurements they were fit to.

The brain

Check: driven by the same input, it matches the motor-neuron voltages that NEURON recorded for BAAIWorm to within 0.0001 mV over 23.8 s, for all 80 motor neurons.

Brain to muscles

Every 100 ms, the mean voltage of 80 motor neurons goes through BAAIWorm's fitted 80 × 96 readout. The result is the activation of 96 muscles: 24 along each of the four muscle quadrants.

The body

Check: in water, given the same muscle signals, no vertex of this body is more than 0.0000002 units from the same vertex in BAAIWorm's own body code during 20 s. (The worm is 0.63 units long, so 1 mm = 0.63 units.) The page crawls on a symmetric mesh of its own; see below.

The skin

What you see is a drawn surface, not the simulation mesh. It is a smooth tube of 21,600 vertices that follows the mesh's outline, with a rounded nose and a tail that narrows to a point. Inside it are the organs that show through a real worm's cuticle: the pharynx with its two bulbs and the grinder, the intestine, and eggs on both sides of the vulva (positions from WormAtlas). Each vertex is fixed in one tetrahedron of the mesh, so it bends with the body. The shading copies transmitted light through a dissecting microscope: the edges are dark where the light bends, the middle is clear, and the cuticle has fine rings (annuli) and a ridge along each side (alae). The physics does not see any of this.

The whole loop, against the original

BAAIWorm's own code also runs here, outside the browser: its NEURON model and its SoftCon body, built without its CUDA viewer. Started the same way, the two runs give the same muscle signals to within 0.0001 at every step for 20 s (the range is 0 to 0.8). For the first 10 s, no vertex of the two bodies is more than 0.02 units apart (3% of the body length). Then the small differences in the brain grow, as they do between any two runs of a swimming body, and the paths separate.

The input

15 sensory neurons get a current clamp. Here it plays the 2 s pattern that BAAIWorm's readout was fit on. That is the pattern of the original's own demo, and it sets the rhythm of the gait. In the paper, this current comes from the change in odor at the head. That closed loop also runs here, and we ran it in BAAIWorm's own code too. It does not find food. In 100 runs with the food 2 units away in different directions, after 60 s the worm was no closer to its own food than to the food of the other runs. The reason is in the input: each step's change in odor is scaled by the range of the last 11 changes, so swimming toward the food and swimming away from it at the same speed give the same current. The readout was also fit to one forward gait, not to turning. The paper shows one closed-loop run and does not test reaching food.

Crawling on agar (ours)

Real worms are studied on agar plates, where they crawl on their side in a shallow groove. Three changes put BAAIWorm's worm on agar:

This pageReal worms on agar
Undulation0.50 Hz0.30 Hz (Fang-Yen et al. 2010); 0.55 Hz (Sawin et al. 2000)
Wavelength0.60 body lengths0.65 (Fang-Yen et al. 2010)
Speed0.15 mm/s0.12–0.15 mm/s (Iino & Yoshida 2009; Pierce-Shimomura et al. 1999)

Finding food (ours)

The food is a lawn of bacteria. Around it the attractant forms a hill: 2 mM on the open plate, rising to 6 mM at the food, about 1 cm wide. This is the radial gradient of Pierce-Shimomura et al. (1999). The worm senses the concentration at its nose. A layer between the brain's muscle signals and the body steers with the two strategies that real worms use, at the rates measured in them:

The brain keeps making the forward gait. It does not make these decisions. Making them inside the circuit is our next step.

Test. We repeated Pierce-Shimomura's assay: worms start 22 mm from the peak, at 48 different headings, and we count how many reach the 5 mm zone around it within 20 minutes.

Reached the peak zonePierce-Shimomura et al. 1999
Both strategies73% (35 of 48)56–60%
No gradient (control)6% (3 of 48)8.3%
Pirouettes only58% (14 of 24)—
Weathervaning only17% (4 of 24)—

The difference from the control is clear (Fisher's exact test, p = 8×10-12). In this shallow gradient, the pirouettes do most of the work, as Pierce-Shimomura et al. found (p = 3×10-6 against the control). Weathervaning alone does not differ clearly from the control (p = 0.2). At the start the gradient is only about 0.08 mM/mm, so Iino and Yoshida's gain curves the path by about 1°/mm, much less than the random wander. Their plates had steeper salt gradients. Near the food the gradient is steeper and weathervaning helps more: worms that reach the zone take 7 minutes (median) with both strategies, against 10 minutes with pirouettes only.

Cutting the wiring

The sliders scale the strength of every chemical synapse or every gap junction. At 0% every connection of that kind is gone, as in the paper's experiments that removed them. Weaker connections in between are this page's addition. On agar the intact worm crawls forward at 0.135 body lengths per second. With the gap junctions at half strength it almost stops (0.008). With them gone, or with the chemical synapses at half strength, it drifts backward. With no chemical synapses it does not move forward. The readout was fit to the intact circuit, so this shows the effect of the cut. It does not show how a real worm adapts.

What is not real