{"id":18420604,"url":"https://github.com/openworm/c302","last_synced_at":"2025-04-07T15:06:18.894Z","repository":{"id":31449972,"uuid":"121283648","full_name":"openworm/c302","owner":"openworm","description":"The c302 framework for generating multiscale network models of C. elegans","archived":false,"fork":false,"pushed_at":"2024-09-03T09:57:31.000Z","size":48836,"stargazers_count":105,"open_issues_count":16,"forks_count":21,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-09-29T20:30:40.423Z","etag":null,"topics":["openworm","simulation"],"latest_commit_sha":null,"homepage":"https://www.opensourcebrain.org/projects/c302","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openworm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-12T18:16:09.000Z","updated_at":"2024-09-21T11:07:06.000Z","dependencies_parsed_at":"2024-10-26T04:36:38.648Z","dependency_job_id":null,"html_url":"https://github.com/openworm/c302","commit_stats":{"total_commits":215,"total_committers":9,"mean_commits":23.88888888888889,"dds":"0.26046511627906976","last_synced_commit":"c94491d0f1858184c042af92c41d0b17b0a5432e"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openworm%2Fc302","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openworm%2Fc302/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openworm%2Fc302/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openworm%2Fc302/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openworm","download_url":"https://codeload.github.com/openworm/c302/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675596,"owners_count":20977376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openworm","simulation"],"created_at":"2024-11-06T04:22:24.572Z","updated_at":"2025-04-07T15:06:18.865Z","avatar_url":"https://github.com/openworm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## The c302 modelling framework for *C. elegans*\n\n[![Continuous builds](https://github.com/openworm/c302/actions/workflows/ci.yml/badge.svg)](https://github.com/openworm/c302/actions/workflows/ci.yml) [![Non OMV tests](https://github.com/openworm/c302/actions/workflows/non_omv.yml/badge.svg)](https://github.com/openworm/c302/actions/workflows/non_omv.yml)\n\nc302 is a framework for generating network models in NeuroML 2 based on *C. elegans* connectivity data. It is primarily intended as a way to generate neuronal networks at multiple levels of detail for the [OpenWorm project](http://www.openworm.org). To see how c302 relates to other OpenWorm subprojects click on the image below:\n\n\u003cp align=\"center\"\u003e\u003ca href=\"OpenWormOverview.md\"\u003e\u003cimg width=\"200\" alt=\"c302_in_overview\" src=\"https://user-images.githubusercontent.com/1573896/44876490-42fca100-ac6f-11e8-95ab-76dc8a2d80e1.png\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n![c302 structure](https://raw.githubusercontent.com/openworm/CElegansNeuroML/master/CElegans/pythonScripts/c302/images/c302.png)\n\nIt uses information on the synaptic connectivity of the network (from [here](https://github.com/openworm/c302/blob/master/c302/data)) and uses [libNeuroML](https://github.com/NeuralEnsemble/libNeuroML) to generate a network in valid NeuroML, which can be run in [jNeuroML](https://github.com/NeuroML/jNeuroML) or [pyNeuroML](https://github.com/NeuroML/pyNeuroML).\n\n**The c302 paper is out!**\n\n*c302: a multiscale framework for modelling the nervous system of Caenorhabditis elegans* Padraig Gleeson, David Lung, Radu Grosu, Ramin Hasani, Stephen D. Larson, [Phil. Trans. R. Soc. B 2018 373 20170379](http://rstb.royalsocietypublishing.org/content/373/1758/20170379); DOI: 10.1098/rstb.2017.0379.\n\n\n### To install \u0026 test\n\nThe full set of dependencies for c302 can be installed with the following (see also the [ci.yml](https://github.com/openworm/c302/blob/master/.github/workflows/ci.yml) and [non_omv.yml](https://github.com/openworm/c302/blob/master/.github/workflows/non_omv.yml) workflow files):\n\n```console\ngit clone https://github.com/openworm/c302.git\ncd c302\npip install .\n\n# The following can only be run on Mac and Linux. Note: c302 can be run without ownmeta fully installed\nowm bundle remote --user add ow 'https://raw.githubusercontent.com/openworm/owmeta-bundles/master/index.json'\n```\n\nThis will install c302 as well as [pyNeuroML](https://github.com/NeuroML/pyNeuroML) and [owmeta](https://github.com/openworm/owmeta).\n\nFor Windows users a  virtual environment must be generated with Python 3.10 as any newer versions do not currently support owmeta.\n\nTo run the test.sh script, the Neuron simulator is also required, and should be installed as described [here](https://www.neuron.yale.edu/neuron/download) (On Mac and Linux it can be installed with `pip install neuron`). \n\nFor Linux users, additional dependencies (OpenJDK 19 and Graphviz) are required to run the usage examples:\n    \n    sudo apt-get install openjdk-19-jdk graphviz\n\nPlease note that Python3 is also required to run both the test.sh script and the Usage Examples. For convenience on Linux, it is recommended to install python-is-python3 prior to running the test.sh script.\n\n    sudo apt-get install python-is-python3\n\n#### Quick test\n\nTo ensure everything is set up correctly try:\n\n1) Regenerate the NeuroML \u0026 LEMS files for one instance of the model:\n\n       python c302/c302_Pharyngeal.py B  # generate pharyngeal network (see fig. above) using parameter set B\n\n2) Run a simulation with pyNeuroML:\n\n       pynml examples/LEMS_c302_B_Pharyngeal.xml      \n\nTo test all of the working features of the framework run [test.sh](https://raw.githubusercontent.com/openworm/CElegansNeuroML/master/CElegans/pythonScripts/c302/test.sh):\n\n     ./test.sh\n\n### Docker image\n\nc302 is included in the **Docker** image which contains the complete OpenWorm simulation stack. Click on the image below for more details.\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://github.com/openworm/OpenWorm/blob/master/README.md#quickstart\"\u003e\u003cimg width=\"400\" alt=\"Worm Crawling\" src=\"https://raw.githubusercontent.com/openworm/OpenWorm/master/img/worm-crawling.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n### Usage Examples\n\n#### 1a) Run standard examples with pyNeuroML\n\nThere are a number of [example models](https://github.com/openworm/c302/tree/master/examples) included with the standard distribution. These consist of: A) generated NeuroML 2 network description file ([example](https://github.com/openworm/c302/blob/master/examples/c302_A_IClamp.net.nml)), containing the definitions of the cells to use (e.g. **iafCell** for an integrate and fire cell), any inputs (e.g. **pulseGenerator**) as well as the **populations**, **projections** and **inputLists** contained within the **network** (for a full description of the NeuroML elements see [here](https://www.neuroml.org/NeuroML2CoreTypes/Networks.html)); and B) a LEMS simulation file ([example](https://github.com/openworm/c302/blob/master/examples/LEMS_c302_A_IClamp.xml)) describing how long to simulate, the timestep and what to plot/record.\n\n       # generate 2 neurons \u0026 1 muscle with current inputs using parameter set A\n       pynml examples/LEMS_c302_A_IClamp.xml      \n\n       # generate full scale network using parameter set C\n       pynml examples/LEMS_c302_C_Full.xml    \n\n       # generate pharyngeal network using parameter set B\n       pynml examples/LEMS_c302_B_Pharyngeal.xml\n\nScreenshots of a simulation with pyNeuroML of c302_B_Pharyngeal are shown below (left: membrane potential of 20 cells, right: \"activity\" of 20 cells - a value from 0-1 showing time smoothed activity of each cell):\n\n![c302_B_Pharyngeal](https://raw.githubusercontent.com/openworm/c302/master/images/c302_B_Pharyngeal.png)\n\n#### 1b) Run standard examples with Neuron\n\nThe models can also be run using the Neuron simulator.  This should be installed as outlined [here](https://www.neuron.yale.edu/neuron/download). Note: running c302 with Neuron is not currently supported on Windows.\n\n       cd examples\n       pynml LEMS_c302_A_IClamp.xml -neuron   # Generate the Neuron files (Python/hoc/mod)\n       nrnivmodl                              # Compile the mod files (used for cell/ion channel definitions)\n       nrngui LEMS_c302_A_IClamp_nrn.py       # Run the main Python file for the simulation using Neuron\n\nNote: models with the D parameter set can only be run using Neuron (not pyNeuroML), simnce they consist of multicompartmental Neurons, e.g.\n\n       pynml LEMS_c302_D_Pharyngeal.xml -neuron  \n       nrnivmodl                         \n       nrngui LEMS_c302_D_Pharyngeal_nrn.py\n\nThis produces the following (graph on top is [Ca2+], bottom is membrane potential; 3D view on right can be produced by selecting in the Neuron main menu: Graph -\u003e Shape plot)\n\n![Neuron](https://raw.githubusercontent.com/openworm/c302/master/images/Neuron.png)\n\n\n#### 2) Use command line interface to create new network\n\nThe **c302** command line utility can be used to generate customised networks of varying size, with different cells stimulated, of varying duration from the command line:\n\n    c302 MyNetwork parameters_C -cells [\"AVBR\",\"VD3\"] -cellstostimulate [\"AVBR\"] -paramoverride {\"unphysiological_offset_current\":\"2.9pA\"} -duration 300\n\nThis will create a NeuroML 2 file and a LEMS file to execute it, containing 2 cells, stimulating 1 of them, and with a duration of 300 ms. It can be run with:\n\n    pynml LEMS_MyNetwork.xml\n\nThis produces two plots: One is neuron activity, measured as calcium ion concentration. You will likely need to click \"Frame\" in the \"View\" menu to scale the plot.\n\n![activity](images/LEMS_MyNetwork-activity.png)\n\n\nThe other shows membrane potential for each neuron in the network.\n\n![membrane potential](images/LEMS_MyNetwork-membranePotential.png)\n\n\nTo see the structure of the network, use pyNeuroML (please note that Graphviz is required):\n\n    pynml MyNetwork.net.nml -graph 4c  # Try other options like 1, 2f, 5c for varying levels of detail\n\n\n![MyNetwork](https://raw.githubusercontent.com/openworm/c302/master/images/MyNetwork.png)\n\n\nMore options for using the **c302** command can be found with\n\n    c302 -h\n\n\n#### 3) Change parameters in a file\n\nTo investigate how the behaviour of a model changes when parameters are varied, it is possible to change the parameters in the parameters_X.py files and regenerate.\n\nFor example in [parameters_C.py](https://github.com/openworm/c302/blob/master/c302/parameters_C.py) there are lists of parameters like:\n\n```python\nself.add_bioparameter(\"muscle_leak_cond_density\", \"5e-7 S_per_cm2\", \"BlindGuess\", \"0.1\")\nself.add_bioparameter(\"neuron_leak_cond_density\", \"0.005 mS_per_cm2\", \"BlindGuess\", \"0.1\")\nself.add_bioparameter(\"leak_erev\", \"-50 mV\", \"BlindGuess\", \"0.1\")\n```\n\nTo change the model behaviour alter one of these values, e.g.\n\n```python\nself.add_bioparameter(\"neuron_leak_cond_density\", \"0.02 mS_per_cm2\", \"BlindGuess\", \"0.1\")\n```\n\nand look at the behaviour afterwards (note the package needs to be reinstalled)\n\n    sudo python setup.py install           # reinstall package after change\n    python c302/c302_IClamp.py C           # regenerate c302_C_IClamp\n    pynml examples/LEMS_c302_C_IClamp.xml  # run simulation\n\nThe plots below show the neuron's membrane potential on application of 6 increasing pulses of current before (left) and after (right) the change, indicating how increasing the leak conductance removes the spiking:\n\n\u003cp\u003e\u003cimg src=\"https://raw.githubusercontent.com/openworm/c302/master/images/changePre.png\" width=400/\u003e \u003cimg src=\"https://raw.githubusercontent.com/openworm/c302/master/images/changePost.png\" width=400/\u003e\u003c/p\u003e\n\n#### 4) Adding a new input type to NeuroML model\n\nThe structure of the model generated can be altered by modifying the NeuroML model returned in the c302_XXX.py script.\nAs an example, say we want to add a sine wave current to the Muscles network (specified by [c302_Muscles.py](https://github.com/openworm/c302/blob/master/c302/c302_Muscles.py)), as opposed to the steady current clamp input. This can be achieved by setting the \"unphysiological_offset_current\" to zero:\n\n```python\nparams.set_bioparameter(\"unphysiological_offset_current\", \"0pA\", \"Disabling offset current\", \"0\")\n```\n\nand (after calling c302.generate()) adding the new NeuroML element for the current and adding the input to a cell:\n\n```python\n# Import from libNeuroML      \nfrom neuroml import SineGenerator, InputList, Input\nimport neuroml.writers as writers\n\n# Create the sine wave current generator \u0026 add to NeuroML document\nsw_input = SineGenerator(id='NewSineWaveInput',\n                      delay='100ms',\n                      phase='0',\n                      duration='800ms',\n                      amplitude='4.5pA',\n                      period='200ms')\n\nnml_doc.sine_generators.append(sw_input)\n\n# Which cell to stimulate\ncell = 'AVBL'\n\n# create an InputList and add one Input to that cell\ninput_list = InputList(id=\"Input_%s_%s\" % (cell, sw_input.id), component=sw_input.id, populations='%s' % cell)\ninput_list.input.append(Input(id=0, target=\"../%s/0/GenericNeuronCell\"%cell, destination=\"synapses\"))\nnml_doc.networks[0].input_lists.append(input_list)\n\n# Write over network file created already...\nnml_file = target_directory+'/'+reference+'.net.nml'\nwriters.NeuroMLWriter.write(nml_doc, nml_file)\n```\n\nThese changes are made in [c302_MusclesSine.py](https://github.com/openworm/c302/blob/master/c302/c302_MusclesSine.py)) and can be run with:\n\n    python c302/c302_MusclesSine.py C\n    pynml examples/LEMS_c302_C_MusclesSine.xml\n\nMembrane potential of neurons (left; stimulated AVBL cell in green) and muscles (right) shown below:\n\n![sine](https://raw.githubusercontent.com/openworm/c302/master/images/sine.png)\n\nOther types of NeuroML input elements are defined [here](https://www.neuroml.org/NeuroML2CoreTypes/Inputs.html)\nand examples are shown [here](https://github.com/NeuroML/NeuroML2/blob/master/examples/NML2_Inputs.nml).\n\n\n#### 5) View and execute the models on Open Source Brain\n\nThe Github repository for c302 is linked to a project on Open Source Brain: http://www.opensourcebrain.org/projects/c302. This allows exploration of the generated NeuroML 2 networks through the Geppetto enabled OSB 3D Explorer.\n\nTo see a list of the networks which can be visuaised, click on the **More** button on the top right of the page. As an example, the Pharyngeal network with parameter set D can be selected (c302_D_Pharyngeal.net.nml in the Network list, direct link [here](http://www.opensourcebrain.org/projects/c302/models?explorer=https%253A%252F%252Fraw.githubusercontent.com%252Fopenworm%252Fc302%252Fmaster%252Fexamples%252Fc302_D_Pharyngeal.net.nml)).\n\nThe initial view of the network is shown on the left below.\n\n\u003cp\u003e\u003cimg src=\"https://raw.githubusercontent.com/openworm/c302/master/images/pharDpre.png\" width=400/\u003e \u003cimg src=\"https://raw.githubusercontent.com/openworm/c302/master/images/pharDpost.png\" width=400/\u003e\u003c/p\u003e\n\nTo get the view on the right:\n- change the background to white by clicking the paintbrush icon (bottom icon on left)\n- open the connectivity matrix (Connectivity button, top left) showing the connections present between cells in an adjacency matrix\n- press Connectivity button again and select Force-directed layout\n- Run a simulation of the network\n    - Persist project so simulations can be run (star on top middle). You will need to have [signed up for OSB](http://www.opensourcebrain.org/account/register) \u0026 logged in!\n    - Press Run button; set duration to 0.4 seconds; press Submit\n    - When dialog appears asking what to record, select all membrane potentials at somas. Simulation will be set running.\n- After circle on Experiments tab has turned green, plot some of the recorded traces:\n    - press the Control Panel icon (four horizontal lines, forth icon from botton on left)\n    - show the list of state variables: x\u003csup\u003e2\u003c/sup\u003e button on top of this dialog. Ensure target button is selected (first of four buttons on right) to only show recorded variables\n    - all recorded variables are shown, e.g. c302_D_Pharyngeal.I1L[0].Seg0_soma_0_0.v: membrane potential of soma in cell I1L. select which to plot with icons on right\n- Replay the simulation:\n    - use the time varying voltage of cells to color the corresponding 3D objects: Results -\u003e Apply voltage colouring to morphologies\n    - open the dialog for the simulation time: Results -\u003e Show simulation time\n    - replay the simulation: Results -\u003e Play step by step (10x)\n\nIt is also possible to view and analyse other configurations, e.g. [c302_D_Full](http://www.opensourcebrain.org/projects/c302/repository/revisions/master/show/examples?explorer=https%253A%252F%252Fraw.githubusercontent.com%252Fopenworm%252Fc302%252Fmaster%252Fexamples%252Fc302_D_Full.net.nml):\n\n![c302_D_Full](https://raw.githubusercontent.com/openworm/c302/master/images/c302_D_Full.png)\n\n### Comparing activity across scales/parameter sets\n\nThis page shows a set of generated simulations at each of the subnetwork/parameter set configurations, and\nprovides a quick overview of the activity of the different instances of c302:\n\n\u003ca href=\"https://github.com/openworm/c302/blob/master/examples/summary/README.md\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/openworm/c302/master/images/activity.png\" alt=\"activity\"  height=\"250\"/\u003e\u003c/a\u003e\n\n**Note that c302 is still in active development and not all of the configurations are producing physiologically realistic results.**\n\n### Background info: Understanding how c302_Full.py works\n\nOverview of the files and packages used in the framework:\n\n\u003ca href=\"https://docs.google.com/drawings/d/1urLRCe--ymaFTevRWp-etS06E9Rl82b627lC4RmUumI/edit?usp=sharing\"\u003e\u003cimg src=\"https://docs.google.com/drawings/d/1urLRCe--ymaFTevRWp-etS06E9Rl82b627lC4RmUumI/pub?w=1307\u0026amp;h=712\"\u003e\u003c/a\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenworm%2Fc302","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenworm%2Fc302","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenworm%2Fc302/lists"}