]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOImageReader.cpp
*** empty log message ***
[creaImageIO.git] / src2 / creaImageIOImageReader.cpp
index 63a87ce515b6db8261a0391a22a59e37aa7e95e3..aa8012bc7228abf5c435387a21e13c85760ff72d 100644 (file)
@@ -1,6 +1,6 @@
 #include <creaImageIOImageReader.h>
 #include <creaImageIOTreeAttributeDescriptor.h>
-
+#include <creaImageIOSystem.h>
 
 #include <vtkImageReader2.h>
 #include <vtkPNGReader.h>
@@ -25,7 +25,7 @@ namespace creaImageIO
   {
     if (str == "GDCM::Unfound") 
       {
-       return "----";
+       return "";
       }
     if (str[str.size()-1]==' ')
       {
@@ -157,6 +157,7 @@ namespace creaImageIO
                        std::map<std::string,std::string>& attr)
     {
       //      std::cout << "SpecificVtkReader::ReadDicomInfo '"<<filename<<"'"<<std::endl;
+      GimmickMessage(2,"Reading attributes from '"<<filename<<std::endl);
       // Get image dimensions
       // How to get the image info without loading it in vtk ?
       mVTKReader->SetFileName(filename.c_str());
@@ -173,26 +174,36 @@ namespace creaImageIO
       char planes[128];
       sprintf(planes,"%i",ext[5]-ext[4]);
       
+
       // 
       std::map<std::string,std::string>::iterator i;
-      if ( (i = attr.find("Full File Name")) != attr.end())
+      if ( (i = attr.find("FullFileName")) != attr.end())
+       {
+         //      boost::filesystem::path full_path(filename);
+         // std::string f = full_path.leaf();
+         i->second = filename;
+       }
+      if ( (i = attr.find("D0004_1500")) != attr.end())
        {
          boost::filesystem::path full_path(filename);
          std::string f = full_path.leaf();
          i->second = f;
        }
-      if ( (i = attr.find("Columns")) != attr.end())
-       {
-         i->second = cols;
-       }
-      if ( (i = attr.find("Rows")) != attr.end())
+       if ( (i = attr.find("D0028_0010")) != attr.end())
        {
          i->second = rows;
        }
-      if ( (i = attr.find("Planes")) != attr.end())
-       {
+       if ( (i = attr.find("D0028_0011")) != attr.end())
+        {
+          i->second = cols;
+        }
+       
+       if ( (i = attr.find("D0028_0012")) != attr.end())
+        {
          i->second = planes;
        }
+
+       GimmickMessage(2,"Attributes map:"<<std::endl<<attr<<std::endl);
     }
     //=====================================================================
   private:
@@ -307,6 +318,9 @@ namespace creaImageIO
                        std::map<std::string,std::string>& attr)
     {
       //    std::cout << "DicomReader::ReadDicomInfo '"<<filename<<"'"<<std::endl;
+      GimmickMessage(2,"Reading attributes from DICOM file '"
+                    <<filename<<"'"<<std::endl);
+
       GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
       file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
       file->SetFileName(filename.c_str());
@@ -317,21 +331,29 @@ namespace creaImageIO
          std::map<std::string,std::string>::iterator i;
          for (i=attr.begin();i!=attr.end();++i)
            {
-             if ( i->first == "FullFileName" )
+             if ( i->first == "D0004_1500" )
                {
                  boost::filesystem::path full_path(filename);
                  std::string f = full_path.leaf();
                  i->second = f;
                }
+             else if ( i->first == "FullFileName" )
+               {
+                 i->second = filename;
+               }
              else
                {
                  uint16_t gr;
                  uint16_t el;
                  tree::AttributeDescriptor::GetDicomGroupElementFromKey(i->first,gr,el);
+                 //              GimmickMessage(2,"Key '"<<i->first<<"' : "<<gr<<"|"<<el
+                 //                             <<std::endl);
                  if ( ( gr!=0 ) && ( el!=0 ) )
                    {
                      std::string val = file->GetEntryString(gr,el);
                      i->second = irclean(val);
+                     //                      GimmickMessage(2,"Key '"<<i->first<<"' : "<<gr<<"|"<<el
+                     //                                     <<"="<<i->second<<std::endl);
                    }
                }
            }