コード例 #1
0
ファイル: cellorg.py プロジェクト: nrnhines/Heart-3D
def test4():
    from neuron import h, gui
    # distance between circles as function of surface distance for
    # inner and outemost layers. Also length of cells.
    g1 = h.Graph()
    #for j, layer in enumerate([0, nlayer-1]):
    for j, layer in enumerate(range(nlayer)):
        p0 = xyz(layer, 0, 0)
        d_surf = [
            distance(xyz(layer, i, 0), p0) for i in range(1, ncircle[layer])
        ]
        d_circle = [
            distance(xyz(layer, i, 0), xyz(layer, i - 1, 0))
            for i in range(1, ncircle[layer])
        ]
        print(d_circle, d_surf)
        h.Vector(d_circle).line(g1, h.Vector(d_surf), j + 1, 2)
    return g1
コード例 #2
0
ファイル: cellorg.py プロジェクト: nrnhines/Heart-3D
def test2(layer, circle, ipt):
    print(layer, circle, ipt)
    print("npts ", npts[ilayer][circle], npts[ilayer][circle + 1])
    a = overlap((layer, circle, ipt), layer, circle + 1)
    print(a)
    for x in a:
        b = overlap((layer, circle + 1, x[0]), layer, circle)
        print(b)

    print("length d_angle of circle ", circle,
          distance(xyz(layer, circle, 0), xyz(layer, circle, 1)),
          ipt2angle(1, layer, circle))
    print("length d_angle of circle ", circle + 1,
          distance(xyz(layer, circle + 1, 0), xyz(layer, circle + 1, 1)),
          ipt2angle(1, layer, circle + 1))

    for i, y in enumerate([a, b]):
        c = circle + (1 - i)
        for x in y:
            print([layer, c, x[0]], xyz(layer, c, x[0]))
    print()
コード例 #3
0
ファイル: cellorg.py プロジェクト: nrnhines/Heart-3D
def test5():  #pt2circle
    from neuron import h, gui
    o0 = paraboloid[0]
    n = 4
    o1 = paraboloid[n]
    d = distance(o1[0][0], o0[0][0])
    g = h.Graph()
    for p in o1:
        g.mark(p[0][0], p[0][2], "|", 10, 1, 1)
    for o in o0:
        p = o[0]
        p1 = addmul(p, d, normgrad(p))
        i = pt2circle(n, p1)
        g.mark(p1[0], p1[2], "|", 10, 2, 1)
        g.mark(o1[i][0][0], o1[i][0][2], "|", 10, 3, 1)
        d1 = distance(p1, o1[i][0])
        if i < len(o1) - 1:
            zi = o1[i][0][2]
            z = p1[2]
            zip = o1[i + 1][0][2]
            print("zi=%g z=%g zip=%g" % (zi, z, zip))
            assert (zi <= z + 1e-9 and z <= zip + 1e-9)
    return g
コード例 #4
0
def gaps_for_gid(gid):
    if not gid_is_simulated(gid):
        return None
    o = gid2org(gid)
    ilayer, icircle, ipt = o
    pinfo = paraboloid[ilayer][icircle]
    rf = pinfo[2]  # RegionFace
    a = ipt2angle(1, ilayer, icircle)
    afirst = a * ipt
    alast = a * (ipt + 1)
    gs = []

    #circum coordinate, end to end
    if icircle < ncircle[ilayer] - 1:
        npt = npts[ilayer][icircle]
        area = area_circum(ilayer, icircle)
        for jpt in [ipt - 1, ipt + 1]:
            g2 = org2gid(ilayer, icircle, jpt)
            if g2 > gid:
                #dens_ipt = ipt if jpt < ipt else jpt%npts[ilayer][icircle]
                #g = conductance_density_circum(ilayer, icircle, dens_ipt)
                if gid_is_simulated(g2):
                    gs.append(set_gap(gid, g2, area))  #abscond(area, g)))

    # between layers
    if icircle < ncircle[ilayer] - 1:
        pinfo1 = paraboloid[ilayer][icircle + 1]
        for jlayer in [ilayer - 1, ilayer + 1]:
            if jlayer >= 0 and jlayer < nlayer:
                # usually 2, sometimes 1, and rarely 3, circles in jlayer overlap icircle
                # n = int(param.layer_thickness/param.cell_diameter)
                n = 1

                #jcircle, b = rf.p0b if jlayer < ilayer else rf.p1b
                p0, plast, (jcircle,
                            b) = (pinfo[0], pinfo1[0],
                                  rf.p0b) if jlayer < ilayer else (pinfo[1],
                                                                   pinfo1[1],
                                                                   rf.p1b)

                for p1 in b + [plast]:
                    jpt, angles = angle_overlap(o, jlayer, jcircle)
                    a0 = afirst
                    for a1 in angles + [alast]:
                        area = side_area(p0, p1, a1 - a0)
                        if area > 1e-9:  # ignore very small areas
                            g2 = org2gid(jlayer, jcircle, jpt)
                            if g2 > gid:
                                #dens_layer, dens_circle, dens_ipt = (ilayer, icircle, ipt) if jlayer < ilayer else (jlayer, jcircle, jpt)
                                #g = conductance_density_layer(dens_layer, dens_circle, dens_ipt)
                                if gid_is_simulated(
                                        g2) and jcircle < ncircle[jlayer] - 1:
                                    gs.append(set_gap(
                                        gid, g2, area))  #abscond(area, g)))
                        jpt += 1
                        a0 = a1
                    jcircle += 1
                    p0 = p1

    # between circles in same layer
    jlayer = ilayer
    for jcircle in [icircle - 1, icircle + 1]:
        if jcircle >= 0 and jcircle < ncircle[jlayer]:
            # how many cells between icircle and jcircle
            d = distance(xyz(ilayer, icircle, 0), xyz(jlayer, jcircle, 0))
            n = int(d / param.cell_diameter)

            jpt, angles = angle_overlap(o, jlayer, jcircle)
            a0 = afirst
            pinfo1 = paraboloid[ilayer][jcircle]
            p0, p1, dens_circle, dens_ipt = (pinfo[0], pinfo[1], icircle,
                                             ipt) if jcircle < icircle else (
                                                 pinfo1[0], pinfo1[1], jcircle,
                                                 jpt)
            for a1 in angles + [alast]:
                area = side_area(p0, p1, a1 - a0)
                if area > 1e-9:
                    g2 = org2gid(jlayer, jcircle, jpt)
                    if g2 > gid:
                        #dens_circle, dens_ipt = (icircle, ipt) if jcircle < icircle else (jcircle, jpt)
                        #g = conductance_density_parabola(ilayer, dens_circle, dens_ipt)
                        if gid_is_simulated(
                                g2) and jcircle < ncircle[jlayer] - 1:
                            gs.append(set_gap(gid, g2,
                                              area))  #abscond(area, g)))
                jpt += 1
                a0 = a1

    return gs
コード例 #5
0
ファイル: util.py プロジェクト: nrnhines/Heart-3D
def area3pt(pts):
  d = [distance(pts[i], pts[(i+1)%3]) for i in range(3)]
  return accurate_triangle_area(*d)
コード例 #6
0
ファイル: util.py プロジェクト: nrnhines/Heart-3D
def end_area(pts):
  d = [distance(pts[i], pts[(i+1)%4]) for i in range(4)]
  x = distance(pts[0], pts[2])
  return accurate_triangle_area(d[0], d[1], x) + accurate_triangle_area(x, d[2], d[3])