proc celldef() {
  topol()
  subsets()
  geom()
  biophys()
  
}

create soma, ABD[4], interD[3], interD_sec[2], axonstart, AIS, axon
create axoD, nABD[3], nABD_sec[23]

proc topol() { local i
  connect ABD(0), soma(1)
  for i = 1, 3 connect ABD[i](0), ABD[i-1](1)
  for i = 0, 2 connect interD[i](0), ABD[i](1)
  for i = 0, 1 connect interD_sec[i](0), interD(1)
  connect axonstart(0), ABD[3](1)
  connect AIS(0), axonstart(1)
  connect axon(0), AIS(1)
  connect axoD(0), ABD[3](1)
  for i = 0, 2 connect nABD[i](0), soma(0)
  for i = 0, 1 connect nABD_sec[i](0), nABD[2](1)
  for i = 2, 3 connect nABD_sec[i](0), nABD[1](1)
  for i = 4, 5 connect nABD_sec[i](0), nABD_sec[3](1)
  for i = 6, 7 connect nABD_sec[i](0), nABD_sec[5](1)
  for i = 8, 9 connect nABD_sec[i](0), nABD(1)
  for i = 10, 11 connect nABD_sec[i](0), nABD_sec[9](1)
  for i = 12, 13 connect nABD_sec[i](0), nABD_sec[11](1)
  for i = 14, 16 connect nABD_sec[i](0), nABD_sec[10](1)
  for i = 17, 18 connect nABD_sec[i](0), nABD_sec[14](1)
  for i = 19, 20 connect nABD_sec[i](0), nABD_sec[15](1)
  for i = 21, 22 connect nABD_sec[i](0), nABD_sec[16](1)
  basic_shape()
}
proc basic_shape() {
  soma {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(15, 0, 0, 1)}
  ABD {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(45, 15, 0, 1)}
  ABD[1] {pt3dclear() pt3dadd(45, 15, 0, 1) pt3dadd(90, 0, 0, 1)}
  ABD[2] {pt3dclear() pt3dadd(90, 0, 0, 1) pt3dadd(105, 30, 0, 1)}
  ABD[3] {pt3dclear() pt3dadd(105, 30, 0, 1) pt3dadd(150, 30, 0, 1)}
  interD {pt3dclear() pt3dadd(45, 15, 0, 1) pt3dadd(45, 45, 0, 1)}
  interD[1] {pt3dclear() pt3dadd(90, 0, 0, 1) pt3dadd(135, -29, 0, 1)}
  interD[2] {pt3dclear() pt3dadd(105, 30, 0, 1) pt3dadd(90, 60, 0, 1)}
  interD_sec {pt3dclear() pt3dadd(45, 45, 0, 1) pt3dadd(15, 60, 0, 1)}
  interD_sec[1] {pt3dclear() pt3dadd(45, 45, 0, 1) pt3dadd(60, 75, 0, 1)}
  axonstart {pt3dclear() pt3dadd(150, 30, 0, 1) pt3dadd(165, 15, 0, 1)}
  AIS {pt3dclear() pt3dadd(165, 15, 0, 1) pt3dadd(180, 0, 0, 1)}
  axon {pt3dclear() pt3dadd(180, 0, 0, 1) pt3dadd(225, -44, 0, 1)}
  axoD {pt3dclear() pt3dadd(150, 30, 0, 1) pt3dadd(180, 60, 0, 1)}
  nABD {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(0, -59, 0, 1)}
  nABD[1] {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-89, 0, 0, 1)}
  nABD[2] {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-29, 60, 0, 1)}
  nABD_sec {pt3dclear() pt3dadd(-29, 60, 0, 1) pt3dadd(-14, 90, 0, 1)}
  nABD_sec[1] {pt3dclear() pt3dadd(-29, 60, 0, 1) pt3dadd(-59, 75, 0, 1)}
  nABD_sec[2] {pt3dclear() pt3dadd(-89, 0, 0, 1) pt3dadd(-104, 30, 0, 1)}
  nABD_sec[3] {pt3dclear() pt3dadd(-89, 0, 0, 1) pt3dadd(-119, -29, 0, 1)}
  nABD_sec[4] {pt3dclear() pt3dadd(-119, -29, 0, 1) pt3dadd(-149, -14, 0, 1)}
  nABD_sec[5] {pt3dclear() pt3dadd(-119, -29, 0, 1) pt3dadd(-119, -59, 0, 1)}
  nABD_sec[6] {pt3dclear() pt3dadd(-119, -59, 0, 1) pt3dadd(-149, -74, 0, 1)}
  nABD_sec[7] {pt3dclear() pt3dadd(-119, -59, 0, 1) pt3dadd(-89, -74, 0, 1)}
  nABD_sec[8] {pt3dclear() pt3dadd(0, -59, 0, 1) pt3dadd(-14, -89, 0, 1)}
  nABD_sec[9] {pt3dclear() pt3dadd(0, -59, 0, 1) pt3dadd(45, -89, 0, 1)}
  nABD_sec[10] {pt3dclear() pt3dadd(45, -89, 0, 1) pt3dadd(30, -134, 0, 1)}
  nABD_sec[11] {pt3dclear() pt3dadd(45, -89, 0, 1) pt3dadd(90, -104, 0, 1)}
  nABD_sec[12] {pt3dclear() pt3dadd(90, -104, 0, 1) pt3dadd(135, -89, 0, 1)}
  nABD_sec[13] {pt3dclear() pt3dadd(90, -104, 0, 1) pt3dadd(105, -134, 0, 1)}
  nABD_sec[14] {pt3dclear() pt3dadd(30, -134, 0, 1) pt3dadd(-14, -149, 0, 1)}
  nABD_sec[15] {pt3dclear() pt3dadd(30, -134, 0, 1) pt3dadd(30, -179, 0, 1)}
  nABD_sec[16] {pt3dclear() pt3dadd(30, -134, 0, 1) pt3dadd(75, -164, 0, 1)}
  nABD_sec[17] {pt3dclear() pt3dadd(-14, -149, 0, 1) pt3dadd(-59, -149, 0, 1)}
  nABD_sec[18] {pt3dclear() pt3dadd(-14, -149, 0, 1) pt3dadd(-14, -194, 0, 1)}
  nABD_sec[19] {pt3dclear() pt3dadd(30, -179, 0, 1) pt3dadd(15, -209, 0, 1)}
  nABD_sec[20] {pt3dclear() pt3dadd(30, -179, 0, 1) pt3dadd(75, -224, 0, 1)}
  nABD_sec[21] {pt3dclear() pt3dadd(75, -164, 0, 1) pt3dadd(120, -164, 0, 1)}
  nABD_sec[22] {pt3dclear() pt3dadd(75, -164, 0, 1) pt3dadd(90, -209, 0, 1)}
}

objref all, all_biophys, all_ABD
proc subsets() { local i
  objref all, all_biophys, all_ABD
  all = new SectionList()
    soma all.append()
    for i=0, 3 ABD[i] all.append()
    for i=0, 2 interD[i] all.append()
    for i=0, 1 interD_sec[i] all.append()
    axonstart all.append()
    AIS all.append()
    axon all.append()
    axoD all.append()
    for i=0, 2 nABD[i] all.append()
    for i=0, 22 nABD_sec[i] all.append()

  all_biophys = new SectionList()
    for i=0, 3 ABD[i] all_biophys.append()
    for i=0, 2 interD[i] all_biophys.append()
    for i=0, 1 interD_sec[i] all_biophys.append()
    axonstart all_biophys.append()
    axoD all_biophys.append()
    for i=0, 2 nABD[i] all_biophys.append()
    for i=0, 22 nABD_sec[i] all_biophys.append()

      all_ABD= new SectionList()
    for i=0, 3 ABD[i] all_ABD.append()
    for i=0, 2 interD[i] all_ABD.append()
    for i=0, 1 interD_sec[i] all_ABD.append()
    axonstart all_ABD.append()
    axoD all_ABD.append()
   


}
proc geom() {

  soma {  L = 37   }
  ABD {  L = 16     }
  ABD[1] {  L = 10     }
  ABD[2] {  L = 50     }
  ABD[3] {  L = 19     }
  interD {  L = 208     }
  interD[1] {  L = 418     }
  interD[2] {  L = 15     }
  interD_sec {  L = 267     }
  interD_sec[1] {  L = 319     }
  axonstart {  L = 21.2     }
  AIS {  L = 30.5     }
  axon {  L = 800     }
  axoD {  L = 33     }
  nABD {  L = 32     }
  nABD[1] {  L = 14     }
  nABD[2] {  L = 21     }
  nABD_sec {  L = 261     }
  nABD_sec[1] {  L = 150     }
  nABD_sec[2] {  L = 101     }
  nABD_sec[3] {  L = 47     }
  nABD_sec[4] {  L = 338     }
  nABD_sec[5] {  L = 362     }
  nABD_sec[6] {  L = 30     }
  nABD_sec[7] {  L = 36     }
  nABD_sec[8] {  L = 112     }
  nABD_sec[9] {  L = 18     }
  nABD_sec[10] {  L = 318     }
  nABD_sec[11] {  L = 204     }
  nABD_sec[12] {  L = 119     }
  nABD_sec[13] {  L = 134     }
  nABD_sec[14] {  L = 21     }
  nABD_sec[15] {  L = 108     }
  nABD_sec[16] {  L = 45     }
  nABD_sec[17] {  L = 204     }
  nABD_sec[18] {  L = 130     }
  nABD_sec[19] {  L = 30     }
  nABD_sec[20] {  L = 10     }
  nABD_sec[21] {  L = 291     }
  nABD_sec[22] {  L = 83     }

  //nseg

  forsec all { nseg = int((L/(0.1*lambda_f(1000))+.999)/2)*2 + 1  }


soma {    diam = 10 }
  ABD {     diam(0:1) = 3.25:3.25  }
  ABD[1] {     diam(0:1) = 3.25:1.8  }
  ABD[2] {     diam(0:1) = 1.8:1.5  }
  ABD[3] {     diam(0:1) = 1.5:1.3  }
  interD {      diam(0:1) = 1.3:1}
  interD[1] {   diam(0:1) = 1.73:1  }
  interD[2] {  diam(0:1) = 1.23:1  }
  interD_sec {   diam = 0.8 }
  interD_sec[1] {   diam = 0.8 }
  axonstart {     diam(0:1) = 1.45:1.26  }
  AIS {   diam(0:1) = 1.26:1.04  }
  axon {      diam = 1.04  }
  axoD {     diam(0:1) = 1.8:1  }
  nABD {     diam(0:1) = 4:3.5  }
  nABD[1] {     diam(0:1) = 2.7:2.5  }
  nABD[2] {     diam(0:1) = 2.1:1.9  }
  nABD_sec {      diam(0:1) = 1:08  }
  nABD_sec[1] {      diam(0:1) = 1:08  }
  nABD_sec[2] {      diam(0:1) = 1:0.8  }
  nABD_sec[3] {     diam(0:1) = 1.5:1  }
  nABD_sec[4] {      diam(0:1) = 1:0.8  }
  nABD_sec[5] {      diam = 1  }
  nABD_sec[6] {     diam = 0.8  }
  nABD_sec[7] {     diam = 0.8 }
  nABD_sec[8] {      diam(0:1) = 2:1  }
  nABD_sec[9] {     diam = 2  }
  nABD_sec[10] {      diam = 1.5  }
  nABD_sec[11] {      diam = 1 }
  nABD_sec[12] {      diam = 0.8 }
  nABD_sec[13] {      diam = 0.8 }
  nABD_sec[14] {     diam = 1  }
  nABD_sec[15] {      diam = 1  }
  nABD_sec[16] {     diam = 1  }
  nABD_sec[17] {      diam = 0.8  }
  nABD_sec[18] {      diam = 0.8 }
  nABD_sec[19] {     diam = 0.8  }
  nABD_sec[20] {     diam = 0.8  }
  nABD_sec[21] {      diam = 0.8  }
  nABD_sec[22] {     diam = 0.8  }
}
proc biophys() {
  forsec all {
    Ra = 150
    cm = 0.75
  }
  forsec all_biophys {
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
    insert Na12
      gbar_Na12 = 75
    insert kdrDA
      gbar_kdrDA = 150
    insert kaDa
      gbar_kaDa = 50
      taurecov_kaDa = 25
    insert Ih
      gbar_Ih = 3
    insert CAV13
      gbar_CAV13 = 1.25
      iLCa_CAV13 = 0
    insert cad
    insert kca
      gbar_kca = 0.1
        
  }
  soma {
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
    insert kca
      gbar_kca = 0.1
        
    insert Na12
      gbar_Na12 = 75
    insert cad
    insert kdrDA
      gbar_kdrDA = 150
    insert kaDasoma
      gbar_kaDasoma = 150
      taurecov_kaDasoma = 25
    insert Ih
      gbar_Ih = 3
    insert CAV13
      gbar_CAV13 = 1.25
      iLCa_CAV13 = 0
  }
  AIS {
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
    insert Na12
      gbar_Na12 = 4000
    insert kdrDA
      gbar_kdrDA = 4000
  }
  axon {
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
    insert Na12
      gbar_Na12 = 400
    insert kdrDA
      gbar_kdrDA = 400
  }
  forsec all { ek=-90
ena=60  }
}
access soma

celldef()