NESTML: a modeling language for spiking neurons

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

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. 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.

Introduction: The Challenge of Neural Simulation

In computational neuroscience, understanding brain function requires simulating the "spiking" behavior of neurons. However, a significant technical hurdle exists: the "Simulator Gap." While neuroscientists are experts in biology and mathematics, high-performance simulators like NEST typically require models to be hand-coded in C++.

This requirement creates several obstacles. First, there is an expertise mismatch; researchers must navigate complex C++ optimization and internal simulator APIs. Second, maintainability suffers; in NEST, mathematical equations were historically tangled with implementation details, leading to massive code duplication—often exceeding 90% between different models. Finally, existing modeling languages like NeuroML or NineML, while simulator-independent, are often verbose and fail to leverage specific simulator optimizations.

Figure 2: (A) Electrical circuit representation of a neuron membrane and (B) the corresponding differential equation for membrane potential.

The NESTML Approach

NESTML is a modular domain-specific language (DSL) built using the MontiCore language workbench. It is designed to bridge the gap by separating biological logic from low-level implementation. Its architecture comprises three specialized sub-languages:

  • Procedural DSL (PL): Handles imperative logic, such as state transitions when a neuron reaches a firing threshold.
  • Units DSL (UL): A type-safe system for physical units (e.g., Volts, Amperes, milliseconds), which prevents common unit-mismatch errors.
  • Differential Equation DSL (DL): Allows researchers to define Ordinary Differential Equations (ODEs) as simple mathematical strings.

Automated Mathematical Processing

A core strength of NESTML is its integration with SymPy, a symbolic mathematics library. NESTML analyzes the provided ODEs: if they are linear, it automatically calculates an exact solution using matrix exponentials. For non-linear equations, it generates the necessary "glue code" to interface with professional numerical solvers like SUNDIALS or GSL. This automation removes the manual, error-prone task of calculating propagator matrices.

Key Insights and Design Philosophy

NESTML treats domain concepts as first-class citizens. By making "neurons," "inputs," and "outputs" keywords, the code reflects scientific intent rather than software architecture. The choice of a Python-inspired syntax further lowers the entry barrier for the neuroscience community.

Furthermore, the language introduces modularity through a component keyword. This allows researchers to define standard elements—such as an "alpha-shape" synaptic current—once and reuse them across multiple neuron models, significantly reducing redundancy.

Results and Impact

The evaluation of NESTML involved reformulating approximately 30% of the existing NEST model library. The results demonstrate significant improvements in developer efficiency and code quality:

  • 20x Code Reduction: Defining a model requires up to 20 times less code compared to manual C++ implementation.
  • Performance Parity: Because NESTML generates optimized C++ tailored for the NEST API, simulations maintain the high performance required for large-scale neural networks without the overhead typically associated with high-level languages.

Limitations and Future Directions

While NESTML significantly advances neuron modeling, future work is needed to expand its scope. Current development focuses on extending the language to describe complex, plastic synapses—the dynamic connections between neurons. Additionally, while currently optimized for the NEST ecosystem, the modular design of NESTML provides a foundation for potential future backends for other simulators.

NESTML and a set of example models are publicly available on GitHub.

Summary updated

Abstract

Biological nervous systems exhibit astonishing complexity .Neuroscientists aim to capture this com- plexity by modeling and simulation of biological processes. Often very comple xm odels are nec- essary to depict the processes, which makes it dif fi cult to create these models. Powerful tools are thus necessary ,which enable neuroscientists to express models in acomprehensi ve and concise way and generate ef fi cient code for digital simulations. Se veral modeling languages for computational neuroscience ha ve been proposed [Gl10, Ra11]. Howe ver, as these languages seek simulator inde- pendence the ytypically only support asubset of the features desired by the modeler .Int his article, we present the modular and extensible domain speci fi cl anguage NESTML, which provides neuro- science domain concepts as fi rst-class language constructs and supports domain experts in creating neuron models for the neural simulation tool NEST .N ESTML and aset of example models are publically available on GitHub.
BibTeX
@inproceedings{plotnikov2016nestml,
  author = {Dimitri Plotnikov and Bernhard Rumpe and Inga Blundell and Tammo Ippen and Jochen Martin Eppler and Abigail Morrison},
  title = {{NESTML: a modeling language for spiking neurons}},
  booktitle = {Modellierung},
  year = {2016},
}
Figure