Commit a4d1a0d
authored
Fixes #8442
### Description
`LoadImage` with `ensure_channel_first=True` raises `ValueError` when
`set_track_meta(False)` is active.
**Root cause chain:**
1. `set_track_meta(False)` causes
`MetaTensor.ensure_torch_and_prune_meta()` to return a plain tensor
instead of a `MetaTensor`
2. `EnsureChannelFirst()(img)` then has no metadata source (img is not a
MetaTensor and no `meta_dict` is passed)
3. This hits the `ValueError` branch in `EnsureChannelFirst.__call__` at
line 205 of `utility/array.py`
**Fix:** pass `meta_data` explicitly to `EnsureChannelFirst` when `img`
is not a `MetaTensor`. `EnsureChannelFirst.__call__` already accepts a
`meta_dict` parameter; `meta_data` is always a validated dict at this
point in `LoadImage.__call__`.
### Types of changes
- [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.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.
---------
Signed-off-by: UGBOMEH OGOCHUKWU WILLIAMS <williamsugbomeh@gmail.com>
1 parent 5ebcade commit a4d1a0d
2 files changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
500 | 511 | | |
501 | 512 | | |
502 | 513 | | |
0 commit comments