-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resample operations should fail when no channels #6809
Comments
@wyli if no one is working on it, Can you please assign the issue to me. I will take a look at it and suggest changes. My suggestion would be to not raise an |
@wyli The trouble mostly comes from MONAI/monai/transforms/spatial/array.py Line 489 in 6f5cea3
Which according to MONAI/monai/data/meta_tensor.py Line 479 in 6f5cea3
As the changes to MetaTensor objects have far wider implications maybe that should be a different issue that needs to be solved before this. |
Sure, I think the main ask of this ticket is to improve the input validation -- when pixdim is configured to have 3 elements and at the same time the input image is not in the format channel-first spatially 3d, the user would get some warning or error msgs. (The affine is in 4x4 so that we can potentially track 2d spatial slices/projections from 3d volumes) |
Got you! Added a userwarning whenever truncation of the affine matrix happens so that it may be an indication of missing channel first inputs. |
@KumoLiu and @a-parida12 is it completed. ? |
Describe the bug
resample operations like
ResampleToMatch
or 'Spacing` (probably all that use same underlying mechanism) behave wrong when passed data has no channels.To Reproduce
Steps to reproduce the behavior:
Run this piece of code:
Expected behavior
Spatial Transformations should lean towards detecting inconsistencies and throw an exception when number of spatial_dims doesn't match.
In this case - image is 3D, it's affine matrix is 4x4, and passed
pixdim
has 3 entries. SinceSpacing
requires explicit channels dimensions - it should raise an exception, since affine and pixdim suggest the image is 3D, while tensor isn't CWHD.Similar thing happens with
ResampleToMatch
where resampling is continued for a 3D volume without channels, but produces wrong results.I think this is a better way as we do not hide a potential issue in user's code and forcing the user to find out why resampling isn't working well.
Environment
The text was updated successfully, but these errors were encountered: