X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=tools%2FclitkWriteDicomSeriesGenericFilter.txx;fp=tools%2FclitkWriteDicomSeriesGenericFilter.txx;h=225aae586e6ccef8bb7eabb0d0dff72053c1af14;hb=5ce3eec189c720473972869df4dd44d91fd52bc4;hp=6f09ba9ea4fb48aef5b3b673b49c955a0dbfac40;hpb=6eef454976366ce9cb242a2047fc8ec5217b7764;p=clitk.git diff --git a/tools/clitkWriteDicomSeriesGenericFilter.txx b/tools/clitkWriteDicomSeriesGenericFilter.txx index 6f09ba9..225aae5 100644 --- a/tools/clitkWriteDicomSeriesGenericFilter.txx +++ b/tools/clitkWriteDicomSeriesGenericFilter.txx @@ -29,6 +29,12 @@ // 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::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= 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( *((*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( *((*dictionary)[fni]), seriesUIDkey, seriesUID ); + itk::EncapsulateMetaData( *((*dictionary)[fni]), frameOfReferenceUIDKey, frameOfReferenceUID ); + } + } + + if (!study_id_given) { + if (m_ArgsInfo.newStudyUID_flag) + itk::EncapsulateMetaData( *((*dictionary)[fni]), studyUIDKey, studyUID ); + } }