From f257fe5c67c61795b1ab7ea8131fa2289dceeca3 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Mon, 1 Jul 2013 09:00:35 +0200 Subject: [PATCH] Add option to display series and filename --- tools/clitkDicomInfo.cxx | 44 ++++++++++++++++++++++++++++++++++++++-- tools/clitkDicomInfo.ggo | 3 +++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tools/clitkDicomInfo.cxx b/tools/clitkDicomInfo.cxx index fe2d869..202afc7 100644 --- a/tools/clitkDicomInfo.cxx +++ b/tools/clitkDicomInfo.cxx @@ -29,8 +29,10 @@ // itk (gdcm) include #include "gdcmFile.h" #if GDCM_MAJOR_VERSION == 2 - #include "gdcmReader.h" - #include "gdcmPrinter.h" +#include "gdcmReader.h" +#include "gdcmPrinter.h" +#include "gdcmDict.h" +#include "gdcmStringFilter.h" #endif //-------------------------------------------------------------------- @@ -43,8 +45,46 @@ int main(int argc, char * argv[]) // check arg if (args_info.inputs_num == 0) return 0; + // Study ID + #if GDCM_MAJOR_VERSION == 2 + if (args_info.studyID_flag) { + std::set l; + for(unsigned int i=0; i tags; + gdcm::Tag StudyInstanceUIDTag(0x0020, 0x000d); + gdcm::Tag SeriesDateTag(0x0008, 0x0021); + tags.insert(StudyInstanceUIDTag); + tags.insert(SeriesDateTag); + if (reader.ReadSelectedTags(tags)) { + gdcm::StringFilter sf; + sf.SetFile(reader.GetFile()); + std::pair p = sf.ToStringPair(StudyInstanceUIDTag); + std::pair d = sf.ToStringPair(SeriesDateTag); + if (args_info.uniq_flag) { + if (l.insert(p.second).second == true) { + if (args_info.filename_flag) + std::cout << args_info.inputs[i] << " " << p.second << " " << d.second << std::endl; + else + std::cout << p.second << std::endl; + } + } + else { + if (args_info.filename_flag) + std::cout << args_info.inputs[i] << " " << p.second << " " << d.second << std::endl; + else + std::cout << p.second << std::endl; + } + } // tag not found + } + } +#endif + // Loop files + if (!args_info.studyID_flag) for(unsigned int i=0; i