]> Creatis software - clitk.git/commitdiff
new options to auto-generate dcm series UIDs
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Fri, 21 Sep 2012 15:46:20 +0000 (17:46 +0200)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Fri, 21 Sep 2012 15:46:20 +0000 (17:46 +0200)
segmentation/clitkExtractLungFilter.txx
tools/clitkWriteDicomSeries.ggo
tools/clitkWriteDicomSeriesGenericFilter.txx

index 8dcdb5b04dffcffa4118269abee862c31742b53a..ffca1df50276062599cbcd22e76666cc25ce9a07 100644 (file)
@@ -812,7 +812,7 @@ TracheaRegionGrowing()
   f->SetUpper(GetUpperThresholdForTrachea());
   f->SetMinimumLowerThreshold(-2000);
   //  f->SetMaximumUpperThreshold(0); // MAYBE TO CHANGE ???
-  f->SetMaximumUpperThreshold(-700); // MAYBE TO CHANGE ???
+  f->SetMaximumUpperThreshold(-300); // MAYBE TO CHANGE ???
   f->SetAdaptLowerBorder(false);
   f->SetAdaptUpperBorder(true);
   f->SetMinimumSize(5000); 
index f6bccde1ad9563bda2d9a10d8a75896928d44dbb..80d4334a03fd0ce765f7eb13236fd1d22e50eb69 100644 (file)
@@ -11,4 +11,6 @@ option "inputDir"     d       "Input dicom directory"           string        yes
 option "outputDir"     o       "Output dicom directory"          string        yes 
 option "key"           k       "Keys of tags to modify"          string        no multiple default="0008|103e"
 option "tag"           t       "Tags values"                    string         no multiple default="MIDPOSITION"
-option "useSizeAsReference"            s       "Use the size of the dicom image as reference for an occasional resampling"     flag    off
\ No newline at end of file
+option "newSeriesUID"          e       "Write the series with a new series UID (ignored if given in key/tag option)"   flag    off
+option "newStudyUID"           u       "Write the series with a new study UID (ignored if given in key/tag option)"    flag    off
+option "useSizeAsReference"            s       "Use the size of the dicom image as reference for an occasional resampling"     flag    off
index 6f09ba9ea4fb48aef5b3b673b49c955a0dbfac40..225aae586e6ccef8bb7eabb0d0dff72053c1af14 100644 (file)
 
 // clitk
 #include "clitkResampleImageWithOptionsFilter.h"
+#if GDCM_MAJOR_VERSION >= 2
+#include "gdcmUIDGenerator.h"
+#else
+#include "gdcmFile.h"
+#include "gdcmUtil.h"
+#endif
 
 
 namespace clitk
@@ -236,12 +242,66 @@ WriteDicomSeriesGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
   // Get keys
   unsigned int numberOfKeysGiven=m_ArgsInfo.key_given;
 
-  for (unsigned int i = 0; i < numberOfKeysGiven; i++) {
-    std::string entryId(m_ArgsInfo.key_arg[i]  );
-    std::string value( m_ArgsInfo.tag_arg[i] );
-    std::cout << entryId << " " << value << std::endl;
-    for(unsigned int fni = 0; fni<numberOfFilenames; fni++)
+  std::string seriesUID;
+  std::string frameOfReferenceUID;
+  if (m_ArgsInfo.newSeriesUID_flag) {
+#if GDCM_MAJOR_VERSION >= 2
+    gdcm::UIDGenerator suid;
+    seriesUID = suid.Generate();
+    gdcm::UIDGenerator fuid;
+    frameOfReferenceUID = fuid.Generate();
+#else
+    seriesUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());
+    frameOfReferenceUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());
+#endif
+    if (m_ArgsInfo.verbose_flag)
+    {
+      DD(seriesUID);
+      DD(frameOfReferenceUID);
+    }
+  }
+  
+
+  std::string studyUID;
+  if (m_ArgsInfo.newStudyUID_flag) {
+#if GDCM_MAJOR_VERSION >= 2
+    gdcm::UIDGenerator suid;
+    studyUID = suid.Generate();
+#else
+    studyUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());
+#endif
+    if (m_ArgsInfo.verbose_flag)
+      DD(studyUID);
+  }
+  
+  std::string seriesUIDkey = "0020|000e";
+  std::string frameOfReferenceUIDKey = "0020|0052";
+  std::string studyUIDKey = "0020|000d";
+  for(unsigned int fni = 0; fni<numberOfFilenames; fni++) {
+    bool series_id_given = false;
+    bool study_id_given = false;
+    for (unsigned int i = 0; i < numberOfKeysGiven; i++) {
+      std::string entryId(m_ArgsInfo.key_arg[i]  );
+      std::string value( m_ArgsInfo.tag_arg[i] );
+
       itk::EncapsulateMetaData<std::string>( *((*dictionary)[fni]), entryId, value );
+      if (entryId ==  seriesUIDkey || entryId ==  frameOfReferenceUIDKey)
+        series_id_given = true;
+      if (entryId == studyUIDKey)
+        study_id_given = true;
+    }
+    
+    if (!series_id_given) {
+      if (m_ArgsInfo.newSeriesUID_flag) {
+        itk::EncapsulateMetaData<std::string>( *((*dictionary)[fni]), seriesUIDkey, seriesUID );
+        itk::EncapsulateMetaData<std::string>( *((*dictionary)[fni]), frameOfReferenceUIDKey, frameOfReferenceUID );
+      }
+    }
+    
+    if (!study_id_given) {
+      if (m_ArgsInfo.newStudyUID_flag) 
+        itk::EncapsulateMetaData<std::string>( *((*dictionary)[fni]), studyUIDKey, studyUID );
+    }
   }