# c302 **Repository Path**: forwardinglei/c302 ## Basic Information - **Project Name**: c302 - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-15 - **Last Updated**: 2025-02-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## The c302 modelling framework for *C. elegans* [](https://github.com/openworm/c302/actions/workflows/ci.yml) [](https://github.com/openworm/c302/actions/workflows/non_omv.yml) c302 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:
 It 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). **The c302 paper is out!** *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. ### To install & test The 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): ```console git clone https://github.com/openworm/c302.git cd c302 pip install . # The following can only be run on Mac and Linux. Note: c302 can be run without ownmeta fully installed owm bundle remote --user add ow 'https://raw.githubusercontent.com/openworm/owmeta-bundles/master/index.json' ``` This will install c302 as well as [pyNeuroML](https://github.com/NeuroML/pyNeuroML) and [owmeta](https://github.com/openworm/owmeta). For Windows users a virtual environment must be generated with Python 3.10 as any newer versions do not currently support owmeta. To 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`). For Linux users, additional dependencies (OpenJDK 19 and Graphviz) are required to run the usage examples: sudo apt-get install openjdk-19-jdk graphviz Please 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. sudo apt-get install python-is-python3 #### Quick test To ensure everything is set up correctly try: 1) Regenerate the NeuroML & LEMS files for one instance of the model: python c302/c302_Pharyngeal.py B # generate pharyngeal network (see fig. above) using parameter set B 2) Run a simulation with pyNeuroML: pynml examples/LEMS_c302_B_Pharyngeal.xml To test all of the working features of the framework run [test.sh](https://raw.githubusercontent.com/openworm/CElegansNeuroML/master/CElegans/pythonScripts/c302/test.sh): ./test.sh ### Docker image c302 is included in the **Docker** image which contains the complete OpenWorm simulation stack. Click on the image below for more details. ### Usage Examples #### 1a) Run standard examples with pyNeuroML There 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. # generate 2 neurons & 1 muscle with current inputs using parameter set A pynml examples/LEMS_c302_A_IClamp.xml # generate full scale network using parameter set C pynml examples/LEMS_c302_C_Full.xml # generate pharyngeal network using parameter set B pynml examples/LEMS_c302_B_Pharyngeal.xml Screenshots 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):  #### 1b) Run standard examples with Neuron The 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. cd examples pynml LEMS_c302_A_IClamp.xml -neuron # Generate the Neuron files (Python/hoc/mod) nrnivmodl # Compile the mod files (used for cell/ion channel definitions) nrngui LEMS_c302_A_IClamp_nrn.py # Run the main Python file for the simulation using Neuron Note: models with the D parameter set can only be run using Neuron (not pyNeuroML), simnce they consist of multicompartmental Neurons, e.g. pynml LEMS_c302_D_Pharyngeal.xml -neuron nrnivmodl nrngui LEMS_c302_D_Pharyngeal_nrn.py This 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 -> Shape plot)  #### 2) Use command line interface to create new network The **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: c302 MyNetwork parameters_C -cells ["AVBR","VD3"] -cellstostimulate ["AVBR"] -paramoverride {"unphysiological_offset_current":"2.9pA"} -duration 300 This 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: pynml LEMS_MyNetwork.xml This 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.  The other shows membrane potential for each neuron in the network.  To see the structure of the network, use pyNeuroML (please note that Graphviz is required): pynml MyNetwork.net.nml -graph 4c # Try other options like 1, 2f, 5c for varying levels of detail  More options for using the **c302** command can be found with c302 -h #### 3) Change parameters in a file To 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. For example in [parameters_C.py](https://github.com/openworm/c302/blob/master/c302/parameters_C.py) there are lists of parameters like: ```python self.add_bioparameter("muscle_leak_cond_density", "5e-7 S_per_cm2", "BlindGuess", "0.1") self.add_bioparameter("neuron_leak_cond_density", "0.005 mS_per_cm2", "BlindGuess", "0.1") self.add_bioparameter("leak_erev", "-50 mV", "BlindGuess", "0.1") ``` To change the model behaviour alter one of these values, e.g. ```python self.add_bioparameter("neuron_leak_cond_density", "0.02 mS_per_cm2", "BlindGuess", "0.1") ``` and look at the behaviour afterwards (note the package needs to be reinstalled) sudo python setup.py install # reinstall package after change python c302/c302_IClamp.py C # regenerate c302_C_IClamp pynml examples/LEMS_c302_C_IClamp.xml # run simulation The 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:


**Note that c302 is still in active development and not all of the configurations are producing physiologically realistic results.**
### Background info: Understanding how c302_Full.py works
Overview of the files and packages used in the framework: