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

« back to all changes in this revision

Viewing changes to examples/synapses/licklider.py

  • 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
#!/usr/bin/env python
 
2
'''
 
3
Spike-based adaptation of Licklider's model of pitch processing (autocorrelation with
 
4
delay lines) with phase locking.
 
5
 
 
6
Romain Brette
 
7
'''
 
8
from brian import *
 
9
 
 
10
defaultclock.dt = .02 * ms
 
11
 
 
12
# Ear and sound
 
13
max_delay = 20 * ms # 50 Hz
 
14
tau_ear = 1 * ms
 
15
sigma_ear = .1
 
16
eqs_ear = '''
 
17
dx/dt=(sound-x)/tau_ear+sigma_ear*(2./tau_ear)**.5*xi : 1
 
18
sound=5*sin(2*pi*frequency*t)**3 : 1 # nonlinear distorsion
 
19
#sound=5*(sin(4*pi*frequency*t)+.5*sin(6*pi*frequency*t)) : 1 # missing fundamental
 
20
frequency=(200+200*t*Hz)*Hz : Hz # increasing pitch
 
21
'''
 
22
receptors = NeuronGroup(2, model=eqs_ear, threshold=1, reset=0, refractory=2 * ms)
 
23
 
 
24
# Coincidence detectors
 
25
min_freq = 50 * Hz
 
26
max_freq = 1000 * Hz
 
27
N = 300
 
28
tau = 1 * ms
 
29
sigma = .1
 
30
eqs_neurons = '''
 
31
dv/dt=-v/tau+sigma*(2./tau)**.5*xi : 1
 
32
'''
 
33
neurons = NeuronGroup(N, model=eqs_neurons, threshold=1, reset=0)
 
34
synapses = Synapses(receptors, neurons, model='w : 1', pre='v+=w')
 
35
synapses[:,:]=True
 
36
synapses.w=0.5
 
37
synapses.delay[1, :] = 1. / exp(linspace(log(min_freq / Hz), log(max_freq / Hz), N))
 
38
spikes = SpikeMonitor(neurons)
 
39
 
 
40
run(500 * ms)
 
41
raster_plot(spikes)
 
42
ylabel('Frequency')
 
43
yticks([0, 99, 199, 299], array(1. / synapses.delay[1, [0, 99, 199, 299]], dtype=int))
 
44
show()