Repository navigation
fix(data): cast SlidingPatchWSIDataset locations to int for numpy 2.x #9136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,9 @@ def __call__(self, engine: Engine) -> None: | |
| locs = engine.state.batch[CommonKeys.IMAGE].meta[ProbMapKeys.LOCATION] | ||
| probs = engine.state.output[self.prob_key] | ||
| for name, loc, prob in zip(names, locs, probs): | ||
| self.prob_map[name][tuple(loc)] = prob | ||
| # numpy 2.x rejects non-integer array indices, so coerce here for datasets that | ||
| # still supply float locations. The bundled WSI datasets already emit integers. | ||
| self.prob_map[name][tuple(int(i) for i in loc)] = prob | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Reject fractional locations before indexing. If a dataset supplies location 🤖 Prompt for AI Agents |
||
| with self.lock: | ||
| self.counter[name] -= 1 | ||
| if self.counter[name] == 0: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: Project-MONAI/MONAI
Length of output: 23620
🏁 Script executed:
Repository: Project-MONAI/MONAI
Length of output: 23620
🏁 Script executed:
Repository: Project-MONAI/MONAI
Length of output: 19777
🏁 Script executed:
Repository: Project-MONAI/MONAI
Length of output: 15649
Clamp rounded locations to the probability-map bounds.
The iterator can emit the edge patch at
(2, 2)for a 4×4 image with 2×2 patches. Withmask_ratio == 2, the current calculation rounds its center to(2, 2). A 2×2 probability map has valid indices only from 0 through 1.ProbMapProduceruses this value directly and can raiseIndexError.Clamp the locations to the reported mask size and add an edge-patch test with
mask_level > 0.🐛 Suggested fix
🤖 Prompt for AI Agents