spatialtis_core.neighbors#

Module Contents#

spatialtis_core.neighbors.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

Parameters
  • bbox – A list of bounding box

  • labels – Integer to label your bounding box

  • expand – Expand the bounding box to search for neighbors

  • scale – Scale the bounding box to search for neighbors

Returns

A list of neighbors

spatialtis_core.neighbors.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

Parameters
  • bbox_collections – A list of bounding box

  • labels – Integer to label your bounding box

  • expand – Expand the bounding box to search for neighbors

  • scale – Scale the bounding box to search for neighbors

Returns

A list of neighbors

spatialtis_core.neighbors.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]]

Parameters
  • points – A list of points

  • labels – Integer to labels your points

  • r – Radius range to search for neighbors

  • k – Number of nearest neighbors

  • method – “kdtree” or “delaunay”

Returns

A list of neighbors

spatialtis_core.neighbors.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]]

Parameters
  • points_collections – A list of points in ROIs

  • labels_collections – Integer to labels your points

  • r – Radius range to search for neighbors

  • k – Number of nearest neighbors

  • method – “kdtree” or “delaunay”

Returns

A list of neighbors