From 903894bc877ec15afe5a0ba0d70fa490f2fa57ef Mon Sep 17 00:00:00 2001 From: tbaudier Date: Tue, 12 Mar 2019 17:22:55 +0100 Subject: [PATCH] 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 --- tools/clitkImage2Dicom.ggo | 1 + tools/clitkImage2DicomGenericFilter.txx | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) 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::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(*inputDict, "0020|000e", seriesUID); + } std::string studyUID; std::string sopClassUID; itk::ExposeMetaData(*inputDict, "0020|000d", studyUID); -- 2.47.1