ITK: Anatomical orientation in MetaImages ignored in ITK
Description
AnatomicalOrientation tag in MetaImages is ignored. LPS is always assumed.
Steps to Reproduce
Have a .mha image with AnatomicalOrientation tag. Change the orientation e.g. from RAS to RAI. The image should be flipped after this change, but it isn’t.
Additional Information
Direction cosines are read, but AnatomicalOrientation is not read, it is always assumed to be LPS.
What should be done: read AnatomicalOrientation, and if it is different from LPS apply an appropriate correction matrix to direction cosines.
Submitted by: @agirault.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 31 (25 by maintainers)
I think an important message from @issakomi is to not break backward compatibility. I think that we should be able to maintain backward compatibility in this case (functionality and API), and it is something we should test heavily.
@issakomi - if I misunderstood your message, please let me know. I greatly appreciate the help that you have already given. Hopefully the end result will be to your liking (e.g., not require changes to your code) and perhaps make moving data between ITK and other applications (e.g., Slicer) more clear/defined/easy.
Thanks!
On Mon, Jun 17, 2019 at 11:54 AM issakomi notifications@github.com wrote:
–
Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives, Kitware, Inc., North Carolina
Kitware: Advancing the frontiers of understanding by developing innovative open-source software platforms and integrating them into research, processes, and products.
Please don’t do this. I don’t want to fight with robots.
Adding a “stale” label is fine. It is also OK to assign it to a “backlog”. However, closing an issue would make it seem that the issue has been fixed or it was not valid in the first place, which is often not true.
I understand the desire to have less open issues, but automatically sweeping them under the rug will not improve quality and discourage community members to spend time with reporting issues.
The only valid use case I see for a stale-bot is to automatically close issues that are labelled as “more-information-needed”. If more information is needed from the reporter but response does not arrive within reasonable time then it makes sense to close the issue (and doing it automatically saves some time for the maintainers).
Agreed. If you need to handle the corner cases, NRRD is the way to go. I like keeping MetaIO simpler and more straightforward.
Thanks for the help with it. If you have ideas for clarifying the descriptions, please post them. Otherwise, I will close this issue in a few days.
Thanks, Stephen
On Mon, Dec 23, 2019 at 1:35 PM Andras Lasso notifications@github.com wrote:
– Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives
Back on topic…I’ve updated the MetaIO documentation, and hopefully it captures this discussion and provides a path forward…
See https://itk.org/Wiki/ITK/MetaIO/Documentation#Tags_Added_by_MetaImage
Also copied below…
AnatomicalOrientation
Hi,
This is perhaps clearer regarding how things are defined now…
AnatomicalOrientation
Andras makes a valid point. Maybe we could change the bot’s settings? @hjmjohnson @thewtex @blowekamp
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Very interesting to see this issue coming up again. I’ve raised this question 7 years ago and the conclusion at that time was that ITK’s implementation was correct and if the documentation was not consistent then it was because it was not interpreted correctly (see details here).
Current AnatomicalOrientation tag is messed up because axis names are inverted (compared to DICOM, nrrd, … and pretty much everything else) and the tag was present but has been ignored for really long time.
One safe option would be to adopt “space” tag from nrrd.
Another safe (and long-term time-saving) option would be to deprecate metaimage format. Nrrd file format was developed for exactly the same purpose as metaimage, but nrrd has advantages, such as having a clear definition of anatomical orientation/space tag (consistent with documentation), it has standard fields for describing axis kinds (very important for higher-dimensional images), and does not contain complicated and rarely-used features (such as multiple data files for a single header). If the decision is made to keep maintaining/improving metaimage format then it would be important to clean up and improve the specification (to be essentially even more similar to nrrd).
in my apps i heavily use itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_… enum and compatibility of ITK and DICOM space, it is great advantage. I don’t understand what is your goal? Rename RAI to LPS? There is no standard for that and i’ve never seen 48 orientation codes like in ITK, here and there is wording “DICOM LPS” (not defined in DICOM) and “Slicer RAS”, nothing else. I also don’t understand what is wrong with direction cosines in MetaImage and why should any additional transforms be applied? I will be not able to update to newer version of ITK, sorry, i have no time to re-write applications, i better stay with the old version of ITK and will back-port critical bugs… Also i have no time to participate in discussions, for me it is too clear. You are from Kitware, it is your playground, but i leave the discussion. Good luck.
There are two issues being discussed here:
For this issue, further discussions can be made to better describe this, as ITK/MetaIO is the only one using the “from” definition, and is prone to a lot of confusion as the last couple comments can confirm. And that’s not new.
We’ll draft a well-documented post explaining the ins-and-outs of the issue, suggest a versioning update of the MetaIO format to restore this initial feature while maintaining backward-compatibility with how MetaIO has been used for the last 14 years, then share it in the ITK discourse forum to get feedback from the community.
I agree that the definition is poorly worded.
The direction cosine matrix exists in a space. That space is defined by the AnatomicOrientation. That is, when moving in the physical x-direction (or in i-index direction with an identity direction matrix), then you are going toward L when in an LPS anatomic space. Changing the direction matrix will never change the fact that you’re in an LPS space, but it will change how moving along the i-index direction maps to a movement in that space. It tells you that the first i-index pixel you access in memory is to the right of the second pixel.
The code cited by @issakomi seems to only consider direction cosines, then it is perhaps describing how the ijk-index spans (i.e., is oriented within) a specific (e.g., ILS) space. This is different than telling us how that larger space is oriented (e.g., if it is ILS).
On Fri, Jun 14, 2019 at 3:18 PM issakomi notifications@github.com wrote:
–
Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives, Kitware, Inc., North Carolina
Kitware: Advancing the frontiers of understanding by developing innovative open-source software platforms and integrating them into research, processes, and products.
But does this refer to
ijkorXYZorigin and vectors? If it refers toijk(index space), then direction matrix is redundant. If it refers toXYZ(physical space), then another (possible) flip is required to reconcile this with ITK convention that identity matrix corresponds to LPS.Also: