/*////////////// Topology and geometry ////////////////

Dendrite section names:

   GCL = GCLD in Mateos-Aparicio et. al. (2014)
  prox = PD in Mateos-Aparicio et. al. (2014)
middle = MD in Mateos-Aparicio et. al. (2014)
distal = DD in Mateos-Aparicio et. al. (2014)

/*/////////////////////////////////////////////////////

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

create soma[1], axon[4], GCL[2], prox[2], middle[2], distal[2]

proc topol() { local i
  connect axon(0), soma(1)
  for i = 1, 3 connect axon[i](0), axon[i-1](1)
  for i = 0, 1 connect GCL[i](0), soma(0)
  for i = 0, 1 connect prox[i](0), GCL[i](1)
  for i = 0, 1 connect middle[i](0), prox[i](1)
  for i = 0, 1 connect distal[i](0), middle[i](1)
  basic_shape()
}
proc basic_shape() {
  soma {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(15, 0, 0, 1)}
  axon {pt3dclear() pt3dadd(15, 0, 0, 1) pt3dadd(30, 0, 0, 1)}
  axon[1] {pt3dclear() pt3dadd(30, 0, 0, 1) pt3dadd(45, 0, 0, 1)}
  axon[2] {pt3dclear() pt3dadd(45, 0, 0, 1) pt3dadd(60, 0, 0, 1)}
  axon[3] {pt3dclear() pt3dadd(60, 0, 0, 1) pt3dadd(120, 0, 0, 1)}
  GCL {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-29, 30, 0, 1)}
  GCL[1] {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(-29, -29, 0, 1)}
  prox {pt3dclear() pt3dadd(-29, 30, 0, 1) pt3dadd(-44, 30, 0, 1)}
  prox[1] {pt3dclear() pt3dadd(-29, -29, 0, 1) pt3dadd(-44, -29, 0, 1)}
  middle {pt3dclear() pt3dadd(-44, 30, 0, 1) pt3dadd(-59, 30, 0, 1)}
  middle[1] {pt3dclear() pt3dadd(-44, -29, 0, 1) pt3dadd(-59, -29, 0, 1)}
  distal {pt3dclear() pt3dadd(-59, 30, 0, 1) pt3dadd(-119, 30, 0, 1)}
  distal[1] {pt3dclear() pt3dadd(-59, -29, 0, 1) pt3dadd(-119, -29, 0, 1)}
}

objref all, dendrites, GCLs, proxs, middles, distals, allaxon
proc subsets() { local i
  objref all, dendrites, GCLs, proxs, middles, distals, allaxon

  all = new SectionList()
    soma all.append()
    for i=0, 3 axon[i] all.append()
    for i=0, 1 GCL[i] all.append()
    for i=0, 1 prox[i] all.append()
    for i=0, 1 middle[i] all.append()
    for i=0, 1 distal[i] all.append()
    
  dendrites = new SectionList()
    for i=0, 1 prox[i] dendrites.append()
    for i=0, 1 middle[i] dendrites.append()
    for i=0, 1 distal[i] dendrites.append()

  GCLs = new SectionList()
    for i=0, 1 GCL[i] GCLs.append()

  proxs = new SectionList()
    for i=0, 1 prox[i] proxs.append()

  middles = new SectionList()
    for i=0, 1 middle[i] middles.append()

  distals = new SectionList()
    for i=0, 1 distal[i] distals.append()

  allaxon = new SectionList()
    for i=0, 3 axon[i] allaxon.append()
}

proc geom() {
  forsec dendrites {  L = 150  diam = 3  }
  forsec GCLs {  L = 50  diam = 3  }
  forsec allaxon {  L = 50  }
   axon.diam = 0.9
   axon[1].diam = 0.7
   axon[2].diam = 0.5
   axon[3].diam = 0.4
  soma {  L = 16.8  diam = 16.8  somaarea = PI*diam^2}
  axon[3] {  L = 1400  }
}

celldef()