Replies: 1 comment
-
Hi @michalhg, thanks for your interest here. Yes, this behavior is expected. In MONAI, all transforms (except for the loader) assume that the input data follows the shape [channel x spatial_dims]. This is also explicitly mentioned in the docstring for clarity. MONAI/monai/transforms/spatial/array.py Line 450 in 13b96ae https://github.com/Project-MONAI/MONAI/wiki/MONAI-Data-Shape-Assumption |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
when using Spacingd on an image_key than has not been loaded with channel first dimension, the scaling anf the affine matrix generated is incorrect.
LoadImaged(keys=[image_key]),
Spacingd(keys=[image_key], pixdim=(0.7, 0.7, 0.4), mode='bilinear',align_corners=True),
values of affine matrix after loadimage:
Image shape: torch.Size([512, 512, 1019])
Current affine:
[[-3.4582e-01, 0.0000e+00, 0.0000e+00, 5.3887e+01],
[ 0.0000e+00, -3.4582e-01, 0.0000e+00, 2.5348e+02],
[ 0.0000e+00, 0.0000e+00, 2.0000e-01, -1.2827e+03],
[ 0.0000e+00, 0.0000e+00, 0.0000e+00, 1.0000e+00]],
after resampling:
Image shape: torch.Size([512, 253, 504])
Current affine:
[[-7.0000e-01, 0.0000e+00, 0.0000e+00, 5.3887e+01],
[ 0.0000e+00, -7.0000e-01, 0.0000e+00, 2.5348e+02],
[ 0.0000e+00, 0.0000e+00, 2.0000e-01, -1.2827e+03],
[ 0.0000e+00, 0.0000e+00, 0.0000e+00, 1.0000e+00]],
However, if I use
LoadImaged(keys=[image_key],ensure_channel_first=True),
resulting affine is correct as is the size.
Image shape: torch.Size([1, 253, 253, 510])
Current affine:
[[-7.0000e-01, 0.0000e+00, 0.0000e+00, 5.3887e+01],
[ 0.0000e+00, -7.0000e-01, 0.0000e+00, 2.5348e+02],
[ 0.0000e+00, 0.0000e+00, 4.0000e-01, -1.2827e+03],
[ 0.0000e+00, 0.0000e+00, 0.0000e+00, 1.0000e+00]],
Please fix this issue, or give a warning in case the expected format of channel first is not given by the user.
Beta Was this translation helpful? Give feedback.
All reactions