Repository navigation
Conversation
…-MONAI#9184) When the input has no channel dim, the cached spatial_ndim was clamped to ndim - 1 at construction and was not updated after the channel dim was added. Crops then built a translation with too few dims and lost the offset on the last spatial axis. Recompute spatial_ndim from the affine once the channel dim exists. Signed-off-by: Sebastian Penhouet <7819068+Spenhouet@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Signed-off-by: Sebastian Penhouet <7819068+Spenhouet@users.noreply.github.com>
Fixes #9184.
Description
EnsureChannelFirstwithchannel_dim="no_channel"adds a channel dim, but the cachedMetaTensor.spatial_ndimwas computed before that and clamped tondim - 1. For a(H, W, D)input with a 4x4 affine it stayed at 2. Crops then built a 2D translation frompeek_pending_rank()and the offset on the third axis was lost.After adding the channel dim, I now recompute
spatial_ndimfrom the affine (only for the no-channel case and a non-batched affine). Inputs where an existing channel dim is moved are not touched.I added tests to
test_ensure_channel_firstd.pythat checkspatial_ndimfor 3D and 2D channel-less input, and thatSpatialCropdgets the full origin shift afterwards. They fail ondevwithout the change.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.I ran the meta tensor, EnsureChannelFirst, crop, spacing, load image and utility transform tests locally, plus black, isort and ruff on the changed files.