changeset 2910:83133583183d

minor fixes if embedding images within DICOM
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Oct 2018 18:28:44 +0100
parents 9d277f8ad698
children 39b360e4666b
files Core/DicomFormat/DicomTag.h Core/DicomParsing/ParsedDicomFile.cpp
diffstat 2 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomTag.h	Tue Oct 30 16:16:07 2018 +0100
+++ b/Core/DicomFormat/DicomTag.h	Tue Oct 30 18:28:44 2018 +0100
@@ -175,6 +175,14 @@
   static const DicomTag DICOM_TAG_IMAGE_COMMENTS(0x0020, 0x4000);
   static const DicomTag DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION(0x0018, 0x1400);
   static const DicomTag DICOM_TAG_CONTRAST_BOLUS_AGENT(0x0018, 0x0010);
+  static const DicomTag DICOM_TAG_STUDY_ID(0x0020, 0x0010);
+  static const DicomTag DICOM_TAG_SERIES_NUMBER(0x0020, 0x0011);
+  static const DicomTag DICOM_TAG_PATIENT_SEX(0x0010, 0x0040);
+  static const DicomTag DICOM_TAG_LATERALITY(0x0020, 0x0060);
+  static const DicomTag DICOM_TAG_BODY_PART_EXAMINED(0x0018, 0x0015);
+  static const DicomTag DICOM_TAG_VIEW_POSITION(0x0018, 0x5101);
+  static const DicomTag DICOM_TAG_MANUFACTURER(0x0008, 0x0070);
+  static const DicomTag DICOM_TAG_PATIENT_ORIENTATION(0x0020, 0x0020);
 
   // Tags used within the Stone of Orthanc
   static const DicomTag DICOM_TAG_FRAME_INCREMENT_POINTER(0x0028, 0x0009);
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Tue Oct 30 16:16:07 2018 +0100
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Tue Oct 30 18:28:44 2018 +0100
@@ -1183,7 +1183,9 @@
     ReplacePlainString(DICOM_TAG_COLUMNS, boost::lexical_cast<std::string>(accessor.GetWidth()));
     ReplacePlainString(DICOM_TAG_ROWS, boost::lexical_cast<std::string>(accessor.GetHeight()));
     ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "1");
-    ReplacePlainString(DICOM_TAG_NUMBER_OF_FRAMES, "1");
+
+    // The "Number of frames" must only be present in multi-frame images
+    //ReplacePlainString(DICOM_TAG_NUMBER_OF_FRAMES, "1");
 
     if (accessor.GetFormat() == PixelFormat_SignedGrayscale16)
     {
@@ -1194,14 +1196,14 @@
       ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "0");  // Unsigned pixels
     }
 
-    ReplacePlainString(DICOM_TAG_PLANAR_CONFIGURATION, "0");  // Color channels are interleaved
-    SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2"); // by default, greyscale images are in MONOCHROME2
-
     unsigned int bytesPerPixel = 0;
 
     switch (accessor.GetFormat())
     {
       case PixelFormat_Grayscale8:
+        // By default, grayscale images are MONOCHROME2
+        SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
+
         ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8");
         ReplacePlainString(DICOM_TAG_BITS_STORED, "8");
         ReplacePlainString(DICOM_TAG_HIGH_BIT, "7");
@@ -1216,10 +1218,18 @@
         ReplacePlainString(DICOM_TAG_BITS_STORED, "8");
         ReplacePlainString(DICOM_TAG_HIGH_BIT, "7");
         bytesPerPixel = 3;
+
+        // "Planar configuration" must only present if "Samples per
+        // Pixel" is greater than 1
+        ReplacePlainString(DICOM_TAG_PLANAR_CONFIGURATION, "0");  // Color channels are interleaved
+
         break;
 
       case PixelFormat_Grayscale16:
       case PixelFormat_SignedGrayscale16:
+        // By default, grayscale images are MONOCHROME2
+        SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
+
         ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "16");
         ReplacePlainString(DICOM_TAG_BITS_STORED, "16");
         ReplacePlainString(DICOM_TAG_HIGH_BIT, "15");