Skip to content

Commit 6acf6f3

Browse files
committed
remove unused code
1 parent bffaabd commit 6acf6f3

File tree

3 files changed

+9
-52
lines changed

3 files changed

+9
-52
lines changed

tests/engines/test_nucleus_detection_engine.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_write_detection_records_to_store_no_class_dict() -> None:
9090

9191

9292
def test_nucleus_detector_patch_annotation_store_output(
93-
remote_sample: Callable, tmp_path: Path
93+
remote_sample: Callable, track_tmp_path: Path
9494
) -> None:
9595
"""Test for nucleus detection engine in patch mode."""
9696
mini_wsi_svs = Path(remote_sample("wsi1_2k_2k_svs"))
@@ -106,7 +106,7 @@ def test_nucleus_detector_patch_annotation_store_output(
106106

107107
pretrained_model = "sccnn-conic"
108108

109-
save_dir = tmp_path
109+
save_dir = track_tmp_path
110110

111111
nucleus_detector = NucleusDetector(model=pretrained_model)
112112
_ = nucleus_detector.run(
@@ -195,7 +195,7 @@ def test_nucleus_detector_patches_dict_output(
195195

196196

197197
def test_nucleus_detector_patches_zarr_output(
198-
remote_sample: Callable, tmp_path: Path
198+
remote_sample: Callable, track_tmp_path: Path
199199
) -> None:
200200
"""Test for nucleus detection engine in patch mode."""
201201
mini_wsi_svs = Path(remote_sample("wsi1_2k_2k_svs"))
@@ -212,7 +212,7 @@ def test_nucleus_detector_patches_zarr_output(
212212

213213
nucleus_detector = NucleusDetector(model=pretrained_model)
214214

215-
save_dir = tmp_path
215+
save_dir = track_tmp_path
216216

217217
output_path = nucleus_detector.run(
218218
patch_mode=True,
@@ -240,13 +240,13 @@ def test_nucleus_detector_patches_zarr_output(
240240
_rm_dir(save_dir)
241241

242242

243-
def test_nucleus_detector_wsi(remote_sample: Callable, tmp_path: Path) -> None:
243+
def test_nucleus_detector_wsi(remote_sample: Callable, track_tmp_path: Path) -> None:
244244
"""Test for nucleus detection engine."""
245245
mini_wsi_svs = Path(remote_sample("wsi4_512_512_svs"))
246246

247247
pretrained_model = "sccnn-conic"
248248

249-
save_dir = tmp_path
249+
save_dir = track_tmp_path
250250

251251
nucleus_detector = NucleusDetector(model=pretrained_model)
252252
nucleus_detector.drop_keys = []

tiatoolbox/cli/nucleus_detector.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import shutil
56
from typing import TYPE_CHECKING
67

78
from tiatoolbox.cli.common import (
@@ -173,3 +174,5 @@ def nucleus_detector(
173174
overwrite=overwrite,
174175
verbose=verbose,
175176
)
177+
178+
shutil.rmtree(cache_path)

tiatoolbox/models/engine/nucleus_detector.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -713,52 +713,6 @@ def _save_predictions_annotation_store(
713713
class_dict=class_dict,
714714
)
715715

716-
@staticmethod
717-
def _extract_nonzero(
718-
block: np.ndarray, block_info: dict | None = None
719-
) -> np.ndarray:
720-
"""Extract non-zero detections from a block with global coordinates.
721-
722-
Args:
723-
block: Input block array of shape (H, W, C).
724-
block_info: Dask block information containing array location.
725-
726-
Returns:
727-
2D array of shape (N, 4) where each row is [y, x, class, prob].
728-
If no detections, returns array of shape (0, 4).
729-
730-
"""
731-
# Local indices within this chunk
732-
ys, xs, classes = np.nonzero(block)
733-
probs = block[ys, xs, classes]
734-
735-
# Get chunk offset from block_info
736-
if block_info is not None:
737-
info = block_info[0]
738-
locs = info["array-location"]
739-
y_offset = locs[0][0]
740-
x_offset = locs[1][0]
741-
742-
# Adjust to global coordinates
743-
ys = ys + y_offset
744-
xs = xs + x_offset
745-
746-
# Stack into (N, 4) array: [y, x, class, prob]
747-
if len(ys) > 0:
748-
result = np.column_stack(
749-
[
750-
ys.astype(np.uint32),
751-
xs.astype(np.uint32),
752-
classes.astype(np.uint32),
753-
probs.astype(np.float32),
754-
]
755-
)
756-
else:
757-
# Return empty array with correct shape
758-
result = np.empty((0, 4), dtype=np.float32)
759-
760-
return result
761-
762716
@staticmethod
763717
def _centroid_maps_to_detection_arrays(
764718
detection_maps: da.Array,

0 commit comments

Comments
 (0)