def add_axon (self):
   # NB: paste-on axon if using SPI morphology (eg for comparing morph effect on dynamics)
   from PTAxonMorph import axonPts
   self.axon.append(h.Section(name="axon[0]"))
   self.all.append(self.axon[0])
   self.axon[0].connect(self.soma[0], 0.0, 0.0)
   # clears 3d points
   h.pt3dclear()
   # define a logical connection point relative to the first 3-d point
   h.pt3dstyle(axonPts[0][0], axonPts[0][1], axonPts[0][2], axonPts[0][3], sec=self.axon[0])
   # add axon points after first logical connection point
   for x, y, z, d in axonPts[1:]: h.pt3dadd(x, y, z, d, sec=self.axon[0])
Ejemplo n.º 2
0
def secinfo():
  result = "\n"
  for sec in h.allsec():
    r = [h.ref(0) for _ in range(3)]
    pseg = sec.parentseg()
    px = ("parent %s(%g)"%(pseg.sec.name(),pseg.x)) if pseg is not None else ""
    style = ""
    if sec.pt3dstyle():
      h.pt3dstyle(1, r[0], r[1], r[2], sec=sec)
      style = [i[0] for i in r]
    result += "%s L=%g %s %s\n" % (str(sec), sec.L, str(style), px)
    for i in range(sec.n3d()):
      result += " %d   %g %g %g %g\n" % (i, sec.x3d(i), sec.y3d(i), sec.z3d(i), sec.diam3d(i))
  return result
Ejemplo n.º 3
0
 def add_axon(self):
     self.axon.append(h.Section(name="axon[0]"))
     self.all.append(self.axon[0])
     self.axon[0].connect(self.soma[0], 0.0, 0.0)
     # clears 3d points
     h.pt3dclear()
     # define a logical connection point relative to the first 3-d point
     h.pt3dstyle(axonPts[0][0],
                 axonPts[0][1],
                 axonPts[0][2],
                 axonPts[0][3],
                 sec=self.axon[0])
     # add axon points after first logical connection point
     for x, y, z, d in axonPts[1:]:
         h.pt3dadd(x, y, z, d, sec=self.axon[0])
Ejemplo n.º 4
0
def load(filename,
         fileformat=None,
         cell=None,
         use_axon=True,
         xshift=0,
         yshift=0,
         zshift=0):
    """
    Load an SWC from filename and instantiate inside cell. Code kindly provided
    by @ramcdougal.

    Args:
        filename = .swc file containing morphology
        cell = Cell() object. (Default: None, creates new object)
        filename = the filename of the SWC file
        use_axon = include the axon? Default: True (yes)
        xshift, yshift, zshift = use to position the cell

    Returns:
        Cell() object with populated soma, axon, dend, & apic fields

    Minimal example:
        # pull the morphology for the demo from NeuroMorpho.Org
        from PyNeuronToolbox import neuromorphoorg
        with open('c91662.swc', 'w') as f:
            f.write(neuromorphoorg.morphology('c91662'))
        cell = load_swc(filename)

    """

    if cell is None:
        cell = Cell(name=string.join(filename.split('.')[:-1]))

    if fileformat is None:
        fileformat = filename.split('.')[-1]

    name_form = {1: 'soma[%d]', 2: 'axon[%d]', 3: 'dend[%d]', 4: 'apic[%d]'}

    # load the data. Use Import3d_SWC_read for swc, Import3d_Neurolucida3 for
    # Neurolucida V3, Import3d_MorphML for MorphML (level 1 of NeuroML), or
    # Import3d_Eutectic_read for Eutectic.
    if fileformat == 'swc':
        morph = h.Import3d_SWC_read()
    elif fileformat == 'asc':
        morph = h.Import3d_Neurolucida3()
    else:
        raise Exception('file format `%s` not recognized' % (fileformat))
    morph.input(filename)

    # easiest to instantiate by passing the loaded morphology to the Import3d_GUI
    # tool; with a second argument of 0, it won't display the GUI, but it will allow
    # use of the GUI's features
    i3d = h.Import3d_GUI(morph, 0)

    # get a list of the swc section objects
    swc_secs = i3d.swc.sections
    swc_secs = [swc_secs.object(i) for i in xrange(int(swc_secs.count()))]

    # initialize the lists of sections
    sec_list = {1: cell.soma, 2: cell.axon, 3: cell.dend, 4: cell.apic}

    # name and create the sections
    real_secs = {}
    for swc_sec in swc_secs:
        cell_part = int(swc_sec.type)

        # skip everything else if it's an axon and we're not supposed to
        # use it... or if is_subsidiary
        if (not (use_axon) and cell_part == 2) or swc_sec.is_subsidiary:
            continue

        # figure out the name of the new section
        if cell_part not in name_form:
            raise Exception('unsupported point type')
        name = name_form[cell_part] % len(sec_list[cell_part])

        # create the section
        sec = h.Section(name=name)

        # connect to parent, if any
        if swc_sec.parentsec is not None:
            sec.connect(real_secs[swc_sec.parentsec.hname()](swc_sec.parentx))

        # define shape
        if swc_sec.first == 1:
            h.pt3dstyle(1,
                        swc_sec.raw.getval(0, 0),
                        swc_sec.raw.getval(1, 0),
                        swc_sec.raw.getval(2, 0),
                        sec=sec)

        j = swc_sec.first
        xx, yy, zz = [swc_sec.raw.getrow(i).c(j) for i in xrange(3)]
        dd = swc_sec.d.c(j)
        if swc_sec.iscontour_:
            # never happens in SWC files, but can happen in other formats supported
            # by NEURON's Import3D GUI
            raise Exception('Unsupported section style: contour')

        if dd.size() == 1:
            # single point soma; treat as sphere
            x, y, z, d = [dim.x[0] for dim in [xx, yy, zz, dd]]
            for xprime in [x - d / 2., x, x + d / 2.]:
                h.pt3dadd(xprime + xshift, y + yshift, z + zshift, d, sec=sec)
        else:
            for x, y, z, d in zip(xx, yy, zz, dd):
                h.pt3dadd(x + xshift, y + yshift, z + zshift, d, sec=sec)

        # store the section in the appropriate list in the cell and lookup table
        sec_list[cell_part].append(sec)
        real_secs[swc_sec.hname()] = sec

    cell.all = cell.soma + cell.apic + cell.dend + cell.axon
    return cell
Ejemplo n.º 5
0
    def create_cell(self):
        """
        3D morphology of CA229simp cell.
        The diam and L of each compartment is determined by 3D structure.
        Same as hoc 3D morphology: CA229.hoc
        """
        self.soma = h.Section(name='soma')
        self.apical = [h.Section(name='apical[0]')]
        self.basal = [h.Section(name='basal[%d]' % i) for i in range(10)]
        self.axon = [h.Section(name='axon[0]')]

        self.axon[0].L = 200.0
        self.axon[0].diam = 1.03
        self.axon[0].nseg = 1
        self.axon[0].connect(self.soma)

        self.apical[0].L = 454.5
        self.apical[0].diam = 6.00
        self.apical[0].nseg = 1
        self.apical[0].connect(self.soma)

        self.basal[9].L = 157.2
        self.basal[9].diam = 6.00
        self.basal[9].nseg = 1
        self.basal[9].connect(self.soma)

        self.basal[8].nseg = 3

        # Set up the 3d morphology and connection of soma
        h.pt3dclear(sec=self.soma)
        h.pt3dstyle(1, -53.42, 3.52, -5.95, 13.43, sec=self.soma)
        h.pt3dadd(-53.42, 3.52, -5.96, 13.43, sec=self.soma)
        h.pt3dadd(-53.74, 0.93, -5.96, 15.35, sec=self.soma)
        h.pt3dadd(-54.06, -1.66, -5.96, 11.51, sec=self.soma)
        h.pt3dadd(-54.06, -4.25, -5.96, 7.99, sec=self.soma)
        h.pt3dadd(-53.42, 3.52, -5.96, 13.43, sec=self.soma)
        h.pt3dadd(-53.1, 6.12, -5.96, 11.19, sec=self.soma)
        h.pt3dadd(-52.78, 8.71, -5.96, 9.59, sec=self.soma)
        h.pt3dadd(-52.78, 11.62, -5.96, 7.36, sec=self.soma)
        h.pt3dadd(-53.1, 14.22, -5.96, 5.76, sec=self.soma)

        # Set up the 3d morphology and connection of basal dendrite cylinder
        h.pt3dclear(sec=self.basal[9])
        h.pt3dadd(-53.1, 14.22, -5.96, 6.0, sec=self.basal[9])
        h.pt3dadd(157.2 + -53.1, 14.22, -5.96, 6.0, sec=self.basal[9])

        # Set up the 3d morphology and connection of the axon
        h.pt3dclear(sec=self.axon[0])
        h.pt3dadd(-53.1, 14.22, -5.96, 1.03, sec=self.axon[0])
        h.pt3dadd(-53.1, -200.0 + 14.22, -5.96, 1.03, sec=self.axon[0])

        # Set up the 3d morphology and connection of the apical cylinder
        h.pt3dclear(sec=self.apical[0])
        h.pt3dadd(-53.1, 14.22, -5.96, 6.0, sec=self.apical[0])
        h.pt3dadd(-53.1, 454.5 + 14.22, -5.96, 6.0, sec=self.apical[0])

        # Set up the 3d morphology and connection of basal dendrites
        self.basal[0].connect(self.soma)
        h.pt3dclear(sec=self.basal[0])
        h.pt3dadd(-53.42, 3.52, -5.96, 2.5, sec=self.basal[0])
        h.pt3dadd(-60.3, 3.99, 0.28, 1.28, sec=self.basal[0])
        h.pt3dadd(-64.028, 3.787, 1.455, 1.28, sec=self.basal[0])
        h.pt3dadd(-68.616, 2.577, 1.405, 1.28, sec=self.basal[0])
        h.pt3dadd(-72.55, 1.133, 1.864, 1.28, sec=self.basal[0])
        h.pt3dadd(-77.03, 0.483, 3.784, 1.28, sec=self.basal[0])

        self.basal[1].connect(self.basal[0])
        h.pt3dclear(sec=self.basal[1])
        h.pt3dadd(-77.03, 0.483, 3.784, 1.28, sec=self.basal[1])
        h.pt3dadd(-80.68, 2.633, 0.564, 0.96, sec=self.basal[1])
        h.pt3dadd(-84.2, 3.613, -0.576, 0.96, sec=self.basal[1])
        h.pt3dadd(-88.771, 4.452, -1.634, 0.96, sec=self.basal[1])
        h.pt3dadd(-93.902, 6.048, -2.616, 0.96, sec=self.basal[1])
        h.pt3dadd(-96.462, 6.688, -4.516, 0.96, sec=self.basal[1])
        h.pt3dadd(-100.622, 5.718, -5.996, 0.96, sec=self.basal[1])
        h.pt3dadd(-102.852, 5.718, -7.876, 0.96, sec=self.basal[1])

        self.basal[2].connect(self.basal[1])
        h.pt3dclear(sec=self.basal[2])
        h.pt3dadd(-102.852, 5.718, -7.876, 0.96, sec=self.basal[2])
        h.pt3dadd(-102.852, 3.128, -17.756, 0.64, sec=self.basal[2])
        h.pt3dadd(-101.262, 2.478, -21.296, 0.64, sec=self.basal[2])
        h.pt3dadd(-100.622, -1.082, -24.456, 0.64, sec=self.basal[2])
        h.pt3dadd(-101.892, -1.732, -27.696, 0.64, sec=self.basal[2])
        h.pt3dadd(-103.172, -2.702, -35.536, 0.64, sec=self.basal[2])
        h.pt3dadd(-105.092, -3.032, -41.596, 0.64, sec=self.basal[2])
        h.pt3dadd(-105.412, -2.052, -46.196, 0.64, sec=self.basal[2])
        h.pt3dadd(-107.012, -1.412, -47.816, 0.64, sec=self.basal[2])
        h.pt3dadd(-108.932, -1.412, -50.276, 0.64, sec=self.basal[2])
        h.pt3dadd(-110.212, 0.538, -52.336, 0.496, sec=self.basal[2])
        h.pt3dadd(-110.212, 1.508, -56.156, 0.476, sec=self.basal[2])

        self.basal[3].connect(self.basal[1])
        h.pt3dclear(sec=self.basal[3])
        h.pt3dadd(-102.852, 5.718, -7.876, 0.96, sec=self.basal[3])
        h.pt3dadd(-104.452, 5.398, -7.876, 0.96, sec=self.basal[3])
        h.pt3dadd(-108.932, 5.718, -9.356, 0.804, sec=self.basal[3])

        self.basal[4].connect(self.basal[3])
        h.pt3dclear(sec=self.basal[4])
        h.pt3dadd(-108.932, 5.718, -9.356, 0.804, sec=self.basal[4])
        h.pt3dadd(-113.092, 4.428, -12.676, 0.64, sec=self.basal[4])
        h.pt3dadd(-115.332, 3.128, -12.676, 0.782, sec=self.basal[4])
        h.pt3dadd(-118.842, 3.128, -14.996, 0.738, sec=self.basal[4])
        h.pt3dadd(-121.402, 2.158, -17.416, 0.73, sec=self.basal[4])
        h.pt3dadd(-124.282, 1.188, -17.416, 0.64, sec=self.basal[4])

        self.basal[5].connect(self.basal[4])
        h.pt3dclear(sec=self.basal[5])
        h.pt3dadd(-124.282, 1.188, -17.416, 0.64, sec=self.basal[5])
        h.pt3dadd(-127.162, 0.858, -20.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-129.082, 0.858, -20.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-131.632, -1.732, -22.016, 0.64, sec=self.basal[5])
        h.pt3dadd(-134.192, -3.352, -24.736, 0.64, sec=self.basal[5])
        h.pt3dadd(-138.352, -4.322, -29.736, 0.64, sec=self.basal[5])
        h.pt3dadd(-140.592, -5.622, -32.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-143.472, -6.912, -32.256, 0.64, sec=self.basal[5])
        h.pt3dadd(-146.342, -6.912, -35.356, 0.64, sec=self.basal[5])
        h.pt3dadd(-149.222, -7.562, -37.116, 0.64, sec=self.basal[5])
        h.pt3dadd(-152.102, -7.562, -37.936, 0.64, sec=self.basal[5])
        h.pt3dadd(-154.022, -7.562, -37.916, 0.64, sec=self.basal[5])
        h.pt3dadd(-157.222, -8.212, -39.196, 0.64, sec=self.basal[5])
        h.pt3dadd(-159.782, -10.152, -39.636, 0.64, sec=self.basal[5])
        h.pt3dadd(-162.332, -11.452, -43.116, 0.64, sec=self.basal[5])
        h.pt3dadd(-165.852, -13.392, -44.816, 0.516, sec=self.basal[5])
        h.pt3dadd(-168.092, -14.042, -47.096, 0.486, sec=self.basal[5])

        self.basal[6].connect(self.basal[4])
        h.pt3dclear(sec=self.basal[6])
        h.pt3dadd(-124.282, 1.188, -17.416, 0.64, sec=self.basal[6])
        h.pt3dadd(-126.522, -2.052, -19.176, 0.58, sec=self.basal[6])
        h.pt3dadd(-130.042, -4.972, -19.176, 0.588, sec=self.basal[6])
        h.pt3dadd(-133.872, -5.942, -17.176, 0.622, sec=self.basal[6])
        h.pt3dadd(-137.072, -8.212, -17.176, 0.664, sec=self.basal[6])
        h.pt3dadd(-139.312, -9.832, -17.176, 0.656, sec=self.basal[6])
        h.pt3dadd(-142.512, -12.422, -17.596, 0.618, sec=self.basal[6])
        h.pt3dadd(-146.342, -12.752, -16.076, 0.648, sec=self.basal[6])
        h.pt3dadd(-149.862, -13.072, -17.236, 0.514, sec=self.basal[6])
        h.pt3dadd(-153.062, -12.752, -18.816, 0.612, sec=self.basal[6])
        h.pt3dadd(-155.942, -12.422, -20.536, 0.498, sec=self.basal[6])
        h.pt3dadd(-159.142, -11.772, -23.916, 0.404, sec=self.basal[6])

        self.basal[7].connect(self.basal[3])
        h.pt3dclear(sec=self.basal[7])
        h.pt3dadd(-108.932, 5.718, -9.356, 0.804, sec=self.basal[7])
        h.pt3dadd(-114.692, 7.338, -3.716, 0.72, sec=self.basal[7])
        h.pt3dadd(-119.482, 8.638, 1.824, 0.758, sec=self.basal[7])
        h.pt3dadd(-122.362, 9.288, 5.544, 0.658, sec=self.basal[7])
        h.pt3dadd(-125.882, 10.578, 7.024, 0.676, sec=self.basal[7])
        h.pt3dadd(-131.002, 10.908, 9.624, 0.598, sec=self.basal[7])
        h.pt3dadd(-133.552, 13.498, 10.304, 0.652, sec=self.basal[7])
        h.pt3dadd(-136.752, 14.788, 11.724, 0.546, sec=self.basal[7])
        h.pt3dadd(-138.992, 16.088, 13.144, 0.614, sec=self.basal[7])
        h.pt3dadd(-144.112, 18.358, 14.244, 0.476, sec=self.basal[7])

        self.basal[8].connect(self.basal[0])
        h.pt3dclear(sec=self.basal[8])
        h.pt3dadd(-77.03, 0.483, 3.784, 1.28, sec=self.basal[8])
        h.pt3dadd(-80.23, -0.487, 1.264, 0.788, sec=self.basal[8])
        h.pt3dadd(-82.47, -0.487, 1.084, 0.852, sec=self.basal[8])
        h.pt3dadd(-85.35, -2.107, 0.664, 0.75, sec=self.basal[8])
        h.pt3dadd(-88.084, -4.512, 0.566, 0.848, sec=self.basal[8])
        h.pt3dadd(-90.408, -7.229, 0.826, 0.952, sec=self.basal[8])
        h.pt3dadd(-93.59, -9.125, 0.336, 0.918, sec=self.basal[8])
        h.pt3dadd(-96.47, -9.445, -0.304, 0.732, sec=self.basal[8])
        h.pt3dadd(-98.07, -11.395, -1.384, 0.852, sec=self.basal[8])
        h.pt3dadd(-99.35, -13.985, -1.924, 0.806, sec=self.basal[8])
        h.pt3dadd(-101.59, -16.895, -2.324, 0.834, sec=self.basal[8])
        h.pt3dadd(-104.47, -20.135, -3.244, 0.872, sec=self.basal[8])
        h.pt3dadd(-106.502, -23.151, -3.947, 0.784, sec=self.basal[8])
        h.pt3dadd(-108.055, -26.209, -4.515, 0.798, sec=self.basal[8])
        h.pt3dadd(-110.728, -29.518, -5.631, 0.798, sec=self.basal[8])
        h.pt3dadd(-113.278, -32.758, -9.111, 0.756, sec=self.basal[8])
        h.pt3dadd(-116.798, -35.348, -10.931, 0.776, sec=self.basal[8])
        h.pt3dadd(-119.038, -37.288, -14.551, 0.786, sec=self.basal[8])
        h.pt3dadd(-121.278, -39.558, -17.851, 0.732, sec=self.basal[8])
        h.pt3dadd(-124.798, -42.148, -20.151, 0.788, sec=self.basal[8])
        h.pt3dadd(-127.15, -46.524, -19.989, 0.748, sec=self.basal[8])
        h.pt3dadd(-130.234, -50.645, -19.025, 0.712, sec=self.basal[8])
        h.pt3dadd(-132.082, -54.729, -18.852, 0.64, sec=self.basal[8])
        h.pt3dadd(-134.952, -57.639, -18.852, 0.64, sec=self.basal[8])
        h.pt3dadd(-137.192, -60.229, -22.812, 0.64, sec=self.basal[8])
        h.pt3dadd(-140.072, -62.499, -24.332, 0.64, sec=self.basal[8])
        h.pt3dadd(-143.272, -64.449, -23.972, 0.64, sec=self.basal[8])
        h.pt3dadd(-145.192, -66.709, -23.972, 0.64, sec=self.basal[8])
        h.pt3dadd(-147.752, -69.309, -26.752, 0.64, sec=self.basal[8])
        h.pt3dadd(-149.982, -72.219, -25.852, 0.64, sec=self.basal[8])
        h.pt3dadd(-150.302, -77.079, -26.312, 0.64, sec=self.basal[8])
        h.pt3dadd(-152.222, -79.999, -27.112, 0.64, sec=self.basal[8])
        h.pt3dadd(-153.182, -83.889, -27.772, 0.64, sec=self.basal[8])
        h.pt3dadd(-156.062, -87.119, -28.132, 0.64, sec=self.basal[8])
        h.pt3dadd(-157.342, -91.009, -28.052, 0.64, sec=self.basal[8])
        h.pt3dadd(-158.822, -95.029, -26.292, 0.64, sec=self.basal[8])
        h.pt3dadd(-160.732, -99.569, -26.272, 0.64, sec=self.basal[8])
        h.pt3dadd(-162.012, -102.479, -25.372, 0.64, sec=self.basal[8])
        h.pt3dadd(-164.572, -106.049, -24.672, 0.32, sec=self.basal[8])
        h.pt3dadd(-167.132, -110.579, -24.672, 0.32, sec=self.basal[8])
        h.pt3dadd(-168.732, -116.409, -26.352, 0.32, sec=self.basal[8])
