libNeuroML is a Python package for working with models specified in NeuroML version 2. It provides a native Python object model corresponding to the NeuroML schema. This allows users to build their NeuroML models natively in Python without having to work directly with the underlying XML representation. Additionally, libNeuroML includes functions for the conversion of the Python representation of the NeuroML model to and from the XML representation.

Quick start#

Install Python#

Python is generally pre-installed on all computers nowadays. However, if you do not have Python installed on your system, please follow the official installation instructions to install Python on your computer. A number of Free/Open source Integrated Development Environments (IDEs) are also available that make working with Python (even) easier. An example list is here.

Install libNeuroML with pip#

The easiest way to install the latest version of libNeuroML is using the default Python package manager, pip:

pip install libNeuroML

Installation on Fedora Linux#

On Fedora Linux systems, the NeuroFedora community provides libNeuroML in the standard Fedora repos and can be installed using the following commands:

sudo dnf install python3-libNeuroML


Detailed API documentation for libNeuroML can be found here. For more information on libNeuroML, please see Vella et al. ([VCC+14]) and Cannon et al. ([CGC+14]).

The core classes in NeuroML are Python representations of the Component Types defined in the NeuroML standard. These can be used to build NeuroML models in Python, and these models can then be exported to the standard XML NeuroML representation. These core classes also contain some utility functions to make it easier for users to carry out common tasks.

Examples of mapping between Component names in the NeuroML schema and their corresponding libNeuroML Python classes.

Fig. 64 Examples of mapping between Component names in the NeuroML schema and their corresponding libNeuroML Python classes.#

Each NeuroML Component Type is represented here as a Python class. Due to implementation limitations, whereas NeuroML Component Types use lower camel case naming, the Python classes here use upper camel case naming. So, for example, the adExIaFCell Component Type in the NeuroML schema becomes the AdExIaFCell class here, and expTwoSynapse becomes the ExpTwoSynapse class.

The child and children elements that NeuroML Component Types can have are represented in the Python classes as variables. The variable names, to distinguish them from class names, use snake case. So for example, the cell NeuroML Component Type has a corresponding Cell Python class here. The biophysicalProperties child Component Type in cell is represented as the biophysical_properties list variable in the Cell Python class. The class signatures list all the child/children elements and text fields that the corresponding Component Type possesses. To again use the Cell class as an example, the construction signature is this:

class neuroml.nml.nml.Cell(neuro_lex_id=None, id=None, metaid=None, notes=None, properties=None, annotation=None, morphology_attr=None, biophysical_properties_attr=None, morphology=None, biophysical_properties=None, extensiontype_=None, **kwargs_)

As can be seen here, it includes both the biophysical_properties and morphology child elements as variables.

Please see the examples in the NeuroML documentation to see usage examples of libNeuroML. Please also note that this module is also included in the top level of the neuroml package, so you can use these classes by importing neuroml:

from neuroml import AdExIaFCell

Getting help#

For any questions regarding libNeuroML, please open an issue on the GitHub issue tracker here. Any bugs and feature requests can also be filed there.

You can also use any of the communication channels of the NeuroML community.


libNeuroML is developed on GitHub at NeuralEnsemble/libNeuroML under the BSD 3 clause license. The repository contains the complete source code along with instructions on building/installing libNeuroML. Please follow the instructions there to build libNeuroML from source.