NESTML: a modeling language for spiking neurons

Dimitri Plotnikov, Inga Blundell, Tammo Ippen, Jochen Martin Eppler, Abigail Morrison, Bernhard Rumpe

TL;DR

NESTML is a domain-specific language (DSL) designed to simplify the creation of spiking neuron models for the NEST simulator. By providing a Python-inspired syntax that separates biological logic from low-level C++ implementation, it allows researchers to define complex models with up to 20 times less code while maintaining high simulation performance.

What Problem Does This Paper Address?

In computational neuroscience, researchers aim to simulate the "spiking" behavior of neurons to understand brain function. However, there is a significant technical hurdle: the "Simulator Gap."

Most high-performance simulators, like NEST, require models to be hand-coded in C++. This presents several challenges:

  1. Expertise Mismatch: Neuroscientists are experts in biology and math, not necessarily in C++ optimization or the internal APIs of a specific simulator.
  2. Maintainability: In NEST, the mathematical equations (the "what") were often tangled with implementation details (the "how"). This led to massive code duplication—sometimes over 90% between different models.
  3. The Portability Paradox: Existing modeling languages (like NeuroML or NineML) are often XML-based, making them verbose and hard for humans to read. Furthermore, because they strive to be "simulator-independent," they often fail to leverage the specific optimizations that make a simulator like NEST fast.

Methods

The authors developed NESTML, a modular DSL built using the MontiCore language workbench. Its design is centered on three sub-languages:

  • Procedural DSL (PL): Handles the imperative logic (e.g., what happens when a neuron reaches a threshold).
  • Units DSL (UL): A type-safe system for physical units (Volts, Amperes, milliseconds), preventing common "unit mismatch" bugs.
  • Differential Equation DSL (DL): Allows researchers to write ODEs as simple mathematical strings.

The Magic Under the Hood: NESTML doesn't just copy-paste code. It uses SymPy (a symbolic math library) to analyze the provided differential equations. If the equations are linear, NESTML automatically calculates an exact solution using matrix exponentials. If they are non-linear, it generates the "glue code" necessary to interface with professional numerical solvers like SUNDIALS or GSL.

Datasets

As this is a systems and languages paper rather than a machine learning study, traditional training datasets were not used. Instead, the authors evaluated NESTML by reformulating approximately 30% of the existing NEST model library (which contained 36 hand-coded C++ models at the time) into the new language to verify correctness and efficiency.

Key Insights and Ideas

  • Domain Concepts as First-Class Citizens: By making "neurons," "inputs," and "outputs" keywords in the language, the code reads like a scientific paper rather than a software manual.
  • Syntax Matters: Choosing a Python-inspired syntax was a strategic move to lower the entry barrier, as Python is the lingua franca of the neuroscience community.
  • Separation of Concerns: NESTML allows a "declarative" approach. A scientist can simply state the ODE for a membrane potential, and the compiler handles the complex task of transforming that math into efficient, parallelizable C++ code.
  • Modularity through Components: The language introduces a component keyword, allowing researchers to define a standard "alpha-shape" synaptic current once and reuse it across dozens of different neuron models.

Key Results

  • 20x Code Reduction: The authors reported a 20-fold reduction in the amount of code required to define a model compared to the manual C++ and bootstrapping code previously required.
  • Automated Math: The manual, error-prone task of calculating propagator matrices for linear models is now entirely automated.
  • Performance Parity: Because the tool generates optimized C++ tailored for the NEST API, the resulting simulations do not suffer the performance penalties typically associated with "simulator-agnostic" high-level languages.

Limitations and Future Work

The paper acknowledges a few areas for growth:

  • Synapse Modeling: At the time of writing, NESTML focused primarily on neuron dynamics. The authors noted that extending the language to describe complex, plastic synapses (the connections between neurons) was the next major milestone.
  • Mathematical Depth: The specific algorithmic techniques used to transform neural dynamics into C++ were deemed "out of scope" for this introductory paper and slated for a follow-up publication.
  • Ecosystem Lock-in: While NESTML is powerful, it is currently tightly coupled to the NEST simulator. While the authors mention the potential for other backends, its primary value remains within the NEST ecosystem.

Summary updated

Abstract

Biological nervous systems exhibit astonishing complexity. Neuroscientists aim to capture this complexity by modeling and simulation of biological processes. Often very complex models are necessary to depict the processes, which makes it difficult to create these models. Powerful tools are thus necessary, which enable neuroscientists to express models in a comprehensive and concise way and generate efficient code for digital simulations. Several modeling languages for computational neuroscience have been proposed [Gl10, Ra11]. However, as these languages seek simulator independence they typically only support a subset of the features desired by the modeler. In this article, we present the modular and extensible domain specific language NESTML, which provides neuroscience domain concepts as first-class language constructs and supports domain experts in creating neuron models for the neural simulation tool NEST. NESTML and a set of example models are publically available on GitHub.
BibTeX
@inproceedings{plotnikov2016nestml,
  author = {Dimitri Plotnikov and Inga Blundell and Tammo Ippen and Jochen Martin Eppler and Abigail Morrison and Bernhard Rumpe},
  title = {{NESTML: a modeling language for spiking neurons}},
  booktitle = {Modellierung},
  year = {2016},
}

Loading related content...

Figure