:py:mod:`spatialtis_core.neighbors` =================================== .. py:module:: spatialtis_core.neighbors Module Contents --------------- .. py:function:: bbox_neighbors(bbox: List[spatialtis_core.types.BoundingBox], labels: spatialtis_core.types.Labels, expand: float = -1.0, scale: float = 1.3) -> List[List[int]] Get neighbors for each bounding box :param bbox: A list of bounding box :param labels: Integer to label your bounding box :param expand: Expand the bounding box to search for neighbors :param scale: Scale the bounding box to search for neighbors :returns: A list of neighbors .. py:function:: bbox_neighbors_parallel(bbox_collections: List[List[spatialtis_core.types.BoundingBox]], labels: List[spatialtis_core.types.Labels], expand: Optional[float] = None, scale: Optional[float] = None) -> List[List[int]] Get neighbors for each bounding box :param bbox_collections: A list of bounding box :param labels: Integer to label your bounding box :param expand: Expand the bounding box to search for neighbors :param scale: Scale the bounding box to search for neighbors :returns: A list of neighbors .. py:function:: points_neighbors(points: spatialtis_core.types.Points, labels: spatialtis_core.types.Labels, r: Optional[float] = None, k: Optional[int] = None, method: str = 'kdtree') -> List[List[int]] Get neighbors for each points When search with KD-tree, you can use either `r` or `k`. If r = 5, it will search for all points within 5; If k = 5, it will search for the 5 nearest neighbors; If combined, r = 5 and k = 5, it will search for at most 5 neighbors within 5; When search with Delaunay triangulation, there is no parameter. The return list follow the order of labels. For example, if serach for points of [100, 101, 102], the result may look like [[100, 102], [101, 102], [102, 100, 101]] :param points: A list of points :param labels: Integer to labels your points :param r: Radius range to search for neighbors :param k: Number of nearest neighbors :param method: "kdtree" or "delaunay" :returns: A list of neighbors .. py:function:: points_neighbors_parallel(points_collections: List[spatialtis_core.types.Points], labels_collections: List[spatialtis_core.types.Labels], r: Optional[float] = None, k: Optional[int] = None, method: str = 'kdtree') -> List[List[int]] Get neighbors for each points When search with KD-tree, you can use either `r` or `k`. If r = 5, it will search for all points within 5; If k = 5, it will search for the 5 nearest neighbors; If combined, r = 5 and k = 5, it will search for at most 5 neighbors within 5; When search with Delaunay triangulation, there is no parameter. The return list follow the order of labels. For example, if serach for points of [100, 101, 102], the result may look like [[100, 102], [101, 102], [102, 100, 101]] :param points_collections: A list of points in ROIs :param labels_collections: Integer to labels your points :param r: Radius range to search for neighbors :param k: Number of nearest neighbors :param method: "kdtree" or "delaunay" :returns: A list of neighbors