Describe the bug
SlidingPatchWSIDataset builds ProbMapKeys.LOCATION with np.round(...) and never casts back to int, so the metadata is float64. ProbMapProducer uses it directly as an array index, which numpy 2.x rejects:
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`)
and integer or boolean arrays are valid indices
MaskedPatchWSIDataset already calls .astype(int) on the same key, so the two datasets emit different dtypes.
To Reproduce
Steps to reproduce the behavior:
To Reproduce
Steps to reproduce the behavior:
- Install:
pip install "monai==1.6.1" "numpy>=2.0" torch tifffile
- Run:
import numpy as np, tifffile, tempfile, os
from monai.data import SlidingPatchWSIDataset
from monai.utils.enums import WSIPatchKeys, ProbMapKeys
path = os.path.join(tempfile.mkdtemp(), "slide.tiff")
tifffile.imwrite(path, np.random.randint(0, 255, (4, 4, 3), dtype=np.uint8), photometric="rgb")
ds = SlidingPatchWSIDataset(
data=[{"image": path, WSIPatchKeys.LEVEL: 0}], patch_size=(2, 2), reader="TiffFile")
print(ds.data[0][ProbMapKeys.LOCATION.value].dtype)
Output: float64 (expected an integer dtype)
- Run sliding-window WSI inference with
ProbMapProducer attached. It raises at monai/handlers/probability_maps.py:
self.prob_map[name][tuple(loc)] = prob
Expected behavior
ProbMapKeys.LOCATION should be an integer array, consistent with MaskedPatchWSIDataset, and ProbMapProducer should index the probability map without error.
Screenshots
N/A — traceback included above.
Environment
MONAI version: 1.6.1
Numpy version: 2.5.3
Pytorch version: 2.14.0+cpu
MONAI flags: HAS_EXT=False, USE_COMPILED=False, USE_META_DICT=False
MONAI rev id: 7af492176792f9069b8f1253d099abd05c5e769d
System: Linux
Linux version: Ubuntu 24.04 LTS
Platform: Linux-6.8.0-31-generic-x86_64-with-glibc2.39
Python version: 3.12.3
Minimal venv for reproducing against a released wheel, so optional dependencies report NOT INSTALLED.
Describe the bug
SlidingPatchWSIDatasetbuildsProbMapKeys.LOCATIONwithnp.round(...)and never casts back to int, so the metadata isfloat64.ProbMapProduceruses it directly as an array index, which numpy 2.x rejects:MaskedPatchWSIDatasetalready calls.astype(int)on the same key, so the two datasets emit different dtypes.To Reproduce
Steps to reproduce the behavior:
To Reproduce
Steps to reproduce the behavior:
pip install "monai==1.6.1" "numpy>=2.0" torch tifffilefloat64(expected an integer dtype)ProbMapProducerattached. It raises atmonai/handlers/probability_maps.py:Expected behavior
ProbMapKeys.LOCATIONshould be an integer array, consistent withMaskedPatchWSIDataset, andProbMapProducershould index the probability map without error.Screenshots
N/A — traceback included above.
Environment
Minimal venv for reproducing against a released wheel, so optional dependencies report
NOT INSTALLED.