Bug hunt episode 1: Broken LaTeX output for equations

This article starts a new series of blog posts about “bug hunts”. In these articles, I will go through a recent bug in Brian (or one of its dependencies) and describe all the steps I used to find the source of the bug and how I fixed it. I will try to not only focus on the Brian-side of things, but also show some general tools like git bisect or “monkey patching” that can be helpful to find the source of these nasty critters (no actual bugs were harmed during the making of this blog post).

Let’s start! Today’s bug will be about equations, and more specifically about their LaTeX representation. As most of you probably know, Brian can represent equations, quantities, etc. in LaTeX. This representation can then either be included in a LaTeX document or directly rendered for example as the output in jupyter notebooks.

Read more…

Preview image

Getting the timing right (scheduling 2)

Quickstart

To run the code below:
  1. Click on the cell to select it.
  2. Press SHIFT+ENTER on your keyboard or press the play button () in the toolbar above
Feel free to create new cells using the plus button (), or pressing SHIFT+ENTER while this cell is selected.

Scheduling”: mechanism to determine the order of operations during a simulation

In this video we will look at its importance for:

  • propagating synaptic activity
Preview image

New release: Brian 2.4

In these very particular times, we are nevertheless happy to announce a new release, Brian 2.4. This release fixes a large number of bugs and includes a number of small improvements. As announced with the previous release, Brian 2.4 is the first release that no longer supports Python 2. For a full list of changes, see the release notes. We recommend all users of Brian 2 to update.

As always, Brian 2 can be installed with Anaconda from the conda-forge channel (packages are provided for Python 3.6, 3.7, 3.8), or with pip from the pypi repository. See the installation instructions for more details.

In case of questions or issues, please join us in the Brian support forum at brian.discourse.group.

Getting the timing right (scheduling 1)

Quickstart

To run the code below:
  1. Click on the cell to select it.
  2. Press SHIFT+ENTER on your keyboard or press the play button () in the toolbar above
Feel free to create new cells using the plus button (), or pressing SHIFT+ENTER while this cell is selected.

Scheduling”: mechanism to determine the order of operations during a simulation

In this notebook we will look at its importance for:

  • recording values with a StateMonitor

You can also watch the   screencast video on Youtube.

Read more…

Preview image

New Brian community forum

Ask questions, chat and learn with other Brian users, show off what you’ve done, suggest new features, … We will try out a brand new forum for support questions and general discussion, replacing our previous forums on Google Groups. The new forum builds on the Discourse platform which gives us exciting new features such as giving credit to users for answering questions.

Please join here 👉 brian.discourse.group.

Forum screenshot

Brian online tutorial

We will experiment with running a Brian tutorial online. The first tutorial of this kind will take place on Friday, August 7th 2020 from 2pm-6pm BST (UTC+1, see here for other timezones). Free (but mandatory) registration here. We will run the tutorial as a Zoom meeting – registering with the link will give you the URL (please don’t share so we can avoid zoombombing). We will record the meeting and if everything goes reasonably well, we will upload the videos later.

Update: The recorded video is now on Youtube:

If you participate, it would be really helpful if you could download and install Brian before the tutorial so that you can work along with it as we go. Instructions are:

  1. Download and install the Anaconda Python 3 distribution
  2. Open a command prompt and run the following lines:
  3. You can now verify this is working by starting a Jupyter notebook server with:
  4. Your browser should open with the Jupyter notebooks interface. Now create a new notebook and put the following code in an empty cell:
    from brian2 import *
  5. Run that cell by pressing Ctrl+Enter. If that works without any errors (you might see a warning) then you’re good to go.
  6. If that doesn’t work or you want to use a different system than Anaconda, take a look at our detailed installation instructions.

If you have trouble installing, don’t worry. You can use the Brian installation on Binder or Google Colab instead.

For Colab, just make the first cell as follows:

!pip install brian2
!pip install brian2tools

Looking forward to seeing you all on Friday!

Making use of Python: threshold finding with bisection

Quickstart

To run the code below:
  1. Click on the cell to select it.
  2. Press SHIFT+ENTER on your keyboard or press the play button () in the toolbar above
Feel free to create new cells using the plus button (), or pressing SHIFT+ENTER while this cell is selected.

This article demonstrates how a control flow, where simulation parameters depend on the results of previous simulations, can be expressed by making use of standard control structures in Python. By having access to the full expressivity of a general purpose programming language, expressing such control flow is straight-forward; this would not be the case for a declarative model description.

Our goal in this toy example is to find the threshold voltage of neuron as a function of the density of sodium channels.

This example is from our eLife paper (Stimberg et al. 2019).

Read more…

Preview image

Non-standard neuron modelling: smooth pursuit eye movements

Quickstart

To run the code below:
  1. Click on the cell to select it.
  2. Press SHIFT+ENTER on your keyboard or press the play button () in the toolbar above
Feel free to create new cells using the plus button (), or pressing SHIFT+ENTER while this cell is selected.

In this article we demonstrate how Brian can be used to simulate non-neural aspects of the model. This is an idealized model of the smooth pursuit reflex, including two ocular muscles, a moving visual stimulus and spiking neural control.

This article is adapted from our eLife paper (Stimberg et al. 2019), which includes an interactive version that you can play with here.

Read more…

Preview image

Non-standard neuron modelling: the pyloric network

Quickstart

To run the code below:
  1. Click on the cell to select it.
  2. Press SHIFT+ENTER on your keyboard or press the play button () in the toolbar above
Feel free to create new cells using the plus button (), or pressing SHIFT+ENTER while this cell is selected.

One of the great advantages of using Brian is that defining new non-standard model types is easy. In this article, we will build a highly simplified model of the pyloric circuit of the crustacean stomatogastric ganglion. This circuit generates a tri-phasic rhythmic pattern with alternating bursts of action potentials in different types of motor neurons. Here, we follow previous work (e.g. Golowasch et al., 1999) by modeling the circuit as consisting of three populations: AB/PD (anterior buster and pyloric dilator neurons), LP (lateral pyloric neurons), and PY (pyloric neurons). This model has a number of non-standard properties that will be described in the following annotated version of the code.

Golowasch, J., Casey, M., Abbott, L. F., & Marder, E. (1999).
Network Stability from Activity-Dependent Regulation of Neuronal Conductances.
Neural Computation, 11(5), 1079-1096.
https://doi.org/10.1162/089976699300016359

This article was based on one of the examples from our eLife paper (Stimberg et al. 2019).

Read more…

Preview image