Commit 2a12c4b
Add input validation to ImageStats class (#8501)
Fixes # .
### Description
This pull request adds input validation to the ImageStats class in
monai/auto3dseg/analyzer.py.
Specifically, it introduces type and value checks at the start of the
__call__ method to ensure: The input is a dictionary. The specified
image_key exists in the input data. The value for image_key is a NumPy
array, torch.Tensor, or MetaTensor. The image array has at least 3
dimensions. If any of these checks fail, an informative error is
raised.This enhancement improves robustness and user experience by
providing clearer feedback when invalid data is passed to the analyzer.
### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved input validation for image statistics analysis to provide
clearer error messages when inputs are invalid.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Emdya Permuy <[email protected]>
Signed-off-by: YunLiu <[email protected]>
Co-authored-by: YunLiu <[email protected]>
Co-authored-by: Eric Kerfoot <[email protected]>1 parent ede6ace commit 2a12c4b
1 file changed
+16
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
220 | 236 | | |
221 | 237 | | |
222 | 238 | | |
| |||
0 commit comments