File: examples-hears_simple_anf.txt

package info (click to toggle)
brian 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 23,436 kB
  • sloc: python: 68,707; cpp: 29,040; ansic: 5,182; sh: 111; makefile: 61
file content (51 lines) | stat: -rw-r--r-- 1,270 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
.. currentmodule:: brian

.. index::
   pair: example usage; tone
   pair: example usage; Gammatone
   pair: example usage; FunctionFilterbank
   pair: example usage; show
   pair: example usage; raster_plot
   pair: example usage; erbspace
   pair: example usage; FilterbankGroup
   pair: example usage; SpikeMonitor
   pair: example usage; whitenoise
   pair: example usage; run

.. _example-hears_simple_anf:

Example: simple_anf (hears)
===========================

Example of a simple auditory nerve fibre model with Brian hears.

::

    from brian import *
    from brian.hears import *
    
    sound1 = tone(1*kHz, .1*second)
    sound2 = whitenoise(.1*second)
    
    sound = sound1+sound2
    sound = sound.ramp()
    
    cf = erbspace(20*Hz, 20*kHz, 3000)
    cochlea = Gammatone(sound, cf)
    
    # Half-wave rectification and compression [x]^(1/3)
    ihc = FunctionFilterbank(cochlea, lambda x: 3*clip(x, 0, Inf)**(1.0/3.0))
    
    # Leaky integrate-and-fire model with noise and refractoriness
    eqs = '''
    dv/dt = (I-v)/(1*ms)+0.2*xi*(2/(1*ms))**.5 : 1
    I : 1
    '''
    anf = FilterbankGroup(ihc, 'I', eqs, reset=0, threshold=1, refractory=5*ms)
    
    M = SpikeMonitor(anf)
    run(sound.duration)
    raster_plot(M)
    show()