]> Creatis software - clitk.git/commitdiff
Add option to display series and filename
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 1 Jul 2013 07:00:35 +0000 (09:00 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 1 Jul 2013 07:00:35 +0000 (09:00 +0200)
tools/clitkDicomInfo.cxx
tools/clitkDicomInfo.ggo

index fe2d869d8bbf2e756068ae0b488c30dc45641583..202afc762feab842659b4421915b6faf74a4e275 100644 (file)
 // 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<std::string> l;
+    for(unsigned int i=0; i<args_info.inputs_num; i++) {
+      gdcm::Reader reader;
+      reader.SetFileName(args_info.inputs[i]);
+      std::set<gdcm::Tag> 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<std::string, std::string> p = sf.ToStringPair(StudyInstanceUIDTag);
+        std::pair<std::string, std::string> 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<args_info.inputs_num; i++) {
+    if (args_info.filename_flag) std::cout << args_info.inputs[i] << std::endl;
 #if GDCM_MAJOR_VERSION == 2
     gdcm::Reader reader;
     reader.SetFileName(args_info.inputs[i]);
index 27786a47ff23be29fa932db58789fd4046eacab9..064fa29ca67ede1aaa9a450dd9e35fd6ce0fdb41 100644 (file)
@@ -3,3 +3,6 @@ package "clitk"
 version "read and print Dicom header"
 
 option "config"                 -      "Config file"            string         no
+option "studyID"        s      "Only display Study UID" flag           off
+option "uniq"           u      "Do not display if same study UID"      flag           off
+option "filename"       f      "Display filename"       flag           off