def cut(self, w, pos, dep):
    
    def set_cut_1(act, grw):
      from math import sqrt
      for i in range(1, len(grw.points)):
        p = grw.points[i]
        d = plane_dist(p, w, pos)
        if d <= dep and act[i - 1].property.opacity == 1:
          op = 1.
        else:
          op = 0.
        act[i - 1].property.opacity = op
        
    def set_cut_2(acts, grws):
      for i in range(len(acts)):
        set_cut_1(acts[i], grws[i])
      

    from misc import centroid, mean
    if plane_dist(centroid(self.mitral.soma.points), w, pos) <= dep:
      self.soma.property.opacity = 1.
    else:
      self.soma.property.opacity = 0.
    set_cut_1(self.apic, self.mitral.apic)
    set_cut_2(self.tuft, self.mitral.tuft)
    set_cut_2(self.dend, self.mitral.dend)
    self.__cutted = (tuple(w), tuple(pos), dep)
Beispiel #2
0
        def drawsoma():
            pts = self.mitral.soma.points
            center = misc.centroid(pts)

            # calc. soma radius
            radius = 0.
            for p in pts:
                radius += misc.distance(p, center)
            radius /= len(pts)

            radius *= cone_factor

            # versor
            u = tuple(
                misc.versor(self.mitral.apic.points[0],
                            self.mitral.apic.points[1]))

            src = tvtk.ConeSource(center=tuple(center[0:3]),
                                  radius=radius,
                                  height=radius,
                                  direction=u,
                                  resolution=20)
            mapper = tvtk.PolyDataMapper(input=src.output)
            actor = tvtk.Actor(mapper=mapper)
            fig.scene.add_actor(actor)

            actor.property.color = self.soma_color
            return actor
Beispiel #3
0
def realSoma(i, p):
    soma1 = copy.deepcopy(__somar[i])

    # translation vector calculation
    vec = centroid(soma1)
    for j in range(3):
        vec[j] = p[j] - vec[j]

    # translate
    for x in soma1:
        for j in range(3):
            x[j] += vec[j]

    return soma1
Beispiel #4
0
    def fill_soma(sections, elements, cellid):
        points = []
        for sec in sections:
            points += sec.points

        center = misc.centroid(points)[:3]
        radius = 0.0
        for p in sec.points:
            radius += misc.distance(p[:3], center)
        radius /= len(points)

        verse = misc.versor(bulbdef.bulb_center, center)

        o = Soma(center, radius, verse)
        o.gids.append(cellid)
        elements.objs.append(o)
Beispiel #5
0
    def drawsoma():
      pts = self.mitral.soma.points
      center = misc.centroid(pts)

      # calc. soma radius
      radius = 0.
      for p in pts:
        radius += misc.distance(p, center)
      radius /= len(pts)

      radius *= cone_factor

      # versor
      u = tuple(misc.versor(self.mitral.apic.points[0], self.mitral.apic.points[1]))

      src = tvtk.ConeSource(center=tuple(center[0:3]), radius=radius, height=radius, direction=u, resolution=20)
      mapper = tvtk.PolyDataMapper(input=src.output)
      actor = tvtk.Actor(mapper=mapper)
      fig.scene.add_actor(actor)

      actor.property.color = self.soma_color 
      return actor
Beispiel #6
0
        self.__readsections(cell.soma)
        self.__readsections(cell.apic)
        self.__readsections(cell.tuft)
        self.__readsections(cell.dend)
        self.__connect(cell)
        return cell


if __name__ == '__main__':
    cr = CellReader('../bulbvis/mccells.car')
    hist = [0] * int(1040 / 40)
    import misc
    for i in range(635, 1904):
        try:
            cell = cr.readcell(i)
            center = misc.centroid(cell.soma[0].points)
            for dnd in cell.dend:
                for p in dnd.points:
                    d = misc.distance(p, center)
                    hist[int(d / 40)] += 1.
        except:
            break
    s = 0.
    for x in hist:
        s += x
    for i in range(len(hist)):
        hist[i] /= s
    with open('../sholl.txt', 'w') as fo:
        for i in range(len(hist)):
            fo.write('%d %g\n' % (i * 40, hist[i]))