Project-MONAI / Project-MONAI/MONAI
Lazy resampling does not get the `mode` and `padding_mode` from the pending transforms properly
Open
@atbenmurray is already working on this.
Since Jan 19, 2024.
Feature request
- Dominant language
- Python
- Stars
- 8.7k
- Forks
- 1.6k
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 20
Description
Describe the bug
The lazy spatial resample records the mode and padding_mode in the extra_info field:
However, the during lazy resampling, the corresponding value is not get from the extra_info filed but directly from the operation. Well, the comment here may also indicate this issue.
To Reproduce
import torch
from monai import transforms as mt
from monai.data import MetaTensor
from monai.utils import GridSampleMode, GridSamplePadMode
def main():
trans = mt.Compose(
[
mt.Spacing((1.5, 1.5, 1.5), mode=GridSampleMode.NEAREST, padding_mode=GridSamplePadMode.ZEROS),
],
lazy=True,
)
x = MetaTensor(torch.randint(3, size=(1, 1, 16, 16, 16)))
print(x.unique())
y = trans(x)
print(y.unique())
if __name__ == '__main__':
main()
Expected behavior
Output without lazy:
tensor([0, 1, 2])
metatensor([0., 1., 2.])
Actual result
metatensor([0, 1, 2])
metatensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000, 1.2500, 1.5000, 1.7500, 2.0000])
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.