]> Creatis software - creaImageIO.git/commitdiff
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/creaImageIO
authorClaire Mouton <claire.mouton@creatis.insa-lyon.fr>
Thu, 13 Mar 2014 15:24:57 +0000 (16:24 +0100)
committerClaire Mouton <claire.mouton@creatis.insa-lyon.fr>
Thu, 13 Mar 2014 15:24:57 +0000 (16:24 +0100)
bbtk/src/bbcreaImageIOGetDicomAttributesFromMaps.cxx [new file with mode: 0644]
bbtk/src/bbcreaImageIOGetDicomAttributesFromMaps.h [new file with mode: 0644]
bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml
src/creaImageIOVtkImageReader.cpp
src/creaImageIOWxSimpleDlg.cpp
src/creaImageIOWxSimpleDlg.h

diff --git a/bbtk/src/bbcreaImageIOGetDicomAttributesFromMaps.cxx b/bbtk/src/bbcreaImageIOGetDicomAttributesFromMaps.cxx
new file mode 100644 (file)
index 0000000..bd45183
--- /dev/null
@@ -0,0 +1,84 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#include "bbcreaImageIOGetDicomAttributesFromMaps.h"
+#include "bbcreaImageIOPackage.h"
+namespace bbcreaImageIO
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaImageIO,GetDicomAttributesFromMaps)
+BBTK_BLACK_BOX_IMPLEMENTATION(GetDicomAttributesFromMaps,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void GetDicomAttributesFromMaps::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+
+    std::vector< std::string > lstResult;
+    std::map <std::string,std::string> tmpMap;
+    int i,size=bbGetInputIn().size();
+    std::string strElement;
+
+    for (i=0;i<size;i++)
+    { 
+       tmpMap          = bbGetInputIn()[i];
+        printf("EED GetDicomAttributesFromMaps::Process %d", tmpMap.size() );
+
+       strElement      = tmpMap.find( bbGetInputKeyDicom() )->second;
+       lstResult.push_back( strElement );
+    } // for i
+    bbSetOutputOut( lstResult );
+  
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void GetDicomAttributesFromMaps::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+//   bbSetInputIn(0);
+  
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void GetDicomAttributesFromMaps::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+
+  
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void GetDicomAttributesFromMaps::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbcreaImageIO
+
+
diff --git a/bbtk/src/bbcreaImageIOGetDicomAttributesFromMaps.h b/bbtk/src/bbcreaImageIOGetDicomAttributesFromMaps.h
new file mode 100644 (file)
index 0000000..3b98bfd
--- /dev/null
@@ -0,0 +1,49 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#ifndef __bbcreaImageIOGetDicomAttributesFromMaps_h_INCLUDED__
+#define __bbcreaImageIOGetDicomAttributesFromMaps_h_INCLUDED__
+#include "bbcreaImageIO_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbcreaImageIO
+{
+
+typedef std::map <std::string, std::string> mapString;
+
+class bbcreaImageIO_EXPORT GetDicomAttributesFromMaps
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(GetDicomAttributesFromMaps,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+  BBTK_DECLARE_INPUT(In,std::vector< mapString > );
+  BBTK_DECLARE_INPUT(KeyDicom, std::string);
+  BBTK_DECLARE_OUTPUT(Out,std::vector <std::string>);
+  BBTK_PROCESS(Process);
+  void Process();
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(GetDicomAttributesFromMaps,bbtk::AtomicBlackBox);
+BBTK_NAME("GetDicomAttributesFromMaps");
+BBTK_AUTHOR("Info-Dev, Eduardo DAVIL");
+BBTK_DESCRIPTION("eduardo.davila[at]creatis.insa-lyon.fr -");
+BBTK_CATEGORY("empty");
+  BBTK_INPUT(GetDicomAttributesFromMaps,In,"Vector of maps with DICOM attributes",std::vector< mapString >,"");
+  BBTK_INPUT(GetDicomAttributesFromMaps,KeyDicom,"Key DICOM",std::string ,"");
+  BBTK_OUTPUT(GetDicomAttributesFromMaps,Out,"Vector of the attribute asked.",std::vector <std::string>,"");
+BBTK_END_DESCRIBE_BLACK_BOX(GetDicomAttributesFromMaps);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+}
+// EO namespace bbcreaImageIO
+
+#endif // __bbcreaImageIOGetDicomAttributesFromMaps_h_INCLUDED__
+
index 9c074739974905f80c56bc69b31866d7d930d969..454f8836a600ae12e0b2222108740a6759359f84 100644 (file)
     INPUTS/OUTPUTS DECLARATION -->
 
   <input name="Title" type="std::string" description="Title of the dialog"/>
+
+
+
   <typedef>
     <PRE>
-      typedef std::vector<vtkImageData*> OutputImagesType;</PRE>
+      typedef std::vector<std::string> VectorStringType;</PRE>
   </typedef>
+  <input name="DicomTags" type="VectorStringType" description="Dicom Tags (vector of Dicom tags ex: D0028_0030  D0020_0037)"/>
 
+  <typedef>
+    <PRE>
+      typedef std::vector<vtkImageData*> OutputImagesType;</PRE>
+  </typedef>
   <output name="Out" type="vtkImageData*" description="The selected image"/>
   <output name="OutImages" type="OutputImagesType" description="Vector of selected images"/>
+
+  <typedef>
+    <PRE>
+      typedef std::map<std::string, std::string> MapInfoDicom;</PRE>
+  </typedef>
+
+  <typedef>
+    <PRE>
+      typedef std::vector< MapInfoDicom > VectorMapInfoDicom;</PRE>
+  </typedef>
+
+  <output name="DicomInfo" type="VectorMapInfoDicom" description="vector of maps of Dicom tags"/>
   
   <!--========================================================================
     PROCESS section -->
 
   <process>
     <PRE>
+     
         creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database"); 
+                dlg.SetAttrDicomTags( bbGetInputDicomTags() );
                dlg.ShowModal(); 
+                bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
                if (dlg.getImagesSelected().size()!=0){ 
                  if(dlg.getImagesSelected().size() ==1)
                  {
                        bbSetOutputOut( dlg.getImagesSelected()[0] );  
                  } else {
-printf("EED  creaImageIOWxSimpleDlg 1 \n");
                          // FCY: it will be a big problem if we have several kind of data in the same folder.
                          // creation of a huge vtkImageData!!!!
                          vtkImageData* first = dlg.getImagesSelected()[0];
@@ -101,11 +123,9 @@ printf("EED  creaImageIOWxSimpleDlg 1 \n");
                                // differents formats char , short, etc...
                                // differents components 1..3  ex. jpg ->RGB 3
                                imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
-printf("EED  creaImageIOWxSimpleDlg 2 \n");
                                int slice,sizeImageVector=dlg.getImagesSelected().size();
                                for (slice=0 ; slice<sizeImageVector ; slice++)
                                {
-printf("EED  creaImageIOWxSimpleDlg 3 slice %d     sizeImageVector %d\n",slice,sizeImageVector);
                                        vtkImageData *img = dlg.getImagesSelected()[slice];
                                        memcpy(out->GetScalarPointer(0,0,slice), img->GetScalarPointer(0,0,0), imsize);
                                //img->Delete();
@@ -124,7 +144,6 @@ printf("EED  creaImageIOWxSimpleDlg 3 slice %d     sizeImageVector %d\n",slice,s
 //                     //      (*it)->Delete();
 //                     //  }
 
-printf("EED  creaImageIOWxSimpleDlg 4 \n");
                                bbSetOutputOut(out);
                        } else {
                         bbSetOutputOut(first);
index 60ef13a8bfa0e087e95669378881d07a1309df4a..6cb4defb1656b9109d86d7e1bee3b0617e6ce7f4 100644 (file)
@@ -43,7 +43,7 @@ namespace creaImageIO{
   {
          
        //EED 21 mars 2012  FLIP probleme  ..PLOP..
-       mReader->FileLowerLeftOn();
+       mReader->FileLowerLeftOff();
          
     if (name.size() == 0) 
       {
@@ -98,13 +98,56 @@ namespace creaImageIO{
     vtkImageData* im = 0;
     try
       {
-       
-       mReader->SetFileName(filename.c_str());
+       printf("EED VtkImageReader::ReadImage  Name:%s\n", GetName().c_str() );
+       mReader->SetFileName( filename.c_str() );
        mReader->Update();
        im = vtkImageData::New();
-        mReader->FileLowerLeftOff();
+
        im->ShallowCopy(mReader->GetOutput());
-printf("EED VtkImageReader::ReadImage GetFileLowerLeft %d\n" , mReader->GetFileLowerLeft() );
+
+
+printf("EED ......\n"); 
+printf("EED ......\n");
+printf("EED VtkImageReader::ReadImage line 108   Missing FlipImage for JPEG, PNG, etc\n");
+printf("EED ......\n"); 
+printf("EED ......\n"); 
+/*
+        im=FlipImageY(im);          
+
+       if ( (GetName()=="JPEG") || (GetName()=="PNG") )
+       {
+
+               im->Update();
+               int inputdims[3];
+               im->GetDimensions (inputdims);
+
+                int nbScalComp = im->GetNumberOfScalarComponents();
+               int scalarSize  = im->GetScalarSize();
+               int lineSize    = inputdims[0]*scalarSize*nbScalComp;      
+               int planeSize   = inputdims[1]*lineSize;
+                int volumeSize  = inputdims[2]*planeSize;
+               char *pixelsIn  = (char *)im->GetScalarPointer();
+               char *pixelsOut = (char *)mImageOut->GetScalarPointer();
+       
+               char *lineIn;
+               char *lineOut;
+               char *debPlanIn;
+               char *debPlanOut;
+               int i,j,k;
+
+               for(k=0; k<inputdims[2]; k++)  // iterate  planes
+                       {  
+                               debPlanIn       = pixelsIn+k*planeSize;
+                               debPlanOut      = pixelsOut+k*planeSize;
+                               for(j=0; j<inputdims[1]; j++)  // iterates  rows
+                               { 
+                                       lineIn = debPlanIn+j*lineSize;
+                                       lineOut = debPlanOut+(inputdims[1]-1-j)*lineSize;
+                                       memcpy(lineOut,  lineIn, lineSize);
+                               }       // for j
+                       } // for k
+       } // FLIP : JPEG PNG
+*/
       }
     catch (...)
       {
index db55ad1ca0208959a417f679459d7800ce83cf3f..a537b32aed81577d8345f07fd585b668115e1f27 100644 (file)
@@ -143,27 +143,28 @@ namespace creaImageIO
                 dlg.ShowModal();
                 if (dlg.GetReturnCode() == wxID_OK)
             {
-                       std::vector<creaImageIO::OutStrGimmick> out;
-                       std::vector<std::string> attr;
                                dlg.stopReading();
-                               dlg.getSelected(out, attr,true,"");
+
+                               std::vector<creaImageIO::OutStrGimmick> outStrGimmick;
+                               dlg.getSelected(outStrGimmick, m_attrDicomTags,true,"");
+
                        m_results.clear();
-                       int size=(int)out.size();
+                       int size=(int)outStrGimmick.size();
                        int ii;
-                       if(!bInfo)
-                       {
+//                     if(!bInfo)
+//                     {
                                for (ii=0;ii<size;ii++)
                                {
-                                       m_results.push_back(out[ii].img);
+                                       m_results.push_back(outStrGimmick[ii].img);
+                                       m_resultsDicomAtr.push_back( outStrGimmick[ii].infos );
                                }
-                       }
-                       else
-                       {
-                               for (ii=0;ii<size;ii++)
-                               {
-                                       m_resultsInfo.push_back(out[ii]);
-                               }
-                       }
+//                     } else {
+//                             for (ii=0;ii<size;ii++)
+//                             {
+//                                     m_resultsInfo.push_back(outStrGimmick[ii]);
+//                             }
+//                     }
+
                        dlg.OnExit();
                 }
                 SetReturnCode( dlg.GetReturnCode() );
@@ -183,6 +184,17 @@ namespace creaImageIO
                  return m_results;
          }
 
+       std::vector< std::map<std::string, std::string> >  WxSimpleDlg::getDicomInfoImagesSelected()
+       {
+               return m_resultsDicomAtr;
+       }
+
+       void WxSimpleDlg::SetAttrDicomTags( std::vector<std::string> attr )
+       {
+               m_attrDicomTags=attr;
+       }
          
+
+
 }
 
index 7fd3335ffe1893fa33038c475592f890ad20b1a3..5e3f5f00f4220c2000f5e7c6757a74b1df39443d 100644 (file)
@@ -58,9 +58,12 @@ namespace creaImageIO
 
                   /// return a vtkImageData vector of selected images, if available
                   std::vector<vtkImageData*> getImagesSelected();
-               
                   wxString getInfoImage();
 
+                  std::vector< std::map<std::string,std::string> >  getDicomInfoImagesSelected();
+                  void SetAttrDicomTags( std::vector<std::string> attr );
+
+
                   void setInfo(bool i_val){bInfo = i_val;}
                   
                   // OutStrGimmick:
@@ -69,19 +72,20 @@ namespace creaImageIO
                   std::vector<creaImageIO::OutStrGimmick> getMapInfos(){return m_resultsInfo;}
 
        private:
-               bool                                    bInfo;
-               std::string                             namedescp; 
-               std::string                             namedb;
-               wxString                                infoimage;
+               bool                                                    bInfo;
+               std::string                                             namedescp; 
+               std::string                                             namedb;
+               wxString                                                infoimage;
 
                /// interface to read data
-               SimpleView                              m_view;
+               SimpleView                                              m_view;
 
                /// vtkImageData vector
-               std::vector<vtkImageData*>              m_results;
+               std::vector<vtkImageData*>                              m_results;
+               std::vector< std::map<std::string,std::string> >        m_resultsDicomAtr;
+               std::vector<std::string>                                m_attrDicomTags;    // DXXXX_YYYY DAAAA_BBBB ...
 
                std::vector<creaImageIO::OutStrGimmick> m_resultsInfo;
                
-
        };
 }