~ubuntu-branches/ubuntu/wily/brian/wily

« back to all changes in this revision

Viewing changes to docs_sphinx/examples-audition_filterbank.txt

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2014-07-30 11:29:44 UTC
  • mfrom: (6.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20140730112944-ln0ogbq0kpyyuz47
Tags: 1.4.1-2
* Forgotten upload to unstable
* debian/control
  - policy boost to 3.9.5
  - updated Vcs- fields given migration to anonscm.d.o and provided -b
    debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.. currentmodule:: brian
2
 
 
3
 
.. index::
4
 
   pair: example usage; NeuronGroup
5
 
   pair: example usage; run
6
 
   pair: example usage; PoissonThreshold
7
 
   pair: example usage; SpikeMonitor
8
 
   pair: example usage; gain
9
 
   pair: example usage; SpikeCounter
10
 
 
11
 
.. _example-audition_filterbank:
12
 
 
13
 
Example: filterbank (audition)
14
 
==============================
15
 
 
16
 
An auditory filterbank implemented with Poisson neurons
17
 
 
18
 
The input sound has a missing fundamental (only harmonics 2 and 3)
19
 
 
20
 
::
21
 
 
22
 
    from brian import *
23
 
    
24
 
    defaultclock.dt = .01 * ms
25
 
    
26
 
    N = 1500
27
 
    tau = 1 * ms # Decay time constant of filters = 2*tau
28
 
    freq = linspace(100 * Hz, 2000 * Hz, N) # characteristic frequencies
29
 
    f_stimulus = 500 * Hz # stimulus frequency
30
 
    gain = 500 * Hz
31
 
    
32
 
    eqs = '''
33
 
    dv/dt=(-a*w-v+I)/tau : Hz
34
 
    dw/dt=(v-w)/tau : Hz # e.g. linearized potassium channel with conductance a
35
 
    a : 1
36
 
    I = gain*(sin(4*pi*f_stimulus*t)+sin(6*pi*f_stimulus*t)) : Hz
37
 
    '''
38
 
    
39
 
    neurones = NeuronGroup(N, model=eqs, threshold=PoissonThreshold())
40
 
    neurones.a = (2 * pi * freq * tau) ** 2
41
 
    
42
 
    spikes = SpikeMonitor(neurones)
43
 
    counter = SpikeCounter(neurones)
44
 
    run(100 * ms)
45
 
    
46
 
    subplot(121)
47
 
    CF = array([freq[i] for i, _ in spikes.spikes])
48
 
    timings = array([t for _, t in spikes.spikes])
49
 
    plot(timings / ms, CF, '.')
50
 
    xlabel('Time (ms)')
51
 
    ylabel('Characteristic frequency (Hz)')
52
 
    subplot(122)
53
 
    plot(counter.count / (300 * ms), freq)
54
 
    xlabel('Firing rate (Hz)')
55
 
    show()
56
 
    
57
 
 
 
1
.. currentmodule:: brian
 
2
 
 
3
.. index::
 
4
   pair: example usage; NeuronGroup
 
5
   pair: example usage; run
 
6
   pair: example usage; PoissonThreshold
 
7
   pair: example usage; SpikeMonitor
 
8
   pair: example usage; gain
 
9
   pair: example usage; SpikeCounter
 
10
 
 
11
.. _example-audition_filterbank:
 
12
 
 
13
Example: filterbank (audition)
 
14
==============================
 
15
 
 
16
An auditory filterbank implemented with Poisson neurons
 
17
 
 
18
The input sound has a missing fundamental (only harmonics 2 and 3)
 
19
 
 
20
::
 
21
 
 
22
    from brian import *
 
23
    
 
24
    defaultclock.dt = .01 * ms
 
25
    
 
26
    N = 1500
 
27
    tau = 1 * ms # Decay time constant of filters = 2*tau
 
28
    freq = linspace(100 * Hz, 2000 * Hz, N) # characteristic frequencies
 
29
    f_stimulus = 500 * Hz # stimulus frequency
 
30
    gain = 500 * Hz
 
31
    
 
32
    eqs = '''
 
33
    dv/dt=(-a*w-v+I)/tau : Hz
 
34
    dw/dt=(v-w)/tau : Hz # e.g. linearized potassium channel with conductance a
 
35
    a : 1
 
36
    I = gain*(sin(4*pi*f_stimulus*t)+sin(6*pi*f_stimulus*t)) : Hz
 
37
    '''
 
38
    
 
39
    neurones = NeuronGroup(N, model=eqs, threshold=PoissonThreshold())
 
40
    neurones.a = (2 * pi * freq * tau) ** 2
 
41
    
 
42
    spikes = SpikeMonitor(neurones)
 
43
    counter = SpikeCounter(neurones)
 
44
    run(100 * ms)
 
45
    
 
46
    subplot(121)
 
47
    CF = array([freq[i] for i, _ in spikes.spikes])
 
48
    timings = array([t for _, t in spikes.spikes])
 
49
    plot(timings / ms, CF, '.')
 
50
    xlabel('Time (ms)')
 
51
    ylabel('Characteristic frequency (Hz)')
 
52
    subplot(122)
 
53
    plot(counter.count / (300 * ms), freq)
 
54
    xlabel('Firing rate (Hz)')
 
55
    show()
 
56
    
 
57