You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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),
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.
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.
The text was updated successfully, but these errors were encountered: