Debian Codegraph @

examples/phase_locking.py

raw
1 #!/usr/bin/env python
2 """
3 Phase locking of IF neurons to a periodic input.
4 """
5 from brian2 import *
6
7 tau = 20*ms
8 n = 100
9 b = 1.2 # constant current mean, the modulation varies
10 freq = 10*Hz
11
12 eqs = '''
13 dv/dt = (-v + a * sin(2 * pi * freq * t) + b) / tau : 1
14 a : 1
15 '''
16 neurons = NeuronGroup(n, model=eqs, threshold='v > 1', reset='v = 0',
17 method='euler')
18 neurons.v = 'rand()'
19 neurons.a = '0.05 + 0.7*i/n'
20 S = SpikeMonitor(neurons)
21 trace = StateMonitor(neurons, 'v', record=50)
22
23 run(1000*ms)
24 subplot(211)
25 plot(S.t/ms, S.i, '.k')
26 xlabel('Time (ms)')
27 ylabel('Neuron index')
28 subplot(212)
29 plot(trace.t/ms, trace.v.T)
30 xlabel('Time (ms)')
31 ylabel('v')
32 tight_layout()
33 show()