Skip to content

NiftiImageIO: Round Trip issue with Image Orientation (Patient) #1042

@malaterre

Description

@malaterre

Description

Placeholder for possibly a longer bug report. But at least store the information for reproducing the issue.

Steps to Reproduce

So basically the steps are:

  1. cp gdcm/Testing/Data/*SIEM*FileSeq* /tmp/dir/
  2. gdcmanon --dumb --replace 0020,0037="0.9997586873\0.02191020543\0.001584328775\0.02196741222\-0.9971551496\-0.0721043717" /tmp/dir /tmp/dir2
  3. bin/DicomSeriesReadImageWrite2 /tmp/dir2 foo.nii
  4. bin/ImageReadWrite foo.nii nii.dcm

Expected behavior

Minimal approximation of the matrix orientation in between the different representations.

$ gdcmdump nii.dcm | grep Orie
        (0020,0037) ?? (DS) [.999758687284262\.021910205429893\.001584328774992\.021967412220091\-.99715514960414\-.07210437170029 ]         # 102,6 Image Orientation (Patient)

This goal is achievable since the MetaImage seems to be giving proper results:

  1. bin/DicomSeriesReadImageWrite2 /tmp/dir2 foo.mha
  2. bin/ImageReadWrite foo.mha mha.dcm

Leads to:

$ gdcmdump mha.dcm | grep Orie
        (0020,0037) ?? (DS) [.999758687284262\.021910205429893\.001584328774992\.021967412220091\-.99715514960414\-.07210437170029 ]         # 102,6 Image Orientation (Patient)

Actual behavior

Leads to:

$ gdcmdump nii.dcm | grep Orie
        (0020,0037) ?? (DS) [.9997590014762\.021938811333211\7.921645009e-4\.021938811254904\-.99715514907211\-.07211308646627 ]         # 98,6 Image Orientation (Patient)

Reproducibility

Versions

$ git rev-parse --short=12 HEAD
b089be7fdd16

Environment

Linux, but I am guessing this will be irrelevant.

Additional Information

$ git diff
diff --git a/Examples/IO/DicomSeriesReadImageWrite2.cxx b/Examples/IO/DicomSeriesReadImageWrite2.cxx
index be15736..d435c10 100644
--- a/Examples/IO/DicomSeriesReadImageWrite2.cxx
+++ b/Examples/IO/DicomSeriesReadImageWrite2.cxx
@@ -74,7 +74,7 @@ int main( int argc, char* argv[] )
 // Software Guide : EndLatex
 
 // Software Guide : BeginCodeSnippet
-  using PixelType = signed short;
+  using PixelType = unsigned short;
   constexpr unsigned int Dimension = 3;
 
   using ImageType = itk::Image< PixelType, Dimension >;
diff --git a/Examples/IO/ImageReadWrite.cxx b/Examples/IO/ImageReadWrite.cxx
index 0ccc48a..1eb8e71 100644
--- a/Examples/IO/ImageReadWrite.cxx
+++ b/Examples/IO/ImageReadWrite.cxx
@@ -85,8 +85,8 @@ int main( int argc, char ** argv )
   //  Software Guide : EndLatex
 
   // Software Guide : BeginCodeSnippet
-  using PixelType = short;
-  constexpr unsigned int Dimension = 2;
+  using PixelType = unsigned short;
+  constexpr unsigned int Dimension = 3;
   using ImageType = itk::Image< PixelType, Dimension >;
   // Software Guide : EndCodeSnippet
 

Metadata

Metadata

Assignees

Labels

area:IOIssues affecting the IO modulestatus:Use_Milestone_BacklogUse "Backlog" milestone instead of label for issues without a fixed deadlinetype:BugInconsistencies or issues which will cause an incorrect result under some or all circumstances

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions