diff --git a/monai/data/wsi_datasets.py b/monai/data/wsi_datasets.py index b183001835..76ace77fc2 100644 --- a/monai/data/wsi_datasets.py +++ b/monai/data/wsi_datasets.py @@ -306,7 +306,7 @@ def _evaluate_patch_locations(self, sample): ) ) # convert locations to mask_location - mask_locations = np.round((patch_locations + patch_size_0 // 2) / float(mask_ratio)) + mask_locations = np.round((patch_locations + patch_size_0 // 2) / float(mask_ratio)).astype(int) # fill out samples with location and metadata sample[WSIPatchKeys.SIZE.value] = patch_size diff --git a/tests/data/test_sliding_patch_wsi_dataset.py b/tests/data/test_sliding_patch_wsi_dataset.py index 8e27f7ad0e..63eb5da0ef 100644 --- a/tests/data/test_sliding_patch_wsi_dataset.py +++ b/tests/data/test_sliding_patch_wsi_dataset.py @@ -21,7 +21,7 @@ from parameterized import parameterized from monai.data import SlidingPatchWSIDataset -from monai.utils import WSIPatchKeys, optional_import, set_determinism +from monai.utils import ProbMapKeys, WSIPatchKeys, optional_import, set_determinism from tests.test_utils import download_url_or_skip_test, testing_data_config set_determinism(0) @@ -250,6 +250,8 @@ def test_read_patches_large(self, input_parameters, expected): steps = [round(expected[i]["ratio"] * s) for s in expected[i]["patch_size"]] expected_location = tuple(expected[i]["step_loc"][j] * steps[j] for j in range(len(steps))) assert_array_equal(sample["image"].meta[WSIPatchKeys.LOCATION], expected_location) + mask_location = np.asarray(sample["image"].meta[ProbMapKeys.LOCATION]) + self.assertTrue(np.issubdtype(mask_location.dtype, np.integer)) @skipUnless(has_cucim, "Requires cucim")