Creating NeuroML models

WIP

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

Please see the Getting Started with NeuroML section for quick examples on how you can use pyNeuroML to create NeuroML models and run them.

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

Needs improvements

This section needs improvements, verfication, and re-writing to make it easier to follow. Related issue: https://github.com/NeuroML/Documentation/issues/31

Schamatic of process of converting models to NeuroML

Fig. 7 Procedures and tools to convert models from native formats to NeuroML and PyNN (Taken from Gleeson et al. 2019 [GCM+19])

Share original model code in GitHub repo

  • Make simple script with one/each cell - simple current pulse into each (example1, example2)

  • Make soma only example with all channels (ideally one where channels can easily be added/commented out) - apply current pulse (example in NEURON)

  • Make passive version of multi-compartmental cell with multiple locations recorded

  • Make multi-compartmental cell with multiple channels and calcium dynamics, with channels specified in separate files

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

  • Ensure all *nml files are valid

  • Ensure LEMS*.xml runs with jnml; visually compare behaviour with original simple script from the previous section)

  • Install NEURON; ensure LEMS*.xml runs with jnml -neuron

  • Commit LEMS/NeuroML code to GitHub

Convert channels

  • 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)

  • If you are using NEURON, use pynml-modchananalysis to generate plots of the activation variables for the channels in the mod files (example1, example2).

  • Start from an existing similar example of an ion channel in NeuroML (examples1, examples2, examples3)

  • Use pynml-channelanalysis to 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)

  • Test in jnml first, then in Neuron with jnml -neuron

Add OMV tests

Compare multi-compartmental cell with channels

  • You can export morphologies on NeuroMorpho.org to NeuroML2 (example)

  • 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=True and 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.

(Re)optimising cell models

  • You can use Neurotune inside pyNeuroML to re-optimise your cell models. An example is here