Simulating NeuroML Models

Work in progress

This page is a work in progress. Please see https://github.com/NeuroML/Documentation/issues/13

Validate NeuroML 2 files before using them.

It is good practice to validate NeuroML 2 files to check them for correctness before simulating them.

Using Open Source Brain

Models that have already been converted to NeuroML and added to the Open Source Brain platform can be simulated through your browser.

Open Source Brain

Fig. 13 Examples of NeuroML 2 models visualised on Open Source Brain. A) Hodgkin Huxley model interactive tutorial. B) Integrate and fire network model of cortical column (Potjans and Diesmann 2014), showing network connectivity. C) Cortical model with multicompartmental cells (Traub et al. 2005), showing network properties and simulated membrane potential activity. D) Model of C. elegans nervous system from OpenWorm project. All visualisation/analysis/simulation enabled due to models being in standardised NeuroML format.

Most of the OSB example projects feature prebuilt NeuroML models which can be simulated in this way.

A discussion on the steps required for sharing your own models on OSB, with a view to simulating them on the platform, can be found here.

Using jNeuroML/pyNeuroML

jLEMS is the reference implementation of the LEMS language in Java, and can be used to simulate single compartment models written in NeuroML/LEMS. It is included in both jNeuroML and pyNeuroML.

jNeuroML and pyNeuroML

Fig. 14 Relationship between jLEMS, jNeuroML and pyNeuroML.

jNeuroML and pyNeuroML can be used at the command line as follows:

# Simulate the model using jNeuroML
jnml <LEMS simulation file>

# Simulate the model using pyNeuroML
pynml <LEMS simulation file>

You can also run LEMS simulations using jNeuroML straight from a Python script using the pyNeuroML API:

from pyneuroml.pynml import run_lems_with_jneuroml

...

run_lems_with_jneuroml(lems_file_name)

Using NEURON

For more complex models that can not be simulated using jLEMS, we can use the NEURON simulator, also using jNeuroML or pyNeuroML:

# Simulate the model using NEURON with python/hoc/mod files generated by jNeuroML
jnml <LEMS simulation file> -neuron -run

# Simulate the model using NEURON with python/hoc/mod files generated by pyNeuroML
pynml <LEMS simulation file> -neuron -run

These commands generate a PyNeuron script and run it (a file ending in _nrn.py). So you must have NEURON installed on your system, with its Python bindings (PyNeuron). Skipping the -run flag will generate the Python script but will not run it: you can run it manually later. Adding -nogui will suppress the NEURON graphical elements/menu opening and just run the model in NEURON in the background

You can also run LEMS simulations using the NEURON simulator using the pyNeuroML API:

from pyneuroml.pynml import run_lems_with_jneuroml_neuron

...

run_lems_with_jneuroml_neuron(lems_file_name)

Using NetPyNE

You can also generate and run NetPyNE code from NeuroML. To generate and run NetPyNE code, use jNeuroML or pyNeuroML:

# Simulate the model using NetPyNE with python/hoc/mod files generated by jNeuroML
jnml <LEMS simulation file> -netpyne -run

# Simulate the model using NetPyNE with python/hoc/mod files generated by pyNeuroML
pynml <LEMS simulation file> -netpyne -run

The main generated Python file name will end in _netpyne.py.

You can also run LEMS simulations using the NetPyNE simulator using the pyNeuroML API:

from pyneuroml.pynml import run_lems_with_jneuroml_netpyne

...

run_lems_with_jneuroml_netpyne(lems_file_name)

Importing NeuroML into NetPyNE

An example of how to import a network in NeuroML into NetPyNE can be found here.

Exporting NeuroML from NetPyNE

An example of how to export a network built using NetPyNE to NeuroML can be found here.

Using Brian2

You can export single component NeuroML models to Python scripts for running them using the Brian2 simulator:

# Using jnml
jnml <LEMS simulation file> -brian2

# Using pynml
pynml <LEMS simulation file> -brian

You can also run LEMS simulations using the Brian2 simulator using the pyNeuroML API:

from pyneuroml.pynml import run_lems_with_jneuroml_brian2


...

run_lems_with_jneuroml_brian2(lems_file_name)

Using MOOSE

You can export NeuroML models to the MOOSE simulator format using jnml:

# Using jnml
jnml <LEMS simulation file> -moose