Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

ProbMapProducer raises IndexError on numpy 2.x: SlidingPatchWSIDataset emits float locations

Ouverte Adaptée aux débutants
#9,135 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
82/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
numpy, python, pytorch

Piste de recherche

Commencez par SlidingPatchWSIDataset et MaskedPatchWSIDataset, en comparant la manière dont chacun construit ProbMapKeys.LOCATION, puis examinez l’indexation dans monai/handlers/probability_maps.py. Reproduisez le problème avec NumPy 2.x en utilisant le snippet fourni et l’inférence par fenêtre glissante ; le travail est terminé lorsque les métadonnées de localisation ont un type entier et que ProbMapProducer indexe la carte de probabilités sans IndexError.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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:

  1. Install: pip install "monai==1.6.1" "numpy>=2.0" torch tifffile
  2. 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)
  3. 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.

Langage dominant
Python
Étoiles
8.7k
Forks
1.6k
Merge moyen
3 j 10 h
PR mergées (30 j)
18

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Project-MONAI/MONAI

Toutes les issues de Project-MONAI/MONAI

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.