Skip to content

Commit

Permalink
Rename box_mask_thumb in box_mask in tiler
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiamarcolini committed Aug 17, 2020
1 parent 47f4324 commit d0e9dbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/histolab/tiler.py
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_tiler.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d0e9dbb

Please sign in to comment.