Page MenuHomePhabricator

Loading and writing of .mhd files leads to a different transform matrix
Closed, WontfixPublic

Description

Hi there,

I am currently facing a problem while writing segmentations as .mhd files. I am using a Subversion version of MITK (Revision 29842; the latest in the old Subversion Repository) together with ITK 3.20.0. When I am loading an .mhd dataset with the following header information:

ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 1 0 0 0 1 0 0 0 1
Offset = 31.395 21.252 16.65
CenterOfRotation = 0 0 0
AnatomicalOrientation = RAI
ElementSpacing = 0.483 0.483 0.49
DimSize = 223 211 122
ElementType = MET_UCHAR
ElementDataFile = MyFilename.raw

And save it again as a .mhd file, I am getting the following header
information:

ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 107.709 0 0 0 101.913 0 0 0 59.78 Offset = 31.395 21.252 16.65 CenterOfRotation = 0 0 0 AnatomicalOrientation = RAI ElementSpacing = 0.483 0.483 0.49 DimSize = 223 211 122 ElementType = MET_FLOAT ElementDataFile = MyFilename2.raw

Please note the difference in the TransformMatrix line. For some reason the writing with my current MITK QT4 version adds some rotation which is not in the data. The old QT3 version did not do that.

From my testing, I can say that:

  • writing the .mhd file adds this arbitrary transformation
  • this transformation is not visible in the "details" view in the Datamanager (there, only the scaling values are visible)
  • this transformation is not being read or used by both the old QT3 and the new QT4 MITK version when loading the newly written dataset (both, the new and the original one are at the same location and orientation)

I am guessing that this is error is either related to MITK (handing some transformation to the .mhd file writer which is not actually present) or to ITK who are now writing transformations to the .mhd files which they didn't in version 3.16.0 that I have used with MITK QT3 before. Anyway MITK should cause the file writer to write the identity matrix in my case.

Could you please try to reproduce this error with your current MITK version?

Thank you very much,
Matthias

Dipl.-Ing. Matthias Keil

Event Timeline

We doublechecked the issue. We used the brain.mhd file provided in the test data repository in MITK (..\BINARY\MITK-build\CMakeExternals\Source\MITK-Data) with the following header imformation:

ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = -1 1.21604e-008 -3.34104e-008 0 0.939693 0.34202 1.44667e-008 -0.34202 0.939693
Offset = 89 -49.3027 -113.792
CenterOfRotation = 0 0 0
AnatomicalOrientation = LAI
ElementSpacing = 2 2 2
DimSize = 91 109 91
ElementType = MET_FLOAT
ElementDataFile = brain.raw

to reproduce the bug we set the transformation matrix manually back to identity and the scaling to (1,1,1) what lead us to the following header information:

ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 1 0 0 0 1 0 0 0 1
Offset = 89 -49.3027 -113.792
CenterOfRotation = 0 0 0
AnatomicalOrientation = LAI
ElementSpacing = 1 1 1
DimSize = 91 109 91
ElementType = MET_FLOAT
ElementDataFile = brain.raw

We loaded and restored the image using the MITK ExtApp of the latest checkout (git commit:4c56916bb77cfa1f42aaa44d2dcbb0a6e501dc77).

The header information of the saved file is as the loaded one:

ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 1 0 0 0 1 0 0 0 1
Offset = 89 -49.3027 -113.792
CenterOfRotation = 0 0 0
AnatomicalOrientation = RAI
ElementSpacing = 1 1 1
DimSize = 91 109 91
ElementType = MET_FLOAT
ElementDataFile = brain3.raw

With the accessible image the bug could not be reproduced. My suggestion is to update MITK to the lastest revision using the new git repository.
In order to see if the bug might be a result from the used image, could you please provide us with the image you used to produce the bug? Please add the image as an attachment to this bug.

kislinsk added a project: Bulk Edit.
kislinsk removed a project: Bulk Edit.