Skip to content

Commit

Permalink
HESTData: add cellvit and tissue_contours to shapes and coordinate sy…
Browse files Browse the repository at this point in the history
…stems
  • Loading branch information
konst-int-i committed Oct 29, 2024
1 parent 239901a commit 82f0779
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/hest/HESTData.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,17 @@ def read_hest_wsi(wsi: WSI, width, height):
scale_lowres = Scale([tissue_lowres_scalef, tissue_lowres_scalef], axes=("x", "y"))
shapes_transformations[f"{dataset_id}_downscaled_lowres"] = scale_lowres

# add cellvit and tissue contours
for it in self.shapes:
shape = it.shapes
key = it.name
if len(shape) > 0 and isinstance(shape.iloc[0], Point):
shape['radius'] = 1
val = ShapesModel.parse(shape, transformations=shapes_transformations)
shapes[key] = val
if self._tissue_contours is not None:
shapes['tissue_contours'] = ShapesModel.parse(self._tissue_contours, transformations=shapes_transformations)

# validate the spot_diameter_fullres value
if len(spot_diameter_fullres_list) > 0:
d = np.array(spot_diameter_fullres_list)
Expand All @@ -653,7 +664,6 @@ def read_hest_wsi(wsi: WSI, width, height):
if SPATIAL in self.adata.obsm:
xy = self.adata.obsm[SPATIAL]
radius = spot_diameter_fullres / 2
# breakpoint()
shapes[REGION] = ShapesModel.parse(xy, geometry=0, radius=radius, transformations=shapes_transformations)

# link the shapes to the table
Expand All @@ -666,7 +676,7 @@ def read_hest_wsi(wsi: WSI, width, height):
new_table = TableModel.parse(new_table, region=REGION, region_key=REGION_KEY, instance_key=INSTANCE_KEY)
else:
new_table = self.adata.copy()

return SpatialData(tables=new_table, images=images, shapes=shapes)

class VisiumHESTData(HESTData):
Expand Down

0 comments on commit 82f0779

Please sign in to comment.