| 1 |
#!/usr/bin/env python |
| 2 |
""" |
| 3 |
Jeffress model, adapted with spiking neuron models. |
| 4 |
A sound source (white noise) is moving around the head. |
| 5 |
Delay differences between the two ears are used to determine the azimuth of the |
| 6 |
source. Delays are mapped to a neural place code using delay lines (each neuron |
| 7 |
receives input from both ears, with different delays). |
| 8 |
""" |
| 9 |
from brian2 import * |
| 10 |
|
| 11 |
defaultclock.dt = .02*ms |
| 12 |
|
| 13 |
# Sound |
| 14 |
sound = TimedArray(10 * randn(50000), dt=defaultclock.dt) # white noise |
| 15 |
|
| 16 |
# Ears and sound motion around the head (constant angular speed) |
| 17 |
sound_speed = 300*metre/second |
| 18 |
interaural_distance = 20*cm # big head! |
| 19 |
max_delay = interaural_distance / sound_speed |
| 20 |
print("Maximum interaural delay: %s" % max_delay) |
| 21 |
angular_speed = 2 * pi / second # 1 turn/second |
| 22 |
tau_ear = 1*ms |
| 23 |
sigma_ear = .1 |
| 24 |
eqs_ears = ''' |
| 25 |
dx/dt = (sound(t-delay)-x)/tau_ear+sigma_ear*(2./tau_ear)**.5*xi : 1 (unless refractory) |
| 26 |
delay = distance*sin(theta) : second |
| 27 |
distance : second # distance to the centre of the head in time units |
| 28 |
dtheta/dt = angular_speed : radian |
| 29 |
''' |
| 30 |
ears = NeuronGroup(2, eqs_ears, threshold='x>1', reset='x = 0', |
| 31 |
refractory=2.5*ms, name='ears', method='euler') |
| 32 |
ears.distance = [-.5 * max_delay, .5 * max_delay] |
| 33 |
traces = StateMonitor(ears, 'delay', record=True) |
| 34 |
# Coincidence detectors |
| 35 |
num_neurons = 30 |
| 36 |
tau = 1*ms |
| 37 |
sigma = .1 |
| 38 |
eqs_neurons = ''' |
| 39 |
dv/dt = -v / tau + sigma * (2 / tau)**.5 * xi : 1 |
| 40 |
''' |
| 41 |
neurons = NeuronGroup(num_neurons, eqs_neurons, threshold='v>1', |
| 42 |
reset='v = 0', name='neurons', method='euler') |
| 43 |
|
| 44 |
synapses = Synapses(ears, neurons, on_pre='v += .5') |
| 45 |
synapses.connect() |
| 46 |
|
| 47 |
synapses.delay['i==0'] = '(1.0*j)/(num_neurons-1)*1.1*max_delay' |
| 48 |
synapses.delay['i==1'] = '(1.0*(num_neurons-j-1))/(num_neurons-1)*1.1*max_delay' |
| 49 |
|
| 50 |
spikes = SpikeMonitor(neurons) |
| 51 |
|
| 52 |
run(1000*ms) |
| 53 |
|
| 54 |
# Plot the results |
| 55 |
i, t = spikes.it |
| 56 |
subplot(2, 1, 1) |
| 57 |
plot(t/ms, i, '.') |
| 58 |
xlabel('Time (ms)') |
| 59 |
ylabel('Neuron index') |
| 60 |
xlim(0, 1000) |
| 61 |
subplot(2, 1, 2) |
| 62 |
plot(traces.t/ms, traces.delay.T/ms) |
| 63 |
xlabel('Time (ms)') |
| 64 |
ylabel('Input delay (ms)') |
| 65 |
xlim(0, 1000) |
| 66 |
tight_layout() |
| 67 |
show() |