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