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

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

proc topol() { local i
  connect ABD(0), soma(1)
  connect ABD[1](0), ABD(1)
  for i = 0, 1 connect axoD[i](0), ABD[1](1)
  for i = 0, 1 connect axoD_sec[i](0), axoD(1)
  connect axonstart(0), ABD[1](1)
  connect AIS(0), axonstart(1)
  connect axon(0), AIS(1)
  connect interD(0), ABD(1)
  for i = 0, 1 connect interD_sec[i](0), interD(1)
  for i = 2, 3 connect interD_sec[i](0), interD_sec[1](1)
  for i = 0, 3 connect nABD[i](0), soma(0)
  for i = 0, 1 connect nABD_sec[i](0), nABD(1)
  for i = 2, 3 connect nABD_sec[i](0), nABD_sec(1)
  for i = 4, 5 connect nABD_sec[i](0), nABD[2](1)
  for i = 6, 7 connect nABD_sec[i](0), nABD_sec[5](1)
  for i = 8, 9 connect nABD_sec[i](0), nABD_sec[7](1)
  for i = 10, 11 connect nABD_sec[i](0), nABD_sec[9](1)
  for i = 12, 13 connect nABD_sec[i](0), nABD[3](1)
  for i = 14, 15 connect nABD_sec[i](0), nABD_sec[13](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, 0, 0, 1)}
  ABD[1] {pt3dclear() pt3dadd(45, 0, 0, 1) pt3dadd(60, -14, 0, 1)}
  axoD {pt3dclear() pt3dadd(60, -14, 0, 1) pt3dadd(90, -14, 0, 1)}
  axoD[1] {pt3dclear() pt3dadd(60, -14, 0, 1) pt3dadd(75, -44, 0, 1)}
  axoD_sec {pt3dclear() pt3dadd(90, -14, 0, 1) pt3dadd(105, 0, 0, 1)}
  axoD_sec[1] {pt3dclear() pt3dadd(90, -14, 0, 1) pt3dadd(105, -29, 0, 1)}
  axonstart {pt3dclear() pt3dadd(60, -14, 0, 1) pt3dadd(75, 0, 0, 1)}
  AIS {pt3dclear() pt3dadd(75, 0, 0, 1) pt3dadd(90, 15, 0, 1)}
  axon {pt3dclear() pt3dadd(90, 15, 0, 1) pt3dadd(150, 75, 0, 1)}
  interD {pt3dclear() pt3dadd(45, 0, 0, 1) pt3dadd(45, 30, 0, 1)}
  interD_sec {pt3dclear() pt3dadd(45, 30, 0, 1) pt3dadd(60, 45, 0, 1)}
  interD_sec[1] {pt3dclear() pt3dadd(45, 30, 0, 1) pt3dadd(30, 45, 0, 1)}
  interD_sec[2] {pt3dclear() pt3dadd(30, 45, 0, 1) pt3dadd(45, 60, 0, 1)}
  interD_sec[3] {pt3dclear() pt3dadd(30, 45, 0, 1) pt3dadd(15, 60, 0, 1)}
  nABD {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(0, -44, 0, 1)}
  nABD[1] {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-44, -29, 0, 1)}
  nABD[2] {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-44, 0, 0, 1)}
  nABD[3] {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-14, 30, 0, 1)}
  nABD_sec {pt3dclear() pt3dadd(0, -44, 0, 1) pt3dadd(-14, -59, 0, 1)}
  nABD_sec[1] {pt3dclear() pt3dadd(0, -44, 0, 1) pt3dadd(15, -59, 0, 1)}
  nABD_sec[2] {pt3dclear() pt3dadd(-14, -59, 0, 1) pt3dadd(-44, -74, 0, 1)}
  nABD_sec[3] {pt3dclear() pt3dadd(-14, -59, 0, 1) pt3dadd(0, -89, 0, 1)}
  nABD_sec[4] {pt3dclear() pt3dadd(-44, 0, 0, 1) pt3dadd(-59, -14, 0, 1)}
  nABD_sec[5] {pt3dclear() pt3dadd(-44, 0, 0, 1) pt3dadd(-59, 15, 0, 1)}
  nABD_sec[6] {pt3dclear() pt3dadd(-59, 15, 0, 1) pt3dadd(-89, 15, 0, 1)}
  nABD_sec[7] {pt3dclear() pt3dadd(-59, 15, 0, 1) pt3dadd(-59, 45, 0, 1)}
  nABD_sec[8] {pt3dclear() pt3dadd(-59, 45, 0, 1) pt3dadd(-89, 60, 0, 1)}
  nABD_sec[9] {pt3dclear() pt3dadd(-59, 45, 0, 1) pt3dadd(-44, 60, 0, 1)}
  nABD_sec[10] {pt3dclear() pt3dadd(-44, 60, 0, 1) pt3dadd(-44, 90, 0, 1)}
  nABD_sec[11] {pt3dclear() pt3dadd(-44, 60, 0, 1) pt3dadd(-29, 75, 0, 1)}
  nABD_sec[12] {pt3dclear() pt3dadd(-14, 30, 0, 1) pt3dadd(0, 45, 0, 1)}
  nABD_sec[13] {pt3dclear() pt3dadd(-14, 30, 0, 1) pt3dadd(-29, 45, 0, 1)}
  nABD_sec[14] {pt3dclear() pt3dadd(-29, 45, 0, 1) pt3dadd(-14, 60, 0, 1)}
  nABD_sec[15] {pt3dclear() pt3dadd(-29, 45, 0, 1) pt3dadd(-44, 30, 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, 1 ABD[i] all.append()
    for i=0, 1 axoD[i] all.append()
    for i=0, 1 axoD_sec[i] all.append()
    axonstart all.append()
    AIS all.append()
    axon all.append()
    interD all.append()
    for i=0, 3 interD_sec[i] all.append()
    for i=0, 3 nABD[i] all.append()
    for i=0, 15 nABD_sec[i] all.append()

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

}
proc geom() {
  
  ABD {  L = 29  }
  ABD[1] {  L = 24   }
  axoD {  L = 25   }
  axoD[1] {  L = 382   }
  axoD_sec {  L = 346   }
  axoD_sec[1] {  L = 92   }
  axonstart {  L = 29   }
  AIS {  L = 34.5   }
  axon {  L = 800   }
  interD {  L = 13   }
  interD_sec {  L = 283   }
  interD_sec[1] {  L = 107   }
  interD_sec[2] {  L = 11   }
  interD_sec[3] {  L = 261   }
  nABD {  L = 38   }
  nABD[1] {  L = 67   }
  nABD[2] { L = 49   }
  nABD[3] {  L = 5   }
  nABD_sec {  L = 283   }
  nABD_sec[1] {  L = 12   }
  nABD_sec[2] {  L = 100   }
  nABD_sec[3] {  L = 85   }
  nABD_sec[4] {  L = 14   }
  nABD_sec[5] {  L = 61   }
  nABD_sec[6] {  L = 200   }
  nABD_sec[7] {  L = 127   }
  nABD_sec[8] {  L = 175   }
  nABD_sec[9] {  L = 21   }
  nABD_sec[10] {  L = 204   }
  nABD_sec[11] {  L = 392   }
  nABD_sec[12] {  L = 246   }
  nABD_sec[13] {  L = 10   }
  nABD_sec[14] {  L = 483   }
  nABD_sec[15] {  L = 182   }

// nseg
  forsec all { nseg = int((L/(0.1*lambda_f(1000))+.999)/2)*2 + 1  }
  
 //tapering
  soma{ diam=10}
  ABD {  diam(0:1) = 3.35:3 }
  ABD[1] {  diam(0:1) = 3:2.8 }
  axoD {  diam(0:1) = 1.575:1.3 }
  axoD[1] {  diam(0:1) = 1 :0.8  }
  axoD_sec {  diam(0:1) = 1:0.8  }
  axoD_sec[1] { diam(0:1) = 1:0.8  }
  axonstart {  diam(0:1) = 1.839:1.24 }
  AIS {   diam(0:1) = 1.24:0.9  }
  axon {  diam = 0.9 }
  interD { diam(0:1) = 1.99:1.7  }
  interD_sec {   diam(0:1) = 1.5:1 }
  interD_sec[1] { diam(0:1) = 1.3:1  }
  interD_sec[2] {  diam = 0.8  }
  interD_sec[3] {   diam = 0.8  }
  nABD { diam(0:1) = 3.5:3  }
  nABD[1] {     diam(0:1) = 1.5:1  }
  nABD[2] {  diam(0:1) = 3.2:3  }
  nABD[3] {  diam(0:1) = 6:5 }
  nABD_sec {      diam(0:1) = 2.8:2 }
  nABD_sec[1] {     diam = 1 }
  nABD_sec[2] {      diam = 1 }
  nABD_sec[3] {     diam = 1.5  }
  nABD_sec[4] {     diam(0:1) = 2:1.5  }
  nABD_sec[5] {     diam(0:1) = 2:1.8 }
  nABD_sec[6] {      diam(0:1) = 1.8:1  }
  nABD_sec[7] {      diam(0:1) = 1.2:1  }
  nABD_sec[8] {      diam(0:1) = 1:0.8  }
  nABD_sec[9] {     diam = 1  }
  nABD_sec[10] {      diam(0:1) = 1 :0.8 }
  nABD_sec[11] {      diam(0:1) = 1:0.8 }
  nABD_sec[12] {      diam(0:1) = 4:1 }
  nABD_sec[13] {     diam(0:1) = 2:1.5  }
  nABD_sec[14] {      diam(0:1) = 1.5:1 }
  nABD_sec[15] {      diam(0:1) = 1.5:1 }
}
proc biophys() {
  forsec all {
    Ra = 150
    cm = 0.75
  }
  forsec all_biophys {
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
    insert kca
      gbar_kca = 0.1
        
    insert cad
    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
  }
  soma {
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
    insert kca
      gbar_kca = 0.1
        
    insert kdrDA
      gbar_kdrDA = 150
    insert Na12
      gbar_Na12 = 75
    insert cad
    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 = 75
    insert kdrDA
      gbar_kdrDA = 150
  }
  axon {
    insert pasnts
      g_pasnts = 1e-05
      e_pasnts = -50
    insert Na12
      gbar_Na12 = 75
    insert kdrDA
      gbar_kdrDA = 150
  }
  forsec all {en= 60
ek=-90  }
}
access soma

celldef()