MHA/MHD orientation convention combined with rotation/translation
About you
CamiTK developer
Overview
This issue is a follow-up of issue #66 (closed) When loading and writing MHA/MHD files, geometrical transformations are applied in this order:
- transform to RAI convention
- rotation
- translation
Unfortunately it means that we apply the rotation and translation specified in the header after changing the convention to RAI (CamiTK convention). But those rotation and translation were probably defined in the convention specified in the header file (e.g. RSA). In that case it means we apply the rotation and translation to the wrong axes.
Steps to Reproduce
Need sample files in conventions other than RAI to be able to test this. Finding out which software (3D Slicer ?) uses a different convention to compare how the transform is read/saved in another convention would be useful.
Actual VS Expected Result
- The transform matrix loaded in a RSA file is saved in an RAI file with the exact same values, even though the axes are not the same
- Loading an image in RSA convention with a translation of (0,1,2) should be saved in RAI with a different translation (1 for axis S-I, 2 for axis A-P)
Interpretation & Possible fixes
MHA/MHD MetaImage file format specs are not very precise on this issue. But I believe that rotation and translation are defined according to the specified orientation convention, and not an arbitrary one (RAI for CamiTK).
A thread from 3D slicer about how ITK does not use this information correctly and how VTK should manage the issue:
It refers to a merge request to solve it in VTK that was not merged because it breaks a lot of tests, but the discussion is interesting. In ITK, it was decided to ignore cases where ITK reader fails because they focus on other image formats.
After reading this we should take our own decision in how to interact with this format. I suggest:
- read the orientation
- consider the image is encoded in that orientation
- consider the matrix is expressed in the specified orientation and use it accordingly For the write part, multiple choices:
- we save in any orientation we want (e.g. RAI, current way), specify it in the header, and write the matrix accordingly. The most logical way !
- we save in LPS (used by ITK and other software for MetaImage format), increasing compatibility with other software. We specify the orientation and the matrix in LPS. This would be ok but, there is a problem: it seems that most software just ignore orientation when they read, but use the matrix in their own orientation without adapting it (e.g. 3D Slicer loads the image as LPS, converts to RAS, and considers the matrix as being in RAS...)
CamiTK Version
CamiTK 5.1.dev.develop.c3d59664
please do not remove anything below this line