-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbidimensionalIF.py
55 lines (46 loc) · 979 Bytes
/
bidimensionalIF.py
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
from brian import *
from brian.library.IF import *
import time
cl=Clock(dt=0.1*ms)
N=1000
Vr=-70.6*mV+20*mV
C=281*pF
gL=30*nS
EL=-70.6*mV
VT=-50.4*mV
DeltaT=2*mV
tauw=.1*144*ms
a=4*nS
b=0.0805*nA
eqs="""
dvm/dt=(gL*(EL-vm)+gL*DeltaT*exp((vm-VT)/DeltaT)+I-w)/C : volt
dw/dt=(a*(vm-EL)-w)/tauw : amp
I : amp
w0 : amp
"""
# Computes phi(w)
wmin=-1*nA
wmax=3*nA
def myreset(P,spikes):
P.vm_[spikes]=Vr
P.w_[spikes]=rand(len(spikes))*(wmax-wmin)+wmin
P.w0_[spikes]=P.w_[spikes]
neuron=NeuronGroup(N,model=eqs,threshold=-20*mV,reset=myreset)
neuron.vm=Vr
neuron.w=rand(N)*(wmax-wmin)+wmin
neuron.w0=neuron.w
neuron.I=1*nA
w=[]
phiw=[]
def record_spikes(spikes):
w.extend(neuron.w0[spikes])
phiw.extend(neuron.w[spikes])
mon=SpikeMonitor(neuron,function=record_spikes)
start_time=time.time()
run(500*ms)
print len(phiw)
print time.time()-start_time
phiw=qarray(phiw)+0.0805*nA
plot(qarray(w)/nA,phiw/nA,'.')
plot([wmin/nA,wmax/nA],[wmin/nA,wmax/nA])
show()