basics.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:SyConn 作者: StructuralNeurobiologyLab 项目源码 文件源码
def convex_hull_area(pts):
    """
    Calculates the surface area from a given point cloud using simplices of
    its convex hull. For the estimation of the synapse contact area, divide by
    a factor of two, in order to get the area of only one face (we assume that
    the contact site is sufficiently thin represented by the points).
    :param pts: np.array of coordinates in nm (scaled)
    :return: Area of the point cloud (nm^2)
    """
    if len(pts) < 4:
        return 0
    area = 0
    try:
        ch = ConvexHull(pts)
        triangles = ch.points[ch.simplices]
        for triangle in triangles:
            area += poly_area(triangle)
    except QhullError as e:
        # warnings.warn("%s encountered during calculation of convex hull "
        #               "area with %d points. Returning 0 nm^2." %
        #               (e, len(pts)), RuntimeWarning)
        pass
    return area
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号