Changes for Brian 1 users

Note

If you need to run existing Brian 1 simulations, have a look at Container image for Brian 1.

In most cases, Brian 2 works in a very similar way to Brian 1 but there are some important differences to be aware of. The major distinction is that in Brian 2 you need to be more explicit about the definition of your simulation in order to avoid inadvertent errors. In some cases, you will now get a warning in other even an error – often the error/warning message describes a way to resolve the issue.

Specific examples how to convert code from Brian 1 can be found in the document Detailed Brian 1 to Brian 2 conversion notes.

Physical units

The unit system now extends to arrays, e.g. np.arange(5) * mV will retain the units of volts and not discard them as Brian 1 did. Brian 2 is therefore also more strict in checking the units. For example, if the state variable v uses the unit of volt, the statement G.v = np.rand(len(G)) / 1000. will now raise an error. For consistency, units are returned everywhere, e.g. in monitors. If mon records a state variable v, mon.t will return a time in seconds and mon.v the stored values of v in units of volts.

If you need a pure numpy array without units for further processing, there are several options: if it is a state variable or a recorded variable in a monitor, appending an underscore will refer to the variable values without units, e.g. mon.t_ returns pure floating point values. Alternatively, you can remove units by diving by the unit (e.g. mon.t / second) or by explicitly converting it (np.asarray(mon.t)).

Here’s an overview showing a few expressions and their respective values in Brian 1 and Brian 2:

Expression

Brian 1

Brian 2

1 * mV

1.0 * mvolt

1.0 * mvolt

np.array(1) * mV

0.001

1.0 * mvolt

np.array([1]) * mV

array([ 0.001])

array([1.]) * mvolt

np.mean(np.arange(5) * mV)

0.002

2.0 * mvolt

np.arange(2) * mV

array([ 0. , 0.001])

array([ 0., 1.]) * mvolt

(np.arange(2) * mV) >= 1 * mV

array([False, True], dtype=bool)

array([False, True], dtype=bool)

(np.arange(2) * mV)[0] >= 1 * mV

False

False

(np.arange(2) * mV)[1] >= 1 * mV

DimensionMismatchError

True

Unported packages

The following packages have not (yet) been ported to Brian 2. If your simulation critically depends on them, you should consider staying with Brian 1 for now.

  • brian.tools

  • brian.library.modelfitting

  • brian.library.electrophysiology

Replacement packages

The following packages that were included in Brian 1 have now been split into separate packages.

  • brian.hears has been updated to brian2hears. Note that there is a legacy package brian2.hears included in brian2, but this is now deprecated and will be removed in a future release. For now, see Brian Hears for details.

Removed classes/functions and their replacements

In Brian 2, we have tried to keep the number of classes/functions to a minimum, but make each of them flexible enough to encompass a large number of use cases. A lot of the classes and functions that existed in Brian 1 have therefore been removed. The following table lists (most of) the classes that existed in Brian 1 but do no longer exist in Brian 2. You can consult it when you get a NameError while converting an existing script from Brian 1. The third column links to a document with further explanation and the second column gives either:

  1. the equivalent class in Brian 2 (e.g. StateMonitor can record multiple variables now and therefore replaces MultiStateMonitor);

  2. the name of a Brian 2 class in square brackets (e.g. [Synapses] for STDP), this means that the class can be used as a replacement but needs some additional code (e.g. explicitly specified STDP equations). The “More details” document should help you in making the necessary changes;

  3. “string expression”, if the functionality of a previously existing class can be expressed using the general string expression framework (e.g. threshold=VariableThreshold('Vt', 'V') can be replaced by threshold='V > Vt');

  4. a link to the relevant github issue if no equivalent class/function does exist so far in Brian 2;

  5. a remark such as “obsolete” if the particular class/function is no longer needed.

Brian 1

Brian 2

More details

AdEx

[Equations]

Library models (Brian 1 –> 2 conversion)

aEIF

[Equations]

Library models (Brian 1 –> 2 conversion)

AERSpikeMonitor

# 298

Monitors (Brian 1 –> 2 conversion)

alpha_conductance

[Equations]

Library models (Brian 1 –> 2 conversion)

alpha_current

[Equations]

Library models (Brian 1 –> 2 conversion)

alpha_synapse

[Equations]

Library models (Brian 1 –> 2 conversion)

AutoCorrelogram

[SpikeMonitor]

Monitors (Brian 1 –> 2 conversion)

biexpr_conductance

[Equations]

Library models (Brian 1 –> 2 conversion)

biexpr_current

[Equations]

Library models (Brian 1 –> 2 conversion)

biexpr_synapse

[Equations]

Library models (Brian 1 –> 2 conversion)

Brette_Gerstner

[Equations]

Library models (Brian 1 –> 2 conversion)

CoincidenceCounter

[SpikeMonitor]

Monitors (Brian 1 –> 2 conversion)

CoincidenceMatrixCounter

[SpikeMonitor]

Monitors (Brian 1 –> 2 conversion)

Compartments

# 443

Multicompartmental models (Brian 1 –> 2 conversion)

Connection

Synapses

Synapses (Brian 1 –> 2 conversion)

Current

# 443

Multicompartmental models (Brian 1 –> 2 conversion)

CustomRefractoriness

[string expression]

Neural models (Brian 1 –> 2 conversion)

DefaultClock

Clock

Networks and clocks (Brian 1 –> 2 conversion)

EmpiricalThreshold

string expression

Neural models (Brian 1 –> 2 conversion)

EventClock

Clock

Networks and clocks (Brian 1 –> 2 conversion)

exp_conductance

[Equations]

Library models (Brian 1 –> 2 conversion)

exp_current

[Equations]

Library models (Brian 1 –> 2 conversion)

exp_IF

[Equations]

Library models (Brian 1 –> 2 conversion)

exp_synapse

[Equations]

Library models (Brian 1 –> 2 conversion)

FileSpikeMonitor

# 298

Monitors (Brian 1 –> 2 conversion)

FloatClock

Clock

Networks and clocks (Brian 1 –> 2 conversion)

FunReset

[string expression]

Neural models (Brian 1 –> 2 conversion)

FunThreshold

[string expression]

Neural models (Brian 1 –> 2 conversion)

hist_plot

no equivalent

HomogeneousPoissonThreshold

string expression

Neural models (Brian 1 –> 2 conversion)

IdentityConnection

Synapses

Synapses (Brian 1 –> 2 conversion)

IonicCurrent

# 443

Multicompartmental models (Brian 1 –> 2 conversion)

ISIHistogramMonitor

[SpikeMonitor]

Monitors (Brian 1 –> 2 conversion)

Izhikevich

[Equations]

Library models (Brian 1 –> 2 conversion)

K_current_HH

[Equations]

Library models (Brian 1 –> 2 conversion)

leak_current

[Equations]

Library models (Brian 1 –> 2 conversion)

leaky_IF

[Equations]

Library models (Brian 1 –> 2 conversion)

MembraneEquation

# 443

Multicompartmental models (Brian 1 –> 2 conversion)

MultiStateMonitor

StateMonitor

Monitors (Brian 1 –> 2 conversion)

Na_current_HH

[Equations]

Library models (Brian 1 –> 2 conversion)

NaiveClock

Clock

Networks and clocks (Brian 1 –> 2 conversion)

NoReset

obsolete

Neural models (Brian 1 –> 2 conversion)

NoThreshold

obsolete

Neural models (Brian 1 –> 2 conversion)

OfflinePoissonGroup

[SpikeGeneratorGroup]

Inputs (Brian 1 –> 2 conversion)

OrnsteinUhlenbeck

[Equations]

Library models (Brian 1 –> 2 conversion)

perfect_IF

[Equations]

Library models (Brian 1 –> 2 conversion)

PoissonThreshold

string expression

Neural models (Brian 1 –> 2 conversion)

PopulationSpikeCounter

SpikeMonitor

Monitors (Brian 1 –> 2 conversion)

PulsePacket

[SpikeGeneratorGroup]

Inputs (Brian 1 –> 2 conversion)

quadratic_IF

[Equations]

Library models (Brian 1 –> 2 conversion)

raster_plot

plot_raster (brian2tools)

brian2tools documentation

RecentStateMonitor

no direct equivalent

Monitors (Brian 1 –> 2 conversion)

Refractoriness

string expression

Neural models (Brian 1 –> 2 conversion)

RegularClock

Clock

Networks and clocks (Brian 1 –> 2 conversion)

Reset

string expression

Neural models (Brian 1 –> 2 conversion)

SimpleCustomRefractoriness

[string expression]

Neural models (Brian 1 –> 2 conversion)

SimpleFunThreshold

[string expression]

Neural models (Brian 1 –> 2 conversion)

SpikeCounter

SpikeMonitor

Monitors (Brian 1 –> 2 conversion)

StateHistogramMonitor

[StateMonitor]

Monitors (Brian 1 –> 2 conversion)

StateSpikeMonitor

SpikeMonitor

Monitors (Brian 1 –> 2 conversion)

STDP

[Synapses]

Synapses (Brian 1 –> 2 conversion)

STP

[Synapses]

Synapses (Brian 1 –> 2 conversion)

StringReset

string expression

Neural models (Brian 1 –> 2 conversion)

StringThreshold

string expression

Neural models (Brian 1 –> 2 conversion)

Threshold

string expression

Neural models (Brian 1 –> 2 conversion)

VanRossumMetric

[SpikeMonitor]

Monitors (Brian 1 –> 2 conversion)

VariableReset

string expression

Neural models (Brian 1 –> 2 conversion)

VariableThreshold

string expression

Neural models (Brian 1 –> 2 conversion)

List of detailed instructions