Skip to content

Commit

Permalink
[FIX] add support for calculating centers on multi-scaled segmentatio…
Browse files Browse the repository at this point in the history
…n masks
  • Loading branch information
sophiamaedler committed Feb 10, 2025
1 parent f13256a commit 6299cc4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/scportrait/pipeline/_utils/sdata_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ def _get_centers(self, sdata: SpatialData, segmentation_label: str) -> PointsMod
if segmentation_label not in sdata.labels:
raise ValueError(f"Segmentation {segmentation_label} not found in sdata object.")

centers = calculate_centroids(sdata.labels[segmentation_label])
mask = sdata.labels[segmentation_label]
if isinstance(mask, xarray.DataTree):
mask = mask.scale0.image
centers = calculate_centroids(mask)
return centers

def _add_centers(self, segmentation_label: str, overwrite: bool = False) -> None:
Expand Down

0 comments on commit 6299cc4

Please sign in to comment.