Skip to content

Commit 5c8cb38

Browse files
committed
2 parents f3028ad + 6031259 commit 5c8cb38

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

cellvit/data/dataclass/wsi_meta.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def find_target_mpp(base_mpp: float, downsample: int) -> float:
122122
"""
123123
# find the target mpp closest to 0.25 given that the following holds:
124124
product = base_mpp * downsample
125+
if product >= 0.20 and product <= 0.30:
126+
return product
125127
k_ideal = 4.0 / product
126128
if k_ideal < 1:
127129
k = 1

cellvit/inference/postprocessing_cupy.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,11 @@ def convert_patch_to_graph_nodes(
724724
wsi_scaling_factor = wsi.metadata["downsampling"]
725725
patch_size = wsi.metadata["patch_size"]
726726
x_global = int(
727-
patch_metadata["row"] * patch_size * wsi_scaling_factor
727+
patch_metadata["row"] * patch_size
728728
- (patch_metadata["row"] + 0.5) * wsi.metadata["patch_overlap"]
729729
)
730730
y_global = int(
731-
patch_metadata["col"] * patch_size * wsi_scaling_factor
731+
patch_metadata["col"] * patch_size
732732
- (patch_metadata["col"] + 0.5) * wsi.metadata["patch_overlap"]
733733
)
734734

@@ -745,9 +745,13 @@ def convert_patch_to_graph_nodes(
745745
):
746746
continue
747747
offset_global = np.array([x_global, y_global])
748-
centroid_global = np.rint(cell["centroid"] + np.flip(offset_global))
749-
contour_global = cell["contour"] + np.flip(offset_global)
750-
bbox_global = cell["bbox"] + offset_global
748+
centroid_global = np.rint(
749+
(cell["centroid"] + np.flip(offset_global)) * wsi_scaling_factor
750+
) # TODO: check for 0.499 mpp slides
751+
contour_global = (
752+
cell["contour"] + np.flip(offset_global)
753+
) * wsi_scaling_factor
754+
bbox_global = (cell["bbox"] + offset_global) * wsi_scaling_factor
751755
cell_dict = {
752756
"bbox": bbox_global.tolist(),
753757
"centroid": centroid_global.tolist(),

cellvit/inference/postprocessing_numpy.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,11 @@ def convert_patch_to_graph_nodes(
724724
wsi_scaling_factor = wsi.metadata["downsampling"]
725725
patch_size = wsi.metadata["patch_size"]
726726
x_global = int(
727-
patch_metadata["row"] * patch_size * wsi_scaling_factor
727+
patch_metadata["row"] * patch_size
728728
- (patch_metadata["row"] + 0.5) * wsi.metadata["patch_overlap"]
729729
)
730730
y_global = int(
731-
patch_metadata["col"] * patch_size * wsi_scaling_factor
731+
patch_metadata["col"] * patch_size
732732
- (patch_metadata["col"] + 0.5) * wsi.metadata["patch_overlap"]
733733
)
734734

@@ -745,9 +745,13 @@ def convert_patch_to_graph_nodes(
745745
):
746746
continue
747747
offset_global = np.array([x_global, y_global])
748-
centroid_global = np.rint(cell["centroid"] + np.flip(offset_global))
749-
contour_global = cell["contour"] + np.flip(offset_global)
750-
bbox_global = cell["bbox"] + offset_global
748+
centroid_global = np.rint(
749+
(cell["centroid"] + np.flip(offset_global)) * wsi_scaling_factor
750+
)
751+
contour_global = (
752+
cell["contour"] + np.flip(offset_global)
753+
) * wsi_scaling_factor
754+
bbox_global = (cell["bbox"] + offset_global) * wsi_scaling_factor
751755
cell_dict = {
752756
"bbox": bbox_global.tolist(),
753757
"centroid": centroid_global.tolist(),

0 commit comments

Comments
 (0)