Debian Codegraph @

docs_sphinx/introduction/brian1_to_2/brian1hears_bridge.rst

raw
1 .. _brian_hears:
2
3 Brian Hears
4 ===========
5
6 .. currentmodule:: brian2.hears
7
8 .. deprecated:: 2.2.2.2
9 Use the `brian2hears <https://brian2hears.readthedocs.io/>`_ package instead.
10
11 This module is designed for users of the Brian 1 library "Brian Hears". It allows you to use Brian Hears with Brian 2
12 with only a few modifications (although it's not compatible with the "standalone" mode of Brian 2).
13 The way it works is by acting as a "bridge" to the version in Brian 1. To
14 make this work, you must have a copy of Brian 1 installed (preferably the latest version), and import Brian Hears
15 using::
16
17 from brian2.hears import *
18
19 Many scripts will run without any changes, but there are a few caveats to be aware of. Mostly, the problems are due
20 to the fact that the units system in Brian 2 is not 100% compatible with the units system of Brian 1.
21
22 `FilterbankGroup` now follows the rules for `NeuronGroup` in Brian 2, which means some changes may be
23 necessary to match the syntax of Brian 2, for example, the following would work in Brian 1 Hears::
24
25 # Leaky integrate-and-fire model with noise and refractoriness
26 eqs = '''
27 dv/dt = (I-v)/(1*ms)+0.2*xi*(2/(1*ms))**.5 : 1
28 I : 1
29 '''
30 anf = FilterbankGroup(ihc, 'I', eqs, reset=0, threshold=1, refractory=5*ms)
31
32 However, in Brian 2 Hears you would need to do::
33
34 # Leaky integrate-and-fire model with noise and refractoriness
35 eqs = '''
36 dv/dt = (I-v)/(1*ms)+0.2*xi*(2/(1*ms))**.5 : 1 (unless refractory)
37 I : 1
38 '''
39 anf = FilterbankGroup(ihc, 'I', eqs, reset='v=0', threshold='v>1', refractory=5*ms)
40
41 Slicing sounds no longer works. Previously you could do, e.g. ``sound[:20*ms]`` but with Brian 2 you would need
42 to do ``sound.slice(0*ms, 20*ms)``.
43
44 In addition, some functions may not work correctly with Brian 2 units. In most circumstances, Brian 2 units can be
45 used interchangeably with Brian 1 units in the bridge, but in some cases it may be necessary to convert units from
46 one format to another, and to do that you can use the functions `convert_unit_b1_to_b2` and `convert_unit_b2_to_b1`.
47
48 .. _`Brian Hears`: http://brian.readthedocs.org/en/latest/hears.html