Brian: a simulator for spiking neural networks
Dan Goodman, Romain Brette
Brian is a new project to create a
clock driven spiking
neural network simulator with the goal
s of being
, highly flexible, and easy to
It is ideally suited to rapid prototyping and
networks of single compartment model neurons
is written entirely in the Python
and will run on any platform that supports
(i.e. almost all platforms)
way it works is that
providing functions, classes and objects
can be used either
interactively using a Python shell, or as part of a
One of the difficulties with current software for neural
network simulation is that you have to
learn and use custom scripting languages for each tool
Neuron’s Hoc and NMODL, NEST’
is increases the learning curve
and is less flexible than using an established
support and development tools such as IDEs, debuggers and profilers. Data analysis is
either limited to those functions provided by the tool, or has to be carried out in another application such as
Matlab, which can slow down the process of prototy
ping and refining models. Writing extensions to these
tools can be rather difficult or somewhat inflexible, depending on whether extensions are written in the
same language as the simulator itself.
Standardisation using Python
To address this problem,
ere are projects in various stages of completion
to provide a Python interface for
ach of the
tools mentioned above.
se it is both easy and powerful,
is rapidly becoming a standard tool in the field and in scientific computing more generally.
addition, the PyNN project is working to provide a
each simulator (currently
supported are Neuron, NEST and PCSIM).
These projects have considerable benefits. Users will only need
to learn a single programming language rather
than one or more for each tool, and that language is easy to
learn, highly developed, very powerful, and has a large user base which provides excellent support and
tools. A great deal of time can be saved working in just one environment, rather than havin
g to switch back
and forth between different applications and GUIs for developing models, running simulations and
The advantages of Brian.
Being written entirely in Python itself, Brian has all the advantages of the
projects above and some
additional ones. Integration with Python is tighter because the implementation is
not in a separate language to the interface. This means that Brian can be used more flexibly, for example if
you wanted to write code which reads and modifies the variables
of the simulation as it runs. Additionally,
extensions to Brian are easy to write because everything is written in the same language.
RIAN IN ACTION
The code below
defines, runs and plots
a randomly connected network of integrate and fire neurons with
xponential inhibitory and excitatory currents (the CUBA network from ):
# Define differential equations of model
eate groups of neurons
P = NeuronGroup
Pe = P.
Pi = P.
# Define network structure
Ce = Connection
Ci = Connection
# Keep track of which neurons have spiked
M = SpikeMonitor
# Run the simulation
# Plot the results
The output can be
seen in Figure 1 below.
Raster plot of the CUBA network
The procedure for writing a simulation with Brian is the same as for most neural network software. First
you define a neuron model, then you create some
neurons with that model, and finally you connect them
At the moment, Brian provides three main ways of defining a neuron model: directly specifying
the differential equations
(including stochastic DEs)
conditions and reset va
lues; using a standard
model or combination of standard components such as
ion channels and alpha function postsynaptic
currents; or providing code for the integration step directly. If you specify a differential equation, Brian can
automatically select an
appropriate integration method. For example linear DEs can be integrated exactly
and Brian will do this automatically (this is what happens when you run the CUBA network example
Threshold conditions can be specified either statically, dynamically,
empirically or functionally.
Refractoriness and synaptic delays can also be used.
Connections can be specified by standard types (all to
all and random connectivity), by providing a connectivity matrix directly, or by writing a function to
generate the co
Brian uses the NumPy and SciPy packages for Python to do highly optimized linear algebra.
Consequently, although there is a computational overhead for using Python
an interpreted language
compared to a compiled language
like C++, for large networks the performance is comparable. The CUBA
network example takes 3.5s to simulate 1s of biological time, which is 60% faster than using Matlab, and
only 25% slower than using C++.
Brian has a system for
defining quantities with physical dimensions. Arithmetical operations and
equations are checked for dimensional consistency, which can help to eliminate hard to debug scaling
errors and mistakes in entering equations.
In some situ
ations, Brian can automatically and transparently generate and use
optimised C++ code from the definition of the model, providing a significant acceleration.
Control and monitoring.
All the internal variables of the simulator can be directly accessed to i
the network or control it as it runs. Spikes and state variables can be monitored and either saved to a file or
used directly. Special neuron models are provided which allow you to specify exactly when a neuron fires a
spike either by code or by
passing a list of spike times.
Analysis and plotting.
Any Python package can be used in combination with Brian. This includes the
NumPy and SciPy scientific computing packages, and the PyLab graphics package which mirrors the
syntax of the Matlab plotting
IMITATIONS AND FUTUR
One of the major missing features in the first release of Brian is STDP. Work is already under way
and this will be included in Brian as soon as possible.
Although for large networks of linear ne
urons the performance of Brian is comparable to C++ code,
it is still slower for many tasks. Work is underway to provide more extensive use of automatic generation
of C++ code. In theory, by dynamically analysing the structure of the network before generat
ing the code,
and using optimisations tailored directly to that structure, Brian could do better than code written directly in
Python has no built in support for distributed computing. There are various
packages that provide so
me support for it, but these are somewhat limited at the time of writing. One
possibility is to use the GPU for very fast vector computations. A Python package is being developed to
implement this, and Brian will use it when a more stable release is ready.
Although it is theoretically possible to use these in Brian, it would not be
easy or efficient. This may be included in subsequent releases of Brian depending on feasibility and
It should be possible in
some situations to provide mathematical analysis of the behaviour
of a network without actually running the simulation, based on its defining equations. This would be a
useful counterpart to running simulations, and to our knowledge is not included in any
We plan to implement the PyNN interface, and the NeuroML and FacetsML
We plan to add real
time plotting and other visualisation tools.
Depending on feasibility and demand,
we would like to implement an online searchable
database of models, networks, etc. This would be accessible directly from the Python command line or via
a web site.
Brette R, Rudolph M, Carnevale T, Hines M, Beeman D, Bower JM, Diesmann M, Mo
Goodman PH, Harris FC, et al.:
Simulation of networks of spiking neurons: a review of tools
. J Comput Neurosci