From 3acd1100ef8164c3b7b9d783c065e0b333ab1eb4 Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Thu, 27 Sep 2012 16:10:23 +0200 Subject: [PATCH] newStudyUID forces newSeriesUID - also some bug corrections... --- tools/clitkWriteDicomSeries.ggo | 2 +- tools/clitkWriteDicomSeriesGenericFilter.txx | 48 ++++++++++---------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/tools/clitkWriteDicomSeries.ggo b/tools/clitkWriteDicomSeries.ggo index 80d4334..faa08cb 100644 --- a/tools/clitkWriteDicomSeries.ggo +++ b/tools/clitkWriteDicomSeries.ggo @@ -12,5 +12,5 @@ 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 "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 "newStudyUID" u "Write the series with a new study UID (ignored if given in key/tag option; forces newSeriesUID = true)" flag off option "useSizeAsReference" s "Use the size of the dicom image as reference for an occasional resampling" flag off diff --git a/tools/clitkWriteDicomSeriesGenericFilter.txx b/tools/clitkWriteDicomSeriesGenericFilter.txx index 32c52e8..d143474 100644 --- a/tools/clitkWriteDicomSeriesGenericFilter.txx +++ b/tools/clitkWriteDicomSeriesGenericFilter.txx @@ -139,7 +139,7 @@ WriteDicomSeriesGenericFilter::UpdateWithDimAndPixelType() namesGenerator->SetInputDirectory( m_ArgsInfo.inputDir_arg ); namesGenerator->SetOutputDirectory( m_ArgsInfo.outputDir_arg ); typename ReaderType::FileNamesContainer filenames_in = namesGenerator->GetInputFileNames(); - typename ReaderType::FileNamesContainer filenames_out = namesGenerator->GetOutputFileNames(); + typename ReaderType::FileNamesContainer filenames_out; // Output the dicom files unsigned int numberOfFilenames = filenames_in.size(); @@ -241,6 +241,8 @@ WriteDicomSeriesGenericFilter::UpdateWithDimAndPixelType() // Get keys unsigned int numberOfKeysGiven=m_ArgsInfo.key_given; + if (m_ArgsInfo.verbose_flag) + DD(numberOfKeysGiven); std::string seriesUID; std::string frameOfReferenceUID; @@ -254,38 +256,34 @@ WriteDicomSeriesGenericFilter::UpdateWithDimAndPixelType() bool studyUIDGiven = false; for (unsigned int i = 0; i < numberOfKeysGiven; i++) { std::string entryId( m_ArgsInfo.key_arg[i] ); + if (m_ArgsInfo.verbose_flag) + DD(entryId); seriesUIDGiven = (entryId == seriesUIDkey || entryId == frameOfReferenceUIDKey); - if (seriesUIDGiven) - { - if (entryId == seriesUIDkey) - seriesUID = m_ArgsInfo.tag_arg[i]; - else - frameOfReferenceUID = m_ArgsInfo.tag_arg[i]; - } - else if (m_ArgsInfo.newSeriesUID_flag) { + studyUIDGiven = (entryId == studyUIDKey); + } + + // force the creation of a new series if a new study was specified + if (!studyUIDGiven && m_ArgsInfo.newStudyUID_flag) { + m_ArgsInfo.newSeriesUID_flag = true; #if GDCM_MAJOR_VERSION >= 2 - gdcm::UIDGenerator suid; - seriesUID = suid.Generate(); - gdcm::UIDGenerator fuid; - frameOfReferenceUID = fuid.Generate(); + gdcm::UIDGenerator suid; + studyUID = suid.Generate(); #else - seriesUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix()); - frameOfReferenceUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix()); + studyUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix()); #endif - } - - studyUIDGiven = (entryId == studyUIDKey); - if (studyUIDGiven) - studyUID = m_ArgsInfo.tag_arg[i]; - else if (m_ArgsInfo.newStudyUID_flag) { + } + + if (!seriesUIDGiven && m_ArgsInfo.newSeriesUID_flag) { #if GDCM_MAJOR_VERSION >= 2 - gdcm::UIDGenerator suid; - studyUID = suid.Generate(); + gdcm::UIDGenerator suid; + seriesUID = suid.Generate(); + gdcm::UIDGenerator fuid; + frameOfReferenceUID = fuid.Generate(); #else - studyUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix()); + seriesUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix()); + frameOfReferenceUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix()); #endif - } } if (m_ArgsInfo.verbose_flag) { -- 2.47.1