Debian Codegraph @

docs_sphinx/introduction/changes.rst

raw
1 Changes for Brian 1 users
2 =========================
3 .. contents::
4 :local:
5 :depth: 1
6
7 .. note::
8
9 If you need to run existing Brian 1 simulations, have a look at
10 :doc:`brian1_to_2/container`.
11
12 In most cases, Brian 2 works in a very similar way to Brian 1 but there are
13 some important differences to be aware of. The major distinction is that
14 in Brian 2 you need to be more explicit about the definition of your
15 simulation in order to avoid inadvertent errors. In some cases, you will now
16 get a warning in other even an error -- often the error/warning message
17 describes a way to resolve the issue.
18
19 Specific examples how to convert code from Brian 1 can be found in the document
20 :doc:`brian1_to_2/index`.
21
22 Physical units
23 --------------
24 The unit system now extends to arrays, e.g. ``np.arange(5) * mV`` will retain
25 the units of volts and not discard them as Brian 1 did. Brian 2 is therefore
26 also more strict in checking the units. For example, if the state variable
27 ``v`` uses the unit of volt, the statement ``G.v = np.rand(len(G)) / 1000.``
28 will now raise an error. For consistency, units are returned everywhere, e.g.
29 in monitors. If ``mon`` records a state variable v, ``mon.t`` will return a
30 time in seconds and ``mon.v`` the stored values of ``v`` in units of volts.
31
32 If you need a pure numpy array without units for further processing, there
33 are several options: if it is a state variable or a recorded variable in a
34 monitor, appending an underscore will refer to the variable values without
35 units, e.g. ``mon.t_`` returns pure floating point values. Alternatively, you
36 can remove units by diving by the unit (e.g. ``mon.t / second``) or by
37 explicitly converting it (``np.asarray(mon.t)``).
38
39 Here's an overview showing a few expressions and their respective values in
40 Brian 1 and Brian 2:
41
42 ================================ ================================ =================================
43 Expression Brian 1 Brian 2
44 ================================ ================================ =================================
45 1 * mV 1.0 * mvolt 1.0 * mvolt
46 np.array(1) * mV 0.001 1.0 * mvolt
47 np.array([1]) * mV array([ 0.001]) array([1.]) * mvolt
48 np.mean(np.arange(5) * mV) 0.002 2.0 * mvolt
49 np.arange(2) * mV array([ 0. , 0.001]) array([ 0., 1.]) * mvolt
50 (np.arange(2) * mV) >= 1 * mV array([False, True], dtype=bool) array([False, True], dtype=bool)
51 (np.arange(2) * mV)[0] >= 1 * mV False False
52 (np.arange(2) * mV)[1] >= 1 * mV DimensionMismatchError True
53 ================================ ================================ =================================
54
55 Unported packages
56 -----------------
57 The following packages have not (yet) been ported to Brian 2. If your simulation
58 critically depends on them, you should consider staying with Brian 1 for now.
59
60 * ``brian.tools``
61 * ``brian.library.modelfitting``
62 * ``brian.library.electrophysiology``
63
64 Replacement packages
65 --------------------
66 The following packages that were included in Brian 1 have now been split into separate
67 packages.
68
69 * ``brian.hears`` has been updated to
70 `brian2hears <https://brian2hears.readthedocs.io/>`_. Note that there is a
71 legacy package ``brian2.hears`` included in ``brian2``, but this is now deprecated and
72 will be removed in a future release. For now, see :ref:`brian_hears` for details.
73
74 Removed classes/functions and their replacements
75 ------------------------------------------------
76 In Brian 2, we have tried to keep the number of classes/functions to a minimum, but make
77 each of them flexible enough to encompass a large number of use cases. A lot of the classes
78 and functions that existed in Brian 1 have therefore been removed.
79 The following table lists (most of) the classes that existed in Brian 1 but do no longer
80 exist in Brian 2. You can consult it when you get a ``NameError`` while converting an
81 existing script from Brian 1. The third column links to a document with further explanation
82 and the second column gives either:
83
84 1. the equivalent class in Brian 2 (e.g. `StateMonitor` can record multiple variables now
85 and therefore replaces ``MultiStateMonitor``);
86 2. the name of a Brian 2 class in square brackets (e.g. [`Synapses`] for ``STDP``), this
87 means that the class can be used as a replacement but needs some additional
88 code (e.g. explicitly specified STDP equations). The "More details" document should
89 help you in making the necessary changes;
90 3. "string expression", if the functionality of a previously existing class can
91 be expressed using the general string expression framework (e.g.
92 `threshold=VariableThreshold('Vt', 'V')` can be replaced by
93 `threshold='V > Vt'`);
94 4. a link to the relevant github issue if no equivalent class/function does exist so far
95 in Brian 2;
96 5. a remark such as "obsolete" if the particular class/function is no longer needed.
97
98 =============================== ================================= ================================================================
99 Brian 1 Brian 2 More details
100 =============================== ================================= ================================================================
101 ``AdEx`` [`Equations`] :doc:`brian1_to_2/library`
102 ``aEIF`` [`Equations`] :doc:`brian1_to_2/library`
103 ``AERSpikeMonitor`` :issue:`298` :doc:`brian1_to_2/monitors`
104 ``alpha_conductance`` [`Equations`] :doc:`brian1_to_2/library`
105 ``alpha_current`` [`Equations`] :doc:`brian1_to_2/library`
106 ``alpha_synapse`` [`Equations`] :doc:`brian1_to_2/library`
107 ``AutoCorrelogram`` [`SpikeMonitor`] :doc:`brian1_to_2/monitors`
108 ``biexpr_conductance`` [`Equations`] :doc:`brian1_to_2/library`
109 ``biexpr_current`` [`Equations`] :doc:`brian1_to_2/library`
110 ``biexpr_synapse`` [`Equations`] :doc:`brian1_to_2/library`
111 ``Brette_Gerstner`` [`Equations`] :doc:`brian1_to_2/library`
112 ``CoincidenceCounter`` [`SpikeMonitor`] :doc:`brian1_to_2/monitors`
113 ``CoincidenceMatrixCounter`` [`SpikeMonitor`] :doc:`brian1_to_2/monitors`
114 ``Compartments`` :issue:`443` :doc:`brian1_to_2/multicompartmental`
115 ``Connection`` `Synapses` :doc:`brian1_to_2/synapses`
116 ``Current`` :issue:`443` :doc:`brian1_to_2/multicompartmental`
117 ``CustomRefractoriness`` [string expression] :doc:`brian1_to_2/neurongroup`
118 ``DefaultClock`` `Clock` :doc:`brian1_to_2/networks_and_clocks`
119 ``EmpiricalThreshold`` string expression :doc:`brian1_to_2/neurongroup`
120 ``EventClock`` `Clock` :doc:`brian1_to_2/networks_and_clocks`
121 ``exp_conductance`` [`Equations`] :doc:`brian1_to_2/library`
122 ``exp_current`` [`Equations`] :doc:`brian1_to_2/library`
123 ``exp_IF`` [`Equations`] :doc:`brian1_to_2/library`
124 ``exp_synapse`` [`Equations`] :doc:`brian1_to_2/library`
125 ``FileSpikeMonitor`` :issue:`298` :doc:`brian1_to_2/monitors`
126 ``FloatClock`` `Clock` :doc:`brian1_to_2/networks_and_clocks`
127 ``FunReset`` [string expression] :doc:`brian1_to_2/neurongroup`
128 ``FunThreshold`` [string expression] :doc:`brian1_to_2/neurongroup`
129 ``hist_plot`` no equivalent --
130 ``HomogeneousPoissonThreshold`` string expression :doc:`brian1_to_2/neurongroup`
131 ``IdentityConnection`` `Synapses` :doc:`brian1_to_2/synapses`
132 ``IonicCurrent`` :issue:`443` :doc:`brian1_to_2/multicompartmental`
133 ``ISIHistogramMonitor`` [`SpikeMonitor`] :doc:`brian1_to_2/monitors`
134 ``Izhikevich`` [`Equations`] :doc:`brian1_to_2/library`
135 ``K_current_HH`` [`Equations`] :doc:`brian1_to_2/library`
136 ``leak_current`` [`Equations`] :doc:`brian1_to_2/library`
137 ``leaky_IF`` [`Equations`] :doc:`brian1_to_2/library`
138 ``MembraneEquation`` :issue:`443` :doc:`brian1_to_2/multicompartmental`
139 ``MultiStateMonitor`` `StateMonitor` :doc:`brian1_to_2/monitors`
140 ``Na_current_HH`` [`Equations`] :doc:`brian1_to_2/library`
141 ``NaiveClock`` `Clock` :doc:`brian1_to_2/networks_and_clocks`
142 ``NoReset`` obsolete :doc:`brian1_to_2/neurongroup`
143 ``NoThreshold`` obsolete :doc:`brian1_to_2/neurongroup`
144 ``OfflinePoissonGroup`` [`SpikeGeneratorGroup`] :doc:`brian1_to_2/inputs`
145 ``OrnsteinUhlenbeck`` [`Equations`] :doc:`brian1_to_2/library`
146 ``perfect_IF`` [`Equations`] :doc:`brian1_to_2/library`
147 ``PoissonThreshold`` string expression :doc:`brian1_to_2/neurongroup`
148 ``PopulationSpikeCounter`` `SpikeMonitor` :doc:`brian1_to_2/monitors`
149 ``PulsePacket`` [`SpikeGeneratorGroup`] :doc:`brian1_to_2/inputs`
150 ``quadratic_IF`` [`Equations`] :doc:`brian1_to_2/library`
151 ``raster_plot`` ``plot_raster`` (``brian2tools``) `brian2tools documentation <http://brian2tools.readthedocs.io>`_
152 ``RecentStateMonitor`` no direct equivalent :doc:`brian1_to_2/monitors`
153 ``Refractoriness`` string expression :doc:`brian1_to_2/neurongroup`
154 ``RegularClock`` `Clock` :doc:`brian1_to_2/networks_and_clocks`
155 ``Reset`` string expression :doc:`brian1_to_2/neurongroup`
156 ``SimpleCustomRefractoriness`` [string expression] :doc:`brian1_to_2/neurongroup`
157 ``SimpleFunThreshold`` [string expression] :doc:`brian1_to_2/neurongroup`
158 ``SpikeCounter`` `SpikeMonitor` :doc:`brian1_to_2/monitors`
159 ``StateHistogramMonitor`` [`StateMonitor`] :doc:`brian1_to_2/monitors`
160 ``StateSpikeMonitor`` `SpikeMonitor` :doc:`brian1_to_2/monitors`
161 ``STDP`` [`Synapses`] :doc:`brian1_to_2/synapses`
162 ``STP`` [`Synapses`] :doc:`brian1_to_2/synapses`
163 ``StringReset`` string expression :doc:`brian1_to_2/neurongroup`
164 ``StringThreshold`` string expression :doc:`brian1_to_2/neurongroup`
165 ``Threshold`` string expression :doc:`brian1_to_2/neurongroup`
166 ``VanRossumMetric`` [`SpikeMonitor`] :doc:`brian1_to_2/monitors`
167 ``VariableReset`` string expression :doc:`brian1_to_2/neurongroup`
168 ``VariableThreshold`` string expression :doc:`brian1_to_2/neurongroup`
169 =============================== ================================= ================================================================
170
171 List of detailed instructions
172 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173
174 .. toctree::
175 :maxdepth: 2
176
177 brian1_to_2/index