load_file("stdrun.hoc")
cvode_active(1)
steps_per_ms = 10
dt = 0.1
tstop = 100
Rm = 220e3
SpineFactor = 2
RmSoma = Rm
RmDend = Rm / SpineFactor
Cm = 0.8
CmSoma = Cm
CmDend = Cm*SpineFactor
RaAll = 200
RaSoma = 200
Vrest = -70
celsius = 30.0
strdef MorphName
MorphName = "L22.hoc"
xopen(MorphName)
gNa = 20e-3
gKdr = 0.0036
gKd = 0.003
gKdAxon = 0.005
gKa = 0.023
gKh = 1e-6
maxdist = 300
KaDt = 50
KaSlope = 5.5e-5
KdDt = 150
KdSlope = 0
NaDt = 150
AXONM = 5
SomaNa = 1
DendNa = 0.2
DendKd = 0.1
NaSlope = 9.615e-05
xopen("fixnseg.hoc")
proc ins_pasive() {
forall if(issection("soma")) {
insert pas
e_pas = Vrest
g_pas = 1 / RmSoma
Ra = RaSoma
cm = CmSoma
} else {
insert pas
e_pas = Vrest
g_pas = 1 / RmDend
Ra = RaAll
cm = CmDend
}
}
proc dist_NaKJ() {local xdist
forall gbar_Na = gNa
forsec "soma" gbar_Na = gNa*SomaNa
forsec "axon" gbar_Na = gNa*AXONM
gNaDend = gNa*DendNa
forall for (x) if(issection("apical_dendrite.*")) {
xdist = abs(distance(x))
if((xdist > NaDt)&&(gNa>0)) {
gbar_Na(x) = gNaDend + NaSlope*(xdist-NaDt)
} else gbar_Na(x) = gNaDend
}
}
proc dist_Kdr() {
forall gbar_Kdr = gKdr
}
proc dist_Ka() {local xdist
forall for (x) if(!issection("axon.*")) {
gbar_KaProx(x) = gKa
xdist = abs(distance(x))
if(xdist > KaDt) gbar_KaProx(x) = gKa + KaSlope * (xdist - KaDt)
}
}
proc dist_Kd() {
forall gbar_KdBG = gKd*DendKd
forall for (x) if(issection("apical_dendrite.*")) {
xdist = abs(distance(x))
if(xdist > KdDt) gbar_KdBG(x) = gKd
} else {
if(issection("axon.*")) gbar_KdBG = gKdAxon
}
}
proc dist_Khd() {local xdist
ehd_KhdM01 = -50
forall for(x) if(!issection("axon.*")) {
ghdbar_KhdM01(x) = gKh
}
}
proc condkd() {local factor
dist_Kd()
if($1!=1) forall for(x) gbar_KdBG(x)*=$1
}
proc condkdlocal() {local blockdist, bdistal
dist_Kd()
forall for (x) if(issection("apical_dendrite.*")) {
xdist = abs(distance(x))
if($2>0) {
if(xdist > $1) gbar_KdBG(x) = 0
} else {
if(xdist < $1) gbar_KdBG(x) = 0
}
}
}
proc condNa() {local factor
dist_NaKJ()
if($1!=1) forall for(x) gbar_Na(x)*=$1
}
proc ins_active() {
forsec "soma" {
insert Na
insert Kdr
insert KaProx
insert KdBG
insert KhdM01
}
forsec "dendrite" {
insert Na
insert Kdr
insert KaProx
insert KdBG
insert KhdM01
}
forsec "axon" {
insert Na
insert Kdr
insert KaProx
insert KdBG
}
}
proc dist_active() {
dist_NaKJ()
dist_Kdr()
dist_Ka()
dist_Kd()
dist_Khd()
forsec "axon" {
gbar_Kdr=gKdr
gbar_KaProx=gKa
}
}
proc init() {
forall {
v = Vrest
ek = -91
ena = 50
e_pas = Vrest
}
finitialize(Vrest)
fcurrent()
forall if(!issection("axon.*")) {
for (x) e_pas(x) = v(x) + ( ina(x) + ik(x) + i_KhdM01(x) ) / g_pas(x)
} else {
e_pas(x)=v(x)+(ina(x)+ik(x))/g_pas(x)
}
finitialize(Vrest)
}
proc mesh_init() {local maxdist
geom_nseg()
access soma
soma distance()
forall for(x) {if (distance(x)>maxdist) {maxdist=distance(x)}}
print "maxdist = ", maxdist
dist_active()
}
objectvar vc, cc
objref gvc
objref rect, recy, recy1, recy2, recy3
objref dfile, pfile, temp
graphvmax = -60
graphimax = 1.5
durIinj = 500
durcctail = 500
Vhold = -80
proc setupvc() {local Tprestep, Tstep
Tprestep = $1
Tstep = $2
access soma
vc = new SEClamp(0.5)
if(!yescc) Vrest = -80
vc.rs = 10
vc.dur1 = Tprestep
vc.dur2 = Tstep
vc.dur3 = 100
vc.amp1 = Vhold
vc.amp2 = -30
vc.amp3 = Vrest
cc = new IClamp(0.5)
cc.amp = 0
cc.dur = Tstep
if(durIinj>50) cc.del = 50 else cc.del = durIinj
if(yescc) {
tstop = cc.del + cc.dur + durcctail
} else {
tstop = vc.dur1 + vc.dur2 + vc.dur3
}
graphvc()
}
proc vcmode() {local step2
cc.amp = 0
vc.rs = 10
vc.amp1 = Vhold
vc.amp2 = $1
vc.amp3 = Vrest
}
proc ccmode() {local amp
vc.rs = 1e15
cc.amp = $1
}
proc graphvc() {
gvc = new Graph(0)
if(yescc) {
gvc.view(0, -90, tstop, (graphvmax+90), 0, 700, 900, 500)
} else {
gvc.view(0, -0.2, tstop, (graphimax+0.2), 0, 700, 900, 500)
}
gvc.xaxis(0)
if(yescc) gvc.addvar("soma.v(0.5)", 2, 1) else gvc.addvar("vc.i", 3, 1)
}
proc stepvc() {
fadvance()
gvc.plot(t)
gvc.fastflush()
doNotify()
}
proc runvc() { local overlap
init()
if (!$1) {
gvc.erase()
}
while(t<tstop) { stepvc()}
gvc.flush()
}
Ndsynmax = 9
objectvar syn3[Ndsynmax], syn2[Ndsynmax], syn1
objectvar ns, acnc[Ndsynmax], ppnc[Ndsynmax], mfnc
objref gepsp
gheight = 30
double wt[5]
proc setupsynapse() { local sr
sr = $1
if(sr){
access apical_dendrite[5]
syn3[0] = new GluSyn(0.8)
syn3[1] = new GluSyn(0.9)
syn3[2] = new GluSyn(0.7)
syn3[3] = new GluSyn(0.75)
syn3[4] = new GluSyn(0.85)
access apical_dendrite[13]
syn3[5] = new GluSyn(0.8)
access apical_dendrite[26]
syn3[6] = new GluSyn(0.8)
access apical_dendrite[40]
syn3[7] = new GluSyn(0.9)
access apical_dendrite[41]
syn3[8] = new GluSyn(0.95)
} else {
access apical_dendrite[5]
syn3[0] = new GluSyn(0.8)
access apical_dendrite[13]
syn3[1] = new GluSyn(0.8)
access apical_dendrite[26]
syn3[2] = new GluSyn(0.8)
access apical_dendrite[35]
syn3[3] = new GluSyn(0.5)
access apical_dendrite[37]
syn3[4] = new GluSyn(0.9)
access apical_dendrite[42]
syn3[5] = new GluSyn(0.9)
access apical_dendrite[40]
syn3[6] = new GluSyn(0.9)
access apical_dendrite[33]
syn3[7] = new GluSyn(0.95)
access apical_dendrite[27]
syn3[8] = new GluSyn(0.9)
}
access apical_dendrite[4]
syn2[0] = new GluSyn(0.5)
access apical_dendrite[10]
syn2[1] = new GluSyn(0.5)
access apical_dendrite[19]
syn2[2] = new GluSyn(0.5)
access apical_dendrite[25]
syn2[3] = new GluSyn(0.5)
access apical_dendrite[39]
syn2[4] = new GluSyn(0.5)
access apical_dendrite[30]
syn2[5] = new GluSyn(0.3)
access apical_dendrite[34]
syn2[6] = new GluSyn(0.3)
access apical_dendrite[42]
syn2[7] = new GluSyn(0.3)
access apical_dendrite[21]
syn2[8] = new GluSyn(0.2)
for(i=0;i<Ndsynmax;i+=1){
syn3[i].tau1 = atau
syn3[i].ntar = NAratio
syn3[i].tau3 = ntau
syn3[i].tauD = tauD
syn3[i].tauF = tauF
syn3[i].Pb = p0
syn3[i].f = Af
ppnc[i] = new NetCon(ns, syn3[i], 0,0,0)
ppnc[i].weight = 0
syn2[i].tau1 = atau
syn2[i].ntar = NAratio
syn2[i].tau3 = ntau
syn2[i].tauD = tauD
syn2[i].tauF = tauF
syn2[i].Pb = p0
syn2[i].f = Af
acnc[i] = new NetCon(ns, syn2[i], 0,0,0)
acnc[i].weight = 0
}
access apical_dendrite[1]
syn1 = new GluSyn(0.5)
syn1.e = 0
syn1.tau1 = atau
syn1.ntar = NAratio
syn1.tauD = taudmf
syn1.tauF = taufmf
syn1.Pb = p0mf
syn1.f = Afmf
mfnc = new NetCon(ns, syn1, 0,0,0)
mfnc.weight = 0
}
proc epsc1(){ local gmax
gmax = $1
resetsyn()
mfnc.weight = gmax
}
proc epsc2(){ local gmax
gmax = $1
resetsyn()
for(i=0;i<Ndsyn;i+=1){
acnc[i].weight = gmax
}
}
proc epsc3(){ local gmax
gmax = $1
resetsyn()
for(i=0;i<Ndsyn;i+=1){
ppnc[i].weight = gmax
}
}
proc resetsyn() {
mfnc.weight = 0
for(i=0;i<Ndsynmax;i+=1){
acnc[i].weight = 0
ppnc[i].weight = 0
}
}
proc graphepsp() {
gepsp = new Graph(0)
gepsp.view(0, Vrest-1, tstop, gheight, 0, 700, 900, 500)
gepsp.xaxis(0)
gepsp.addvar("soma.v(0.5)", 3, 1)
gepsp.addvar("apical_dendrite[4].v(0.5)", 2,1)
gepsp.addvar("apical_dendrite[5].v(0.7)", 4,1)
}
proc stepepsp() {
fadvance()
gepsp.plot(t)
gepsp.fastflush()
doNotify()
}
proc runepsp() { local overlap
init()
if (!$1) gepsp.erase()
while(t<tstop) { stepepsp()}
gepsp.flush()
}
proc runsyn() {local loc, overlap, fileidx
loc = $1
weight = wt[loc]
if(loc==1) epsc1(weight)
if(loc==2) epsc2(weight)
if(loc==3) epsc3(weight)
runepsp($2)
}