Creating NeuroML models¶
This page is currently a work in progress. Please see the related issue here: https://github.com/NeuroML/Documentation/issues/39
Writing models from scratch using Python NeuroML tools¶
Converting models from NEURON to NeuroML¶
Model simulations written using the NEURON simulator can be converted to NeuroML using the pyNeuroML API:
from pyneuroml.neuron import export_to_neuroml2 .. .. export_to_neuroml2("test.hoc", "test.morphonly.cell.nml", includeBiophysicalProperties=False)
Converting conductance based cell models to NeuroML¶
This section needs improvements, verfication, and re-writing to make it easier to follow. Related issue: https://github.com/NeuroML/Documentation/issues/31
Create an initial version in NeuroML 2¶
Create LEMS*.xml (example) with *.net.nml (example) and *.cell.nml (example) - for a cell with only a soma (don’t try to match a multi-compartmental cell with channels to the original at this first stage)
Start off with only passive parameters (capacitance, ax resistance and 1 leak current) set; gradually add channels as in 3); apply current pulse and save soma membrane potential to file
*nmlfiles are valid
jnml;visually compare behaviour with original simple script from the previous section)
Install NEURON; ensure
Commit LEMS/NeuroML code to GitHub
Restructure/annotate/comment channel files in original model to be as clear as possible and ideally all in the same overall structure (see mod files here).
(Optional) Create a (Python) script/notebook which contains the core activation variable expressions for the channels; this can be useful to restructure/test/plot/alter units of the expressions before generating the equivalent in NeuroML (example)
pynml-channelanalysisto generate similar plots for your NeuroML based channels as your mod channels; these can easily be plotted for adding to your GitHub repo as summary pages (example1, example2).
Create a script to load the output of mod analysis and nml analysis and compare the outputs (example).
Compare single compartment cell with channels¶
Start by comparing passive soma example in original to passive NeuroML version
Gradually test cell with passive conductance and each channel individually. Plot v along with rate variables for each channel & compare how they look during current pulse (example in NEURON vs example in NeuroML and LEMS)
jnmlfirst, then in Neuron with
Add OMV tests¶
Optional, but recommended.
This step is optional, but recommended.
Add OMV tests to native code (example), e.g. test the spike times of cell when simple current pulse applied
Add OMV tests for NeuroML version, reusing the Model Emergent Property (
*.mep) file (example)
Compare multi-compartmental cell with channels¶
If you are using NEURON, export morphology from NEURON using pyNeuroML (example); this will be easier if there is a hoc script with just a single cell instance as in section 1). While there is the option to use
includeBiophysicalProperties=Trueand this will attempt to export the conductance densities on different groups, it may be better to consolidate these and add them afterwards using correctly named groups and the most efficient representation of conductance density to group relationships (example).
Alternatively manually add the
<channelDensity>elements to the cell file (as here).
As with the single compartment example, it’s best to start off with the passive case, compare that to the original code (for v at multiple locations), and gradually add channels.
Many projects on OSB were originally converted from the original format (NEURON, GENESIS, etc.) to NeuroML v1 using neuroConstruct (see here for a list of these). neuroConstruct has good support for export to NeuroML v2, and this code could form the basis for your conversion. More on using neuroConstruct here and details on conversion of models to NeuroML v1 here.