- Poster presentation
- Open Access
Brian: a simulator for spiking neural networks in Python
BMC Neurosciencevolume 9, Article number: P92 (2008)
We present Brian, a new clock driven simulator for spiking neural networks which is available on almost all platforms. Brian is easy to learn and use, highly flexible and easily extensible. The Brian package itself and simulations using it are all written in the Python programming language, which is very well adapted to these goals. Python is an easy, concise and highly developed language with many advanced features and development tools, excellent documentation and a large community of users providing support and extension packages. Brian allows you to write very concise, natural and readable code for simulations, and makes it quick and efficient to play with these models (for example, changing the differential equations doesn't require a recompile of the code). Figure 1 shows an example of a complete network implemented in Brian, a randomly connected network of integrate and fire neurons with exponential inhibitory and excitatory currents (the CUBA network from ). Defining the model, running the simulation and making a raster plot of the activity takes fifteen lines of code. Amongst Brian's features are:
• Flexible neuron models: these can be defined in many ways, notably by directly providing differential equations (including stochastic DEs), or modularly, using standard components like ion channels and alpha function postsynaptic currents.
• Built in analysis and plotting: using the SciPy and PyLab scientific computing and plotting packages.
• Unit checking: equations and quantities are checked for dimensional consistency, which helps to eliminate scaling errors and incorrect equations which can otherwise be very hard to debug.
• Interactive simulations: Using the Python interactive shell, running simulations, changing aspects of the model, plotting and analysis can all be done interactively rather than requiring the network to be run afresh each time.
• Extensibility: Since Brian is written in the same high level language as simulations using it, it is easy to write extensions to Brian and share them with others.
Python is an interpreted language which means that it is slower than code written directly in C, but by using the NumPy package for highly optimised linear algebra it ends up comparable in speed to C code for large networks. The random network described above with 4000 neurons took 3.5 s to simulate 1 s of biological time, which was roughly 60% faster than Matlab, and 25% slower than C.
Brette R, Rudolph M, Carnevale T, Hines M, Beeman D, Bower JM, Diesmann M, Morrison A, Goodman PH, Harris FC, et al: Simulation of networks of spiking neurons: a review of tools and strategies. J Comput Neurosci. 2007, 23 (3): 349-398. 10.1007/s10827-007-0038-6.