Project-MONAI / Project-MONAI/MONAI
Resolve the confusion about dimension order and orientation through their respective keyword arguments in `LoadImage`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.7k
- Forks
- 1.6k
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 20
Description
Is your feature request related to a problem? Please describe.
- As a PyTorch user, I was surprised that MONAI does not follow PyTorch's dimension order convention (MONAI:
WHD, PyTorch:DHW).
PyTorch 3D Conv docs:
- I also thought that it is odd that the images are not represented in the way that a radiologist would look at them, with the patient facing up or down, instead of left or right. However, I understand that this is the convention that MONAI settled on. I will only be proposing a more transparent and flexible approach further below.
- Finally, the
reverse_indexingoption in LoadImage is misleading - I tried it withNrrdReader,NibabelReader, andITKReader, and it only worked withITKReader. At least in theory for my case (not to clutter the post, I will upload the picture in the response).
Here are a few issues/discussions describing the confusion/differences/conventions:
- https://github.com/Project-MONAI/MONAI/discussions/2189#discussioncomment-732827
- https://github.com/Project-MONAI/MONAI/discussions/2888
- https://github.com/Project-MONAI/MONAI/discussions/4872
- https://github.com/Project-MONAI/MONAI/issues/362#issuecomment-625675026
- https://github.com/Project-MONAI/MONAI/issues/4862
Describe the solution you'd like
Similarly to how LoadImage has ensure_channel_first, it would be really transparent, flexible, and a non-breaking change to have:
order/dim_order, set by default toWHDas per MONAI convention, but a user could change it toDWHor any other combination.orientation, can be set toRAS,LPS, etc. I am not sure right now if there is a consistent convention for different formats or if it varies. It could be implemented in a "non-breaking" way, similar to howLoadImage'sreaderis implemented, but it might be useful to have it consistent for all formats.- [Optional] If 1. is implemented,
reverse_indexingis probably unnecessary.
Additional context
Personally, even though I have been using MONAI for quite a while now, I always transpose the images so that: 1) they follow the PyTorch convention, 2) we see the axial slice (first dim after batch and channel dims) in the same way that a radiologist would look at it. I also orient the images LPS, but that's irrelevant rn.
The proposed approach may be particularly important for sharing models/MONAI Bundle - the dimension order or orientation used can be different between models and easily overlooked, rendering the weights almost useless if the data is not in the correct format. The proposed feature would make it more transparent as well as more easily documented by developers/sharers.
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.
Research direction
Start by tracing LoadImage and its NrrdReader, NibabelReader, and ITKReader paths, especially how reverse_indexing is handled. Define how order and orientation keyword arguments should behave consistently across formats, then verify that the resulting API preserves current defaults and makes model input conventions explicit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100