Neuroscientific research makes use of computational simulations more and more often. To performs such simulations, we designed the Brian simulator for spiking neural networks with the goal in mind that "a simulator should not only save the time of processors, but also the time of scientists." We here present Brian 2, a new major version and fundamental rewrite of Brian.
Brian is written in Python and focuses on simplicity and extensibility: A consistent interface centered around human-readable string descriptions using mathematical notation allows the specification of neuronal models, synaptic models and synaptic connections. Since models are described by differential equations, simulating a model means integrating the equations numerically. For explicit numerical integration methods, the numerical integration method itself can be described in mathematical notation, referring to the continuously updated state variables as abstract functions of state variables and time. Brian applies such an integration method to the differential equations using sympy and generates abstract code, a simple Pseudocode using Python syntax. Abstract code is also used by the user to describe event-based updates, for example the reset of an integrate-and-fire neuron after an action potential.
In order to benefit from the ease of use and the flexibility of the Python programming language without being limited by the speed of running interpreted Python code, Brian 2 makes use of fully automated runtime code generation. The aforementioned abstract code is transformed to Python code (for maximum compatibility), to C++ code or to CUDA code targetting GPUs. This code generation system is designed to be extensible to new target languages and its output can also be used on its own: for situations where high performance is necessary and/or where a Python interpreter is not available (for example in robotics applications), Brian 2 offers tools to assist in assembling the generated code into a stand-alone version that runs independently of Brian or a Python interpreter.
To ensure the correctness and maintainability of the software, Brian 2 includes an extensive, full coverage test suite. Debugging of simulation scripts is supported by a configurable logging system, allowing simple monitoring of the internal details of the simulation process. Brian 2 is available under a free software license and hosted on github.