File: examples-hears_gammatone.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 (55 lines) | stat: -rw-r--r-- 1,654 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
52
53
54
55
.. currentmodule:: brian

.. index::
   pair: example usage; Gammatone
   pair: example usage; figure
   pair: example usage; title
   pair: example usage; imshow
   pair: example usage; erbspace
   pair: example usage; yscale
   pair: example usage; ylabel
   pair: example usage; show
   pair: example usage; xlabel
   pair: example usage; whitenoise

.. _example-hears_gammatone:

Example: gammatone (hears)
==========================

Example of the use of the class :class:`~brian.hears.Gammatone` available in the
library. It implements a fitlerbank of IIR gammatone filters as 
described  in Slaney, M., 1993, "An Efficient Implementation of the
Patterson-Holdsworth Auditory Filter Bank". Apple Computer Technical Report #35. 
In this example, a white noise is filtered by a gammatone filterbank and the
resulting cochleogram is plotted.

::

    from brian import *
    from brian.hears import *
    from matplotlib import pyplot
    
    sound = whitenoise(100*ms).ramp()
    sound.level = 50*dB
    
    nbr_center_frequencies = 50
    b1 = 1.019  #factor determining the time constant of the filters
    #center frequencies with a spacing following an ERB scale
    center_frequencies = erbspace(100*Hz, 1000*Hz, nbr_center_frequencies)
    gammatone = Gammatone(sound, center_frequencies, b=b1)
    
    gt_mon = gammatone.process()
    
    figure()
    imshow(gt_mon.T, aspect='auto', origin='lower left',
           extent=(0, sound.duration/ms,
                   center_frequencies[0], center_frequencies[-1]))
    pyplot.yscale('log')
    title('Cochleogram')
    ylabel('Frequency (Hz)')
    xlabel('Time (ms)')
    
    show()