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

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

The neural network simulation was coupled with the physical body & environment 
simulation to achieve closed-loop interaction. Food was at the center of the simulated 
physical environment, acting as an attractor to the C. elegans . The food concentration was 
linearly distributed in the environment. The neural system received currents regarded as 
sensory signals. The amplitude of the currents was proportional to the gradient of food 
concentration. The outputs of the neural network controlled the movements of the body in the 
environment through a reservoir readout weight matrix (see Method 3.2). As the body moved 
in the physical environment, the distance between the body and the food changed, causing the 
food concentration gradient updated and transformed to currents injected into the soma of 
sensory neurons. 
During the interaction of the two sub-models, the simulation time step of the neural network 
was 5/3 ms and that of physical environment simulation was 100 ms. The two systems 
synchronized every 100 ms to update the sensory signals and muscle forces. 
3.2 Reservoir configuration 
To establish the neuron- muscle connection between the neural system and physical body 
muscles, a reservoir computing framework was used. The neural network model acted as the 
non-linear reservoir. The membrane potentials of 80 motor neurons (Supplement Table S5) 
were linearly combined and mapped to 96 muscle forces via an 80 by 96 matrix.  
The r eservoir  was trained using data extracted from a 10-second movement generated in the 
simulated physical environment. The pairs of food concentration and muscle force during the 
movements were used as inputs to the neural network and target outputs of the readout layer, 
respectively. Only the reservoir readout matrix was optimized, while the parameters in the 
neural network model was fixed. 
4 User-friendly Interfaces 
The neural network model consists of ion channel, neuron, and network connection 
modules. The parameter and algorithm settings of each module can be modified 
independently. Parameters were saved in JSON files that are easy to read and modify.  
Code Availability 
The C. elegans neural network simulation was performed with the code written in Python 
3.7 and employing NEURON 8.0.0 24 as a simulation engine. The custom-developed code 
used in this work will be made publicly available in an online repository latest upon journal 
publication. If you wish to obtain the code before then, please contact us. To facilitate better 
evaluation of this article by reviewers, we also provide the code that can be run (we will 
continue to optimize our code details): https://www.dropbox.com/s/ep2yv3rmlp67eex/worm-
simulation-share.zip?dl=0, Please contact us if you would like to have access to the latest 
code before our article is published. 
 
Methods Reference 
1 Hodgkin, A. L. & Huxley, A. F. A quantitative description of membrane current and its 
application to conduction and excitation in nerve. The Journal of physiology  117, 500-
544 (1952). 
2 Nicoletti, M. et al. Biophysical modeling of C. elegans neurons: Single ion currents and 
whole-cell dynamics of AWCon and RMD. PLOS ONE  14, e0218738, 
doi:10.1371/journal.pone.0218738 (2019). 
(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

3 Grove, C. & Sternberg, P. in 18th International C. elegans Meeting. 
4 Gleeson, P., Lung, D., Grosu, R., Hasani, R. & Larson, S. D. c302: a multiscale framework 
for modelling the nervous system of <i>Caenorhabditis elegans</i>. Philosophical 
Transactions of the Royal Society B: Biological Sciences  373, 20170379, 
doi:doi:10.1098/rstb.2017.0379 (2018). 
5 Sheng, K.  et al.  Domain Adaptive Neural Inference for Neurons, Microcircuits and 
Networks. bioRxiv 2022.2010. 2003.510694 (2022). 
6 Cook, S. J.  et al.  Whole-animal connectomes of both Caenorhabditis elegans sexes. 
Nature 571, 63-71, doi:10.1038/s41586-019-1352-7 (2019). 
7 Gray, J. M., Hill, J. J. & Bargmann, C. I. A circuit for navigation in <i>Caenorhabditis 
elegans</i>. Proceedings of the National Academy of Sciences  102, 3184- 3191, 
doi:doi:10.1073/pnas.0409009101 (2005). 
8 Liu, Q., Kidd, P. B., Dobosiewicz, M. & Bargmann, C. I. C. elegans AWA Olfactory 
Neurons Fire Calcium -Mediated All -or-None Action Potentials. Cell 175, 57 -70.e17 
(2018). 
9 Mellem, J. E., Brockie, P. J., Madsen, D. M. & Maricq, A. V. Action potentials contribute to 
neuronal signaling in C. elegans. Nature neuroscience 11, 865-867 (2008). 
10 Liu, P., Chen, B. & Wang, Z.- W. SLO-2 potassium channel is an important regulator of 
neurotransmitter release in Caenorhabditis elegans. Nature communications  5, 5155 
(2014). 
11 Liu, Q., Hollopeter, G. & Jorgensen, E. M. Graded synaptic transmission at the 
Caenorhabditis elegans neuromuscular junction. Proceedings of the National Academy 
of Sciences 106, 10823-10828 (2009). 
12 Shui, Y., Liu, P., Zhan, H., Chen, B. & Wang, Z.- W. Molecular basis of junctional current 
rectification at an electrical synapse. Science Advances  6, eabb3076, 
doi:doi:10.1126/sciadv.abb3076 (2020). 
13 Prinz, A. A., Bucher, D. & Marder, E. Similar network activity from disparate circuit 
parameters. Nature neuroscience 7, 1345-1352 (2004). 
14 Wicks, S. R., Roehrig, C. J. & Rankin, C. H. A dynamic network simulation of the 
nematode tap withdrawal circuit: predictions concerning synaptic function using 
behavioral criteria. Journal of Neuroscience 16, 4017-4031 (1996). 
15 White, J. G., Southgate, E., Thomson, J. N. & Brenner, S. The structure of the nervous 
system of the nematode Caenorhabditis elegans. Philos Trans R Soc Lond B Biol Sci  314, 
1-340 (1986). 
16 Ruach, R., Ratner, N., Emmons, S. W. & Zaslaver, A. The synaptic organization in the 
<i>Caenorhabditis elegans</i> neural network suggests significant local 
compartmentalized computations. Proceedings of the National Academy of Sciences  
120, e2201699120, doi:doi:10.1073/pnas.2201699120 (2023). 
17 Uzel, K., Kato, S. & Zimmer, M. A set of hub neurons and non- local connectivity features 
support global brain dynamics in C.  elegans. Current Biology  32, 3443- 3459, 
doi:https://doi.org/10.1016/j.cub.2022.06.039 (2022). 
18 Chalasani, S. H.  et al.  Dissecting a circuit for olfactory behaviour in Caenorhabditis 
elegans. Nature 450, 63-70 (2007). 
19 Palyanov, A., Khayrulin, S. & Larson, S. D. Three- dimensional simulation of 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

Caenorhabditis elegans body and muscle cells in liquid and gel environments for 
behavioural analysis. Philosophical Transactions of the Royal Society B: Biological 
Sciences 373, 20170376 (2018). 
20 Hu, Y. et al. Tetrahedral meshing in the wild. ACM Trans. Graph. 37, 60:61-60:14 (2018). 
21 Foundation, B. Blender: a 3D Modelling and Rendering Package. , 
<http://www.blender.org> (2012). 
22 Bouaziz, S., Martin, S., Liu, T., Kavan, L. & Pauly, M. Projective dynamics: Fusing 
constraint projections for fast simulation. ACM transactions on graphics (TOG)  33, 1-11 
(2014). 
23 Min, S., Won, J., Lee, S., Park, J. & Lee, J. Softcon: Simulation and control of soft -bodied 
animals with biomimetic actuators. ACM Transactions on Graphics (TOG)  38, 1 -12 
(2019). 
24 Hines, M. L. & Carnevale, N. T. NEURON: a tool for neuroscientists. The Neuroscientist 7, 
123-135 (2001). 
 
(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