MetaWorm: An Integrative Data-Driven Model Simulating <i>C. elegans</i> Brain, Body and Environment Interactions — part 1/6

Cleaned-text code points [0, 15224). Bibliography omitted here; source.md includes it.

MetaWorm: An Integrative Data-Driven Model Simulating C.
elegans Brain, Body and Environment Interactions
Mengdi Zhao1†, Ning Wang1†, Xinrui Jiang1, Xiaoyang Ma1, Haixin Ma1, Gan He1,3, Kai Du1,4, Lei
Ma1,2,3*, Tiejun Huang1,3,4
1 Beijing Academy of Artificial Intelligence, Beijing 100084, China
2 National Biomedical Imaging Center, College of Future Technology, Peking University, Beijing
100871, China
3 National Key Laboratory for Multimedia Information Processing, School of Computer Science,
Peking University, Beijing, 100871, China
4 Institute for Artificial Intelligence, Peking University, Beijing 100871, China
*Corresponding author: Email: malei@baai.ac.cn (Lei Ma)
†These authors contributed equally to this work.
Abstract
The behavior of an organism is profoundly influenced by the complex interplay between its
brain, body, and environment. Existing data-driven models focusing on either the brain or the
body-environment separately. A model that integrates these two components is yet to be developed.
Here, we present MetaWorm, an integrative data-driven model of a widely studied organism, C.
elegans. This model consists of two sub-models: the brain model and the body & environment
model. The brain model was built by multi-compartment models with realistic morphology,
connectome, and neural population dynamics based on experimental data. Simultaneously, the
body & environment model employed a lifelike body and a 3D physical environment, facilitating
easy behavior quantification. Through the closed-loop interaction between two sub-models,
MetaWorm faithfully reproduced the realistic zigzag movement towards attractors observed in C.
elegans. Notably, MetaWorm is the first model to achieve seamless integration of detailed brain,
body, and environment simulations, enabling unprecedented insights into the intricate
relationships between neural structures, neural activities, and behaviors. Leveraging this model,
we investigated the impact of neural system structure on both neural activities and behaviors.
Consequently, MetaWorm can enhance our understanding of how the brain controls the body to
interact with its surrounding environment.
Introduction
The behaviors of an organism are not simply the product of brain activity but rather, emerge
from a dynamic interplay among the brain, body, and environment. To unravel the underlying
neural control mechanisms, it is crucial to develop an integrative simulation that incorporates
detailed models of the brain, body and environment, to both validate theories and make
predictions for biological experiments. Currently, there are specific data-driven models that
simulate either the brain, e.g., the mouse primary visual cortex1, the mouse striatum2, and the rat
somatosensory cortex3, or exclusively the body and environment to reproduce animal behaviors,
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint

such as neuromechanical models for Drosophila4 and rodent5. OpenWorm project6 aimed to
simulate C. elegans years ago, despite its detailed brain model and body model worked separately.
So far, no data-driven model exists that successfully integrates these elements, although such
integration is urgently needed to progress our understanding of neural control mechanisms7.
An integrative data-driven model must meet certain requirements. First, it should incorporate a
biophysically detailed brain model that has similar neural structures and neural activity patterns as
real organism. Secondly, it should consist of a realistic and high-performance body and
environment model that facilitates easy behavior quantification. Thirdly, and most crucially, the
brain model should not only control the body model interacting with the virtual environment, but
also receive the feedback from the body and environment model, establishing a closed-loop
interaction8,9.
C. elegans stands out as an exemplary model for developing such an integrative data-driven
model that bridges brain, body and environment. It has completely mapped morphologies of all
302 neurons10,11 (in adult hermaphrodite), along with the connectome and synapse-level
structure12-14. Recordings of single neural activity15-23, as well as brain-wide neural dynamics18,20,24
are available. Its body is well-reconstructed, consisting of only 95 muscle cells. It also exhibits
easily quantifiable behaviors, such as crawling, swimming and foraging25,26. Therefore, these
simple structures and abundant data provide solid foundations for creating an integrative data-
driven model.
In this study, we present an integrative data-driven model of C. elegans, MetaWorm (Fig. 1).
First, we developed a neural network model (brain model) of a C. elegans foraging neural circuit.
It was built using biophysically detailed compartmental neuronal models, with compartments
under 2 μm in length, encoding neural activity similar to live C. elegans. Second, we developed a
body & environment model of C. elegans. The body model contained 96 muscles and enabled
efficient real-time simulation at 30 frames per second and easy quantification of behaviors. Third,
we established a closed-loop interaction between the brain model and the body-environment
model to simulate C. elegans moving towards an attractor in a zigzag shape. Sensory neurons in
the neural network model were activated by attractor’s concentration in environment. Muscles in
the body model were controlled by motor neurons in the neural network model. Finally, we
performed synthetic perturbations on the neural network model and suggested that neurite or
synaptic/gap junction' absence disrupts global neural dynamics and hampers accurate forward
motion. This highlights the importance of network structure in shaping both network dynamics
and behavior patterns.
MetaWorm is open-source and modular as the brain, body, environment models and their
interactions can be independently modified, improved or extended by the scientific community.
MetaWorm will contribute to a deeper understanding of the intricate relationships between neural
structures, neural activities, and behaviors. This work also provides a valuable framework for
developing brain-body-environment model of other organisms. This innovative approach paves
the way for new avenues of systems biology and has the potential to revolutionize traditional
neural mechanism research.
Results
Constructing a data-driven biophysically detailed neural network model of C. elegans
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint

Our neural network model of C. elegans contained 136 neurons that participated in sensory and
locomotion functions, as indicated by published studies24,27-31. To construct this model, we first
collected the necessary data including neural morphology, ion channel models, electrophysiology
of single neurons, connectome, connection models and network activities (Fig. 2A). Next, we
constructed the individual neuron models and their connections (Fig. 2B). Subsequently, a
biophysically detailed model without functions was established (Fig. 2C). Finally, we optimized
the weights and polarities of the connections to obtain a model that reflected realistic dynamics
(Fig. 2D). An overview of the model construction is illustrated in Figure 2.
To achieve a high level of biophysical and morphological realism in our model, we employed
multi-compartment models to represent individual neurons. The morphologies of neuron models
were constructed based on published morphological data32,33. Soma and neurite sections were
further divided into several segments, where each segment was less than 2 μm in length. We
combined 14 known classes of ion channels (Supplementary Table S1-2)34 in neuron models, and
tuned the passive parameters and ion channel conductance densities by an optimization
algorithm35 to reproduced electrophysiological traces in the experiments36-39. Based on the few
available electrophysiological data, we digitally reconstructed models of five representative
neurons: AWC, AIY ,A V A,RIM and VD5. The I-V curves of our neuron models perfectly match
that in the experiments (Fig. 3). The optimized parameters of neuron models are listed in
Supplementary Table S3.
These five neurons are representative for five different functional group: sensory neuron,
interneuron, command neuron, head motor neuron and body motor neuron. They serve as the
initial pool of digital neuron models to reconstruct other neurons in the neural network model. For
neurons that are not representative neurons, their biophysical parameters were set the same as the
representative neuron models that belonged to the same functional group. The referenced neurons
of all neurons are listed in Supplementary Table S4. This approach allows us to achieve a high
level of biophysical and morphological realism in our C. elegans neural network model with
limited accessible experimental data.
For connections, we first modeled gap junctions as simple ohmic resistances, and synapses as
continuously transmitting synapse, according to published models32,40-43. Then, we developed an
algorithm to determine the number and locations of connections. The number of connections
between two cells was from the cell adjacency matrix10,11 (Fig. 4A). For each connection, we
randomly assigned a distance following the neurite centroids distance distributions of synapse/gap
junction in experiment13 (Fig. 4B). Each connection linked two segments whose distance was
closest to the randomly assigned distance. This approach allowed us to generate connections that
were constrained by experimental connection numbers and distance distributions (Fig. 4C). Figure
4D-F show some examples of the connections between neurons in our neural network model.
Most synapses and gap junctions were located on neurites that were relatively close to each other.
Also, as shown in Fig. 4F, the constructed connections tended to cluster together, which followed
the clustered organization principle in published research13,14.
To determine the polarities of synapses (excitatory or inhibitory) and the connection weights,
we employed a gradient-descend-based algorithm to minimize the mean squared error (MSE)
between simulation results and the optimization target. In this study, our optimization target was a
Pearson correlation matrix of 65 identified neurons in a prior study24, where activity series were
recorded through whole-brain single-cell-resolution Ca2+ imaging. Figure 5A illustrates the
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint

correlation matrices generated from our simulation and the experimental data. These two maps
exhibited similar correlation strengths, whose mean squared error was only 0.076.
To further analyze the optimized neural network model, we conducted principal components
analysis (PCA) on the membrane potential of the 65 identified neurons, involving the calculation
of principal components (PCs) based on the covariance structure in the normalized data (Fig. 5B).
Our analysis unveiled that PC1 exhibits an opposite dynamic to that of PC2 (Fig. 5C). Upon
sorting based on PC1, most neurons controlling forward locomotion (e.g., A VB,VB, DB neurons)
and backward locomotion (e.g., A V A,V A,DA neurons) were distinctly classified into two groups
(Fig. 5B). This indicates that our neural network model accurately captures realistic neural
dynamical relationships, and the dynamics of neurons encode functions similar to those observed
in real C. elegans, to some extent.
Constructing a high-performance body & environment model of C. elegans
Next, we developed the body & environment model of the C. elegans. Our primary
contributions are: 1) modelling the soft body, muscles, and solving soft body deformation, 2)
creating the 3D simulation environment and solving soft body-fluid interaction, 3) proposed a
novel reference coordinate system for behavior analysis. The framework of this model is
illustrated in Figure 6A and B.
The body model was built with tetrahedral mesh, including 984 vertices, 3341 tetrahedrons and
1466 triangles on the body surface (Fig. 6C). Also, it had four muscle strings: ventral right (VR),
ventral left (VL), dorsal right (DR) and dorsal left (DL). Each string had 24 muscle cells arranged
from head to tail (Fig. 6D). Tetrahedrons were controlled by their near muscle strings. The
corresponding strings were visualized with different colors in Figure 6E. We used Finite Element
Method (FEM) solver to compute positions and velocities of all vertices on the deformable body
at any given time. In the computation, the solver used 4558 muscle constraints and 3341 corotated
elasticity constraints. Thus, our soft-body simulation engaged a sum of 7,899 mechanical
constraints. After the geometry construction, we need to solve the body deformation efficiently. In
our model, we selected a real-time, highly robust, and accurate approach named projective
dynamics as the FEM solver for calculation. The solved body state was visualized in Fig.6F.
We constructed a large 3D fluid simulation environment, where the body, foods were embedded.
This environment was essentially a large cube, with each edge equating to approximately 1200
times the length of a C. elegans. The mechanic of the body movement in fluid is essentially a soft
body-fluid coupling problem. To simplify this problem, we only calculated the thrust force (Fig.
6G) and drag force (Fig. 6H) on the body surface44. This simplification allowed for the simulation
of a much larger space and improved computational efficiency. To achieve forward locomotion
behavior, we used projective dynamics to calculate real-time bending waves that propagated from
head to tail. The interaction between these bending waves and the fluid generated impetus for
forward locomotion (Fig.6I).
C. elegans is an animal with soft body that exhibits special patterns during locomotion, wherein
every point on its body oscillates continuously. Therefore, it is difficult to quantify the trajectory
and body state during locomotion. Here, we proposed an effective and simple method to measure
C. elegans locomotion. The main idea of this method is to establish a numerically stable
coordinate system relative to the body itself, named Target Body Reference Coordinate System
(TBRCS) (Fig. 7A). First, we defined the target body, standard body and Standard Body
(which was not certified by peer review) is the author/funder. All rights reserved. No reuse allowed without permission. 
The copyright holder for this preprintthis version posted March 10, 2024. ; https://doi.org/10.1101/2024.02.22.581686doi: bioRxiv preprint