Ejemplo n.º 6
0
def load(filename, fileformat=None, cell=None, use_axon=True, xshift=0, yshift=0, zshift=0):
    """
    Load an SWC from filename and instantiate inside cell. Code kindly provided
    by @ramcdougal.

    Args:
        filename = .swc file containing morphology
        cell = Cell() object. (Default: None, creates new object)
        filename = the filename of the SWC file
        use_axon = include the axon? Default: True (yes)
        xshift, yshift, zshift = use to position the cell

    Returns:
        Cell() object with populated soma, axon, dend, & apic fields

    Minimal example:
        # pull the morphology for the demo from NeuroMorpho.Org
        from PyNeuronToolbox import neuromorphoorg
        with open('c91662.swc', 'w') as f:
            f.write(neuromorphoorg.morphology('c91662'))
        cell = load_swc(filename)

    """

    if cell is None:
        cell = Cell(name=string.join(filename.split('.')[:-1]))

    if fileformat is None:
        fileformat = filename.split('.')[-1]

    name_form = {1: 'soma[%d]', 2: 'axon[%d]', 3: 'dend[%d]', 4: 'apic[%d]'}

    # load the data. Use Import3d_SWC_read for swc, Import3d_Neurolucida3 for
    # Neurolucida V3, Import3d_MorphML for MorphML (level 1 of NeuroML), or
    # Import3d_Eutectic_read for Eutectic.
    if fileformat == 'swc':
        morph = h.Import3d_SWC_read()
    elif fileformat == 'asc':
        morph = h.Import3d_Neurolucida3()
    else:
        raise Exception('file format `%s` not recognized'%(fileformat))
    morph.input(filename)

    # easiest to instantiate by passing the loaded morphology to the Import3d_GUI
    # tool; with a second argument of 0, it won't display the GUI, but it will allow
    # use of the GUI's features
    i3d = h.Import3d_GUI(morph, 0)

    # get a list of the swc section objects
    swc_secs = i3d.swc.sections
    swc_secs = [swc_secs.object(i) for i in xrange(int(swc_secs.count()))]

    # initialize the lists of sections
    sec_list = {1: cell.soma, 2: cell.axon, 3: cell.dend, 4: cell.apic}

    # name and create the sections
    real_secs = {}
    for swc_sec in swc_secs:
        cell_part = int(swc_sec.type)

        # skip everything else if it's an axon and we're not supposed to
        # use it... or if is_subsidiary
        if (not(use_axon) and cell_part == 2) or swc_sec.is_subsidiary:
            continue
        
        # figure out the name of the new section
        if cell_part not in name_form:
            raise Exception('unsupported point type')
        name = name_form[cell_part] % len(sec_list[cell_part])

        # create the section
        sec = h.Section(name=name)
        
        # connect to parent, if any
        if swc_sec.parentsec is not None:
            sec.connect(real_secs[swc_sec.parentsec.hname()](swc_sec.parentx))

        # define shape
        if swc_sec.first == 1:
            h.pt3dstyle(1, swc_sec.raw.getval(0, 0), swc_sec.raw.getval(1, 0),
                        swc_sec.raw.getval(2, 0), sec=sec)

        j = swc_sec.first
        xx, yy, zz = [swc_sec.raw.getrow(i).c(j) for i in xrange(3)]
        dd = swc_sec.d.c(j)
        if swc_sec.iscontour_:
            # never happens in SWC files, but can happen in other formats supported
            # by NEURON's Import3D GUI
            raise Exception('Unsupported section style: contour')

        if dd.size() == 1:
            # single point soma; treat as sphere
            x, y, z, d = [dim.x[0] for dim in [xx, yy, zz, dd]]
            for xprime in [x - d / 2., x, x + d / 2.]:
                h.pt3dadd(xprime + xshift, y + yshift, z + zshift, d, sec=sec)
        else:
            for x, y, z, d in zip(xx, yy, zz, dd):
                h.pt3dadd(x + xshift, y + yshift, z + zshift, d, sec=sec)

        # store the section in the appropriate list in the cell and lookup table               
        sec_list[cell_part].append(sec)    
        real_secs[swc_sec.hname()] = sec

    cell.all = cell.soma + cell.apic + cell.dend + cell.axon
    return cell