From: tbaudier <thomas.baudier@creatis.insa-lyon.fr>
Date: Tue, 12 Mar 2019 16:22:55 +0000 (+0100)
Subject: Add preserve studyUID in clitkImage2Dicom
X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=903894bc877ec15afe5a0ba0d70fa490f2fa57ef;p=clitk.git

Add preserve studyUID in clitkImage2Dicom

Before the script automatically change the serie UID but it's preferable to not change it
Adding the flag to change it
---

diff --git a/tools/clitkImage2Dicom.ggo b/tools/clitkImage2Dicom.ggo
index 47ee878..3c3022a 100644
--- a/tools/clitkImage2Dicom.ggo
+++ b/tools/clitkImage2Dicom.ggo
@@ -10,4 +10,5 @@ option "input"      i "Input image filename"    string  no
 option "inputDcm"   d "Input dicom filename"    string  no
 option "outputDcm"  o "Output dicom folder"     string  no
 option "nameDicom"  n "Output dicom filename"   string  no
+option "newUID"     u "Write output with new UID" flag  off
 
diff --git a/tools/clitkImage2DicomGenericFilter.txx b/tools/clitkImage2DicomGenericFilter.txx
index da30589..37fa8a5 100644
--- a/tools/clitkImage2DicomGenericFilter.txx
+++ b/tools/clitkImage2DicomGenericFilter.txx
@@ -216,14 +216,22 @@ Image2DicomGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
   // to keep the same study UID. But we need new series and frame of
   // reference UID's.
 #if ITK_VERSION_MAJOR >= 4
-  gdcm::UIDGenerator suid;
-  std::string seriesUID = suid.Generate();
   gdcm::UIDGenerator fuid;
   std::string frameOfReferenceUID = fuid.Generate();
 #else
-  std::string seriesUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());
   std::string frameOfReferenceUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());
 #endif
+  std::string seriesUID;
+  if (m_ArgsInfo.newUID_flag) {
+#if ITK_VERSION_MAJOR >= 4
+    gdcm::UIDGenerator suid;
+    seriesUID = suid.Generate();
+#else
+    seriesUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());
+#endif
+  } else {
+    itk::ExposeMetaData<std::string>(*inputDict, "0020|000e", seriesUID);
+  }
   std::string studyUID;
   std::string sopClassUID;
   itk::ExposeMetaData<std::string>(*inputDict, "0020|000d", studyUID);