Goodman and Brette Python A high-level programming language. Programs can be run from a script or interactively from a shell (as in Matlab). It is often used for providing a high-level interface to low-level code. The Python community has developed a large number of third party packages, including NumPy and SciPy, which are commonly used for efﬁcient numerical and scientiﬁc computation. Interface A mechanism for interacting with software, often simpliﬁed and using abstractions, such as a graphical user interface (GUI) for interacting directly with the user, or an application programming interface (API) for interacting via code, possibly written in another language. High-level language A programming language providing data abstraction and hiding low-level implementation details speciﬁc to the CPU, memory management, and other technical details. Package A self-contained collection of objects and functions, often written by a third party to provide easily usable implementations of various algorithms. Script A ﬁle containing a sequence of statements in a high-level language which are run as a whole rather than interactively. Shell A computer environment or program in which single statements can be entered interactively, where the results are evaluated immediately and are then available for use in subsequently entered statements. Vector-based computation A technique for achieving computational efﬁciency in high-level languages. It consists of replacing repeated operations by single operations on vectors (e.g. arithmetic operations) that are implemented in a dedicated efﬁcient package (e.g. NumPy for Python). restriction. For example, we may want to deﬁne an α post-synaptic current by g(t) = (t/τ)e1 − t/τ rather than a differential equation. However, this is just the integrated formulation of the associated kinetic model: where presynaptic spikes act on y (that is, cause an instantaneous increase in y). More generally, biophysical neural models can almost always be expressed as differential equations, whose solutions are the post-synaptic potentials or currents. In the same way, short-term plasticity (Tsodyks and Markram, 1997) and spike-timing-dependent plasticity (STDP, Song et al., 2000) can also be deﬁned by differential equations with discrete events. In fact, although STDP is often described by the modiﬁcation of the synaptic weight for a given pair of presynaptic and postsynaptic spikes, this phenomenological description is ambiguous because it does not specify how pairs interact (e.g. all-to-all or nearest neighbours). These considera- tions motivated our choice to deﬁne all models unambiguously with differential equations and discrete events. Brian emphasises this approach more strongly than any other simulator package, and it has some crucial beneﬁts. Foremost, it separates the deﬁnition of the model from its implementa- tion, which makes the code highly reproducible and readable. The equations deﬁne the models unambiguously, independently of the simula- tor itself, which makes it easy to share the code with other researchers, even though they might use a different simulator or no simulator at all. Second, it minimises the amount of simulator speciﬁc syntax that needs to be learnt. For exam- ple, users do not need to look up the names of the model parameters since they deﬁne them themselves. Third, simulating custom models is as simple as simulating standard models. In the following, we illustrate these features in a few concrete cases. CASE STUDIES In this section, we discuss several examples that illustrate the key features of Brian. INVESTIGATING A NEW NEURON MODEL Several recent experimental (Badel et al., 2008) and theoretical studies (Deneve, 2008) have suggested that the threshold for spike initiation should increase after each spike and decay to a stationary value. A simple model is given by a differential equation for the threshold VT: τtdVT/dt = VT0 − VT, and an instantaneous increase at spike time: VT ← VT + δ. This model can be simulated directly with Brian, even though it is not a predeﬁned model: The Brian simulator equations = ‘’’ dV/dt = (V0-V)/tau : volt dVT/dt = (VT0-VT)/tau_t : volt ‘’’ G = NeuronGroup(N, equations, threshold=’V>VT’, reset=’’’ V = V0 VT += delta’’’) Two things can be noted in this code: the threshold condition can be any boolean condi- tion on the variables of the model (not only a ﬁxed threshold), and the reset can be any sequence of Python instructions. INVESTIGATING PLASTICITY MECHANISMS The mechanisms of spike-timing-dependent plas- ticity are an active line of research, so that many different models coexist and we might expect new models to emerge in the near future. Figure 1 shows a Brian script replicating some of the results of Song et al. (2000), where a neuron receives random inputs through plastic synapses. The STDP rule is exponential with all-to-all interactions between spike pairs and results in a bimodal stationary dis- tribution of synaptic weights. Although the expo- nential STDP rule can be most simply used in Brian with the ExponentialSTDP object, the most general way to deﬁne such a mechanism in Brian is to give its equations. As is shown in Figure 1, a synaptic plasticity model is deﬁned by three components: differential equations for synaptic variables (here Apre and Apost); events at presynaptic spike times; and events at postsynaptic spike times. This formalism encompasses a very broad class of plasticity rules. For example, triplet-based STDP rules (Pﬁster and Gerstner, 2006) can be imple- mented by inserting a third differential equation; and nearest-neighbour rules can be obtained by replacing the presynaptic code A_pre+=dA_pre by A_pre=dA_pre and the postsynaptic code A_post+=dA_post by A_post=dA_post. MODELLING A FUNCTIONAL NEURAL SYSTEM Figure 2 shows a Brian script adapted from Stürzl et al. (2000), which models the neural mechanisms of prey localisation by a sand scorpion. This model is fairly complex and includes in particular noise and delays, which would make equivalent code in Matlab or C very long, whereas the full script takes only about 20 lines with Brian (plus the deﬁnition of parameter values). The script illustrates the fact that the code is close to the mathematical deﬁni- tion of the model, which makes it relatively easy to understand. Many (if not most) neurocompu- tational studies at the systems level are not pub- lished along with the code, which might be because Frontiers in Neuroscience www.frontiersin.org September 2009 | Volume 3 | Issue 2 | 194