diff --git a/src/histolab/tiler.py b/src/histolab/tiler.py index 754c2f95..37188ddb 100644 --- a/src/histolab/tiler.py +++ b/src/histolab/tiler.py @@ -29,7 +29,7 @@ class Tiler(Protocol): tile_size: int @lru_cache(maxsize=100) - def box_mask_thumb(self, slide: Slide) -> np.ndarray: + def box_mask(self, slide: Slide) -> np.ndarray: """Return binary mask, at thumbnail level, of the box for tiles extraction. The mask pixels set to True correspond to the tissue box. @@ -224,7 +224,7 @@ def _grid_coordinates_generator(self, slide: Slide) -> CoordinatePair: Iterator[CoordinatePair] Iterator of tiles' CoordinatePair """ - box_mask_thumb = self.box_mask_thumb(slide) + box_mask_thumb = self.box_mask(slide) regions = regions_from_binary_mask(box_mask_thumb) for region in regions: # at the moment there is only one region @@ -415,7 +415,7 @@ def _random_tile_coordinates(self, slide: Slide) -> CoordinatePair: CoordinatePair Random tile Coordinates at level 0 """ - box_mask_thumb = self.box_mask_thumb(slide) + box_mask_thumb = self.box_mask(slide) tile_w_lvl, tile_h_lvl = self.tile_size x_ul_lvl = np.random.choice(np.where(box_mask_thumb)[1]) diff --git a/tests/unit/test_tiler.py b/tests/unit/test_tiler.py index 2eb8ac70..ae881ead 100644 --- a/tests/unit/test_tiler.py +++ b/tests/unit/test_tiler.py @@ -129,7 +129,7 @@ def it_can_generate_random_coordinates(self, request, tmpdir): image.save(os.path.join(tmp_path_, "mywsi.png"), "PNG") slide_path = os.path.join(tmp_path_, "mywsi.png") slide = Slide(slide_path, "processed") - _box_mask_thumb = method_mock(request, RandomTiler, "box_mask_thumb") + _box_mask_thumb = method_mock(request, RandomTiler, "box_mask") _box_mask_thumb.return_value = NpArrayMock.ONES_500X500_BOOL _tile_size = property_mock(request, RandomTiler, "tile_size") _tile_size.return_value = (128, 128) @@ -169,7 +169,7 @@ def it_knows_its_box_mask(self, request, tmpdir, check_tissue, expected_box): _biggest_tissue_box_mask.return_value = expected_box random_tiler = RandomTiler((128, 128), 10, 0, check_tissue=check_tissue) - box_mask = random_tiler.box_mask_thumb(slide) + box_mask = random_tiler.box_mask(slide) _biggest_tissue_box_mask.assert_called_once_with() assert type(box_mask) == np.ndarray @@ -446,7 +446,7 @@ def it_knows_its_box_mask(self, request, tmpdir, check_tissue, expected_box): _biggest_tissue_box_mask.return_value = expected_box grid_tiler = GridTiler((128, 128), 0, check_tissue=check_tissue) - box_mask = grid_tiler.box_mask_thumb(slide) + box_mask = grid_tiler.box_mask(slide) _biggest_tissue_box_mask.assert_called_once_with() assert type(box_mask) == np.ndarray