Skip to content

zhongyuchen/digital-twin-c-elegans

Repository files navigation

digital-twin-c-elegans

[Mathematics 2023] A Connectome-Based Digital Twin Caenorhabditis elegans Capable of Intelligent Sensorimotor Behavior

https://doi.org/10.3390/math11112442

citation

@article{chen2023connectome,
  title={A Connectome-Based Digital Twin Caenorhabditis elegans Capable of Intelligent Sensorimotor Behavior},
  author={Chen, Zhongyu and Yu, Yuguo and Xue, Xiangyang},
  journal={Mathematics},
  volume={11},
  number={11},
  pages={2442},
  year={2023},
  publisher={MDPI}
}

prerequisites

  • python==3.8
  • pytorch==1.8.0
  • tensorboard
  • install gym-worm and its dependencies

installation

  • install the project in editable mode from local project path pip install -e .

mathematical models of locomotion

  • computational_model: chemotaxis with behaviors including forward, pirouette, weathervane and random walk
  • forward: forward sinusoidal movement
  • tap: tap-withdrawal composing of forward, backward and stochastic turning behaviors

data

  • concat: concatenate torch.utils.data.TensorDataset
  • subset.RandomSubset: sample a random subset
  • subset.FilterSubset: sample a subset with higher chemotaxis index
  • split: split a time sequence
  • chemotaxis: create a dataset of chemotaxis locomotion
  • simulation.SimulationSample: generate one simulation sample
  • simulation.SimulationDataset: do parallel simulations by multiprocessing and collect the samples

networks

ncp

how to use multiple GPUs using torch.nn.DataParallel

  • DataParallel tutorial: https://pytorch.org/tutorials/beginner/blitz/data_parallel_tutorial.html
  • All manually defined parameters need to be registered, so that they can be transferred along with the module to any devices.
  • torch.nn.ParameterDict can register dict of parameters, but it doesn't support DataParallel.
  • In torch.nn.Module, register parameters one by one with self.register_parameter(name, param), and access param directly with self.name.
  • save DataParallel models by: torch.save(model.module.state_dict(), PATH)

usage

  • run simulation: python sim.py
  • generate simulation data: python data.py
  • preprocess data: python ncp_data.py
  • train and test network: python ncp.py
  • online test the trained network: python ncp_online.py

TensorBoard

  • check TensorBoard log: tensorboard --logdir=runs --host=10.176.50.34 --port=6006
  • local: tensorboard --logdir=runs

Server

  • shut down after python train.py; shutdown
  • shut down if the result is successful python train.py && shutdown
  • count files: ls -l | grep "^-" | wc -l

About

[Mathematics 2023] A Connectome-Based Digital Twin Caenorhabditis elegans Capable of Intelligent Sensorimotor Behavior

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages