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

create soma, axonstart, AIS, axon, nABD[4], nABD_sec[25]

proc topol() { local i
  connect axonstart(0), soma(0)
  connect AIS(0), axonstart(1)
  connect axon(0), AIS(1)
  for i = 0, 3 connect nABD[i](0), soma(1)
  for i = 0, 2 connect nABD_sec[i](0), nABD(1)
  for i = 3, 4 connect nABD_sec[i](0), nABD_sec[1](1)
  for i = 5, 6 connect nABD_sec[i](0), nABD_sec[4](1)
  for i = 7, 8 connect nABD_sec[i](0), nABD_sec[2](1)
  for i = 9, 10 connect nABD_sec[i](0), nABD[1](1)
  for i = 11, 12 connect nABD_sec[i](0), nABD_sec[10](1)
  for i = 13, 14 connect nABD_sec[i](0), nABD[2](1)
  for i = 15, 16 connect nABD_sec[i](0), nABD_sec[13](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[17](1)
  for i = 21, 22 connect nABD_sec[i](0), nABD[3](1)
  for i = 23, 24 connect nABD_sec[i](0), nABD_sec[22](1)
  basic_shape()
}
proc basic_shape() {
  soma {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(15, 0, 0, 1)}
  axonstart {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-29, 0, 0, 1)}
  AIS {pt3dclear() pt3dadd(-29, 0, 0, 1) pt3dadd(-59, 0, 0, 1)}
  axon {pt3dclear() pt3dadd(-59, 0, 0, 1) pt3dadd(-89, 0, 0, 1)}
  nABD {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(0, 30, 0, 1)}
  nABD[1] {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(45, 30, 0, 1)}
  nABD[2] {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(45, -14, 0, 1)}
  nABD[3] {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(0, -29, 0, 1)}
  nABD_sec {pt3dclear() pt3dadd(0, 30, 0, 1) pt3dadd(-29, 30, 0, 1)}
  nABD_sec[1] {pt3dclear() pt3dadd(0, 30, 0, 1) pt3dadd(-29, 45, 0, 1)}
  nABD_sec[2] {pt3dclear() pt3dadd(0, 30, 0, 1) pt3dadd(15, 60, 0, 1)}
  nABD_sec[3] {pt3dclear() pt3dadd(-29, 45, 0, 1) pt3dadd(-59, 45, 0, 1)}
  nABD_sec[4] {pt3dclear() pt3dadd(-29, 45, 0, 1) pt3dadd(-29, 75, 0, 1)}
  nABD_sec[5] {pt3dclear() pt3dadd(-29, 75, 0, 1) pt3dadd(-44, 90, 0, 1)}
  nABD_sec[6] {pt3dclear() pt3dadd(-29, 75, 0, 1) pt3dadd(-14, 90, 0, 1)}
  nABD_sec[7] {pt3dclear() pt3dadd(15, 60, 0, 1) pt3dadd(0, 75, 0, 1)}
  nABD_sec[8] {pt3dclear() pt3dadd(15, 60, 0, 1) pt3dadd(30, 75, 0, 1)}
  nABD_sec[9] {pt3dclear() pt3dadd(45, 30, 0, 1) pt3dadd(45, 60, 0, 1)}
  nABD_sec[10] {pt3dclear() pt3dadd(45, 30, 0, 1) pt3dadd(75, 30, 0, 1)}
  nABD_sec[11] {pt3dclear() pt3dadd(75, 30, 0, 1) pt3dadd(90, 60, 0, 1)}
  nABD_sec[12] {pt3dclear() pt3dadd(75, 30, 0, 1) pt3dadd(105, 30, 0, 1)}
  nABD_sec[13] {pt3dclear() pt3dadd(45, -14, 0, 1) pt3dadd(75, -14, 0, 1)}
  nABD_sec[14] {pt3dclear() pt3dadd(45, -14, 0, 1) pt3dadd(45, -44, 0, 1)}
  nABD_sec[15] {pt3dclear() pt3dadd(75, -14, 0, 1) pt3dadd(105, 0, 0, 1)}
  nABD_sec[16] {pt3dclear() pt3dadd(75, -14, 0, 1) pt3dadd(105, -29, 0, 1)}
  nABD_sec[17] {pt3dclear() pt3dadd(45, -44, 0, 1) pt3dadd(30, -74, 0, 1)}
  nABD_sec[18] {pt3dclear() pt3dadd(45, -44, 0, 1) pt3dadd(75, -59, 0, 1)}
  nABD_sec[19] {pt3dclear() pt3dadd(30, -74, 0, 1) pt3dadd(45, -89, 0, 1)}
  nABD_sec[20] {pt3dclear() pt3dadd(30, -74, 0, 1) pt3dadd(15, -89, 0, 1)}
  nABD_sec[21] {pt3dclear() pt3dadd(0, -29, 0, 1) pt3dadd(15, -44, 0, 1)}
  nABD_sec[22] {pt3dclear() pt3dadd(0, -29, 0, 1) pt3dadd(-29, -44, 0, 1)}
  nABD_sec[23] {pt3dclear() pt3dadd(-29, -44, 0, 1) pt3dadd(-29, -74, 0, 1)}
  nABD_sec[24] {pt3dclear() pt3dadd(-29, -44, 0, 1) pt3dadd(-59, -44, 0, 1)}
}

objref all, all_biophys, all_ABD
proc subsets() { local i
  objref all, all_biophys, all_ABD
  all = new SectionList()
    soma all.append()
    axonstart all.append()
    AIS all.append()
    axon all.append()
    for i=0, 3 nABD[i] all.append()
    for i=0, 24 nABD_sec[i] all.append()

  all_biophys = new SectionList()
    axonstart all_biophys.append()
    for i=0, 3 nABD[i] all_biophys.append()
    for i=0, 24 nABD_sec[i] all_biophys.append()

      all_ABD=new SectionList()
       axonstart all_ABD.append()

}
proc geom() {

  soma {  L = 34 }
  axonstart {  L = 19.8      }
  AIS {  L = 30.7      }
  axon {  L = 800     }
  nABD {  L = 37      }
  nABD[1] {  L = 15      }
  nABD[2] {  L = 12      }
  nABD[3] {  L = 14      }
  nABD_sec {  L = 312      }
  nABD_sec[1] {  L = 23      }
  nABD_sec[2] {  L = 7      }
  nABD_sec[3] {  L = 92      }
  nABD_sec[4] {  L = 13      }
  nABD_sec[5] {  L = 161      }
  nABD_sec[6] {  L = 408      }
  nABD_sec[7] {  L = 235      }
  nABD_sec[8] {  L = 319      }
  nABD_sec[9] {  L = 235      }
  nABD_sec[10] {  L = 17      }
  nABD_sec[11] {  L = 38      }
  nABD_sec[12] {  L = 31      }
  nABD_sec[13] {  L = 26      }
  nABD_sec[14] {  L = 11      }
  nABD_sec[15] {  L = 49      }
  nABD_sec[16] {  L = 244      }
  nABD_sec[17] {  L = 4      }
  nABD_sec[18] {  L = 198      }
  nABD_sec[19] {  L = 44      }
  nABD_sec[20] {  L = 3      }
  nABD_sec[21] {  L = 214      }
  nABD_sec[22] {  L = 10      }
  nABD_sec[23] {  L = 281      }
  nABD_sec[24] {  L = 160      }

// nseg definition has to be launched before diam definition for tapering to be taken into account

  forsec all { nseg = int((L/(0.1*lambda_f(1000))+.999)/2)*2 + 1  }
  
  soma {      diam = 10  }
  axonstart {       diam(0:1) = 1.2:1.1  }
  AIS {       diam(0:1) = 1.1:0.6  }
  axon {     diam = 0.6 }
  nABD {     diam = 2  }
  nABD[1] {     diam = 1.8  }
  nABD[2] {     diam = 3 }
  nABD[3] {     diam = 2.3  }
  nABD_sec {      diam(0:1) = 1 :0.8 }
  nABD_sec[1] {     diam = 1  }
  nABD_sec[2] {      diam = 1  }
  nABD_sec[3] {     diam = 0.8  }
  nABD_sec[4] {     diam = 1  }
  nABD_sec[5] {      diam = 0.8  }
  nABD_sec[6] {      diam = 0.8 }
  nABD_sec[7] {      diam = 0.8 }
  nABD_sec[8] {      diam = 0.8 }
  nABD_sec[9] {      diam(0:1) = 1:0.8  }
  nABD_sec[10] {     diam = 1  }
  nABD_sec[11] {     diam = 0.8  }
  nABD_sec[12] {     diam = 0.8  }
  nABD_sec[13] {     diam = 1.5  }
  nABD_sec[14] {     diam = 1.5  }
  nABD_sec[15] {     diam = 0.8  }
  nABD_sec[16] {      diam(0:1) = 1:0.8  }
  nABD_sec[17] {      diam = 1  }
  nABD_sec[18] {      diam(0:1) = 1:0.8  }
  nABD_sec[19] {     diam = 0.8  }
  nABD_sec[20] {      diam = 0.8  }
  nABD_sec[21] {      diam(0:1) = 1:0.8  }
  nABD_sec[22] {    diam = 1.3  }
  nABD_sec[23] {      diam(0:1) = 1:0.8  }
  nABD_sec[24] {      diam = 0.8   }
}

proc biophys() {
  forsec all {
    Ra = 150
    cm = 0.75
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
  }
  forsec all_biophys {
    insert CAV13
      gbar_CAV13 = 1.25
      iLCa_CAV13 = 0
    insert Ih
      gbar_Ih = 3
    insert kaDa
      gbar_kaDa = 50
      taurecov_kaDa = 25
    insert kdrDA
      gbar_kdrDA = 150
    insert Na12
      gbar_Na12 = 75
    insert cad
    insert kca
      gbar_kca = 0.1
        
  }
  soma {
    insert CAV13
      gbar_CAV13 = 1.25
      iLCa_CAV13 = 0
    insert Ih
      gbar_Ih = 3
    insert kaDasoma
      gbar_kaDasoma = 150
      taurecov_kaDasoma = 25
    insert kdrDA
      gbar_kdrDA = 150
    insert Na12
      gbar_Na12 = 75
    insert cad
    insert kca
      gbar_kca = 0.1
        
  }
  AIS {
    insert kdrDA
      gbar_kdrDA = 4000
    insert Na12
      gbar_Na12 = 4000
  }
  axon {
    insert kdrDA
      gbar_kdrDA = 400
    insert Na12
      gbar_Na12 = 400
  }
  forsec all { ek=-90
ena=60  }
}
access soma

celldef()