Skip to content

Commit b2d2095

Browse files
authored
for large scale use convex hull to generate a boundary
1 parent db4b741 commit b2d2095

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/segger/validation/xenium_explorer.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,24 @@
99
import matplotlib.pyplot as plt
1010
from tqdm import tqdm
1111
from typing import Dict, Any, Optional, List, Tuple
12-
from segger.prediction.boundary import generate_boundary
12+
# from segger.prediction.boundary import generate_boundary
1313
from zarr.storage import ZipStore
1414
import zarr
1515

1616

17+
def generate_boundary(seg_cell):
18+
"""Generate convex hull boundary for a cell"""
19+
# Your existing implementation
20+
points = seg_cell[['x_location', 'y_location']].values
21+
if len(points) < 3:
22+
return None
23+
try:
24+
from scipy.spatial import ConvexHull
25+
hull = ConvexHull(points)
26+
return Polygon(points[hull.vertices])
27+
except:
28+
return None
29+
1730
def get_flatten_version(polygon_vertices: List[List[Tuple[float, float]]], max_value: int = 21) -> np.ndarray:
1831
"""Standardize list of polygon vertices to a fixed shape.
1932

0 commit comments

Comments
 (0)