]> Creatis software - creaImageIO.git/commitdiff
allow data anonymization
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Sun, 18 Dec 2011 23:07:42 +0000 (23:07 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Sun, 18 Dec 2011 23:07:42 +0000 (23:07 +0000)
src/creaImageIOGimmickView.cpp
src/creaImageIOGimmickView.h
src/creaImageIOWxTreeView.cpp

index 76342d64da63897103dbdf17b01575d587b4341a..02d18a7d490af03bb2eab27f1540d000f6b5aea3 100644 (file)
@@ -5,6 +5,8 @@
 #if defined(USE_GDCM)
 #include <gdcmGlobal.h>
 #include <gdcmSerieHelper.h>
+#include <gdcmFileHelper.h>
+#include <gdcmUtil.h>
 #include <vtkGdcmReader.h>
 #endif
 
@@ -839,6 +841,66 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, s
   
 
 
+////////////////////////////////////////////////////////////////////////
+void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
+{
+       bool res = true;
+   std::vector<GDCM_NAME_SPACE::FileHelper *> filesH;
+   std::vector<std::string> suid;
+   std::map<std::string, std::string> msuid;
+   std::string tempuid = GDCM_NAME_SPACE::Util::CreateUniqueUID();
+   int i = 1;
+   std::vector<std::string>::iterator it = i_filenames.begin();
+   for(; it != i_filenames.end(); it++)
+   {
+
+          GDCM_NAME_SPACE::File *file;
+          file = GDCM_NAME_SPACE::File::New(  );
+          file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL );
+          file->SetFileName( (*it).c_str() );
+          res = file->Load();
+          if ( !res ) 
+          {
+                       std::cerr << "Sorry, " <<  (*it).c_str()  <<"  not a gdcm-readable "
+                 << "DICOM / ACR File" <<std::endl;
+                       file ->Delete();
+       //return 0;
+               }
+               std::cout << " ... is readable " << std::endl;
+               
+               // We need a gdcm::FileHelper, since we want to load the pixels        
+               GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(file);
+       
+   uint8_t *imageData = fh->GetImageData();
+
+          // Institution name 
+          file->AddAnonymizeElement(0x0008, 0x0080, "*"); 
+          // Patient's name 
+          file->AddAnonymizeElement(0x0010, 0x0010, "*");   
+          // Patient's ID
+          file->AddAnonymizeElement( 0x0010, 0x0020,"1515" );   
+          // Study Instance UID
+          file->AddAnonymizeElement(0x0020, 0x000d, tempuid );
+          // Telephone
+          file->AddAnonymizeElement(0x0010, 0x2154, "3615" );
+
+          // Aware user will add here more fields to anonymize here
+
+          // The gdcm::File is modified in memory
+
+          file->AnonymizeFile();
+
+          
+          i++;
+          fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
+   
+          fh->WriteDcmExplVR(file->GetFileName() +".ano1" );
+          std::cout << i <<"  End Anonymize" << std::cout;  
+          file->ClearAnonymizeList();
+          file->Delete();
+          fh->Delete();
+   }
+}
 ////////////////////////////////////////////////////////////////////////
 //void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
 //{
index c34f895d08d89e09ef8b3d7efea894272f7bd177..fb9f17738ec4bc6e5b6623ca49a796e45dcab3bd 100644 (file)
@@ -12,8 +12,8 @@
 #include <creaImageIOMultiThreadImageReader.h>
 #endif
 
-#if defined(USE_QT4)
-#include <creaImageIOQMultiThreadImageReader.h>
+#if defined(USE_QT)
+#include "Qt/creaImageIOQMultiThreadImageReader.h"
 #endif
 
 
@@ -112,8 +112,7 @@ namespace creaImageIO
          { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
       
          /// Anonymize or de-anonymize data
-         virtual void Anonymize(std::vector<std::string> i_filenames, int type)
-         { GimmickError("INTERNAL ERROR : Anonymize not implemented"); }
+         void Anonymize(std::vector<std::string> i_filenames, int type);
 
          /// Display all Dicom Tags
          virtual void DumpTags(const std::string filename)
index 34db01a70a63b4aa8041e5b68b2656dc666a6314..49bba9b711b1bca8139814779bd07010d07f0139 100644 (file)
@@ -222,11 +222,11 @@ namespace creaImageIO
        wxMenuItem* m4Item=menuItem->Append(wxID_ANY, _T("&Display Dicom Tags"));
        menuItem->AppendSubMenu(subExportMenu, wxT("&Export"));
 
-#if defined(USE_GDCM_ANOM)
+
        wxMenuItem* m1Item=menuItem->Append(wxID_ANY, _T("&Anonymize"));
        mAnonymizingID=m1Item->GetId();
-       Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymize) );
-#endif
+       Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymizer) );
+
        mLocalCopyID=m2Item->GetId();
        mEditFieldID=m3Item->GetId();
        mDumpID=m4Item->GetId();
@@ -821,11 +821,11 @@ namespace creaImageIO
           wxBusyCursor busy;
           std::vector<std::string> filesname;
           std::vector<tree::Node*> nodes;
-//        nodes.push_back(((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node);
+          nodes.push_back(((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node);
           if(nodes.size() != 0)
           {
                   GetFilenamesAsString(nodes,filesname);
-               //   GetGimmickView()->Anonymize(filesname,0);
+                  GetGimmickView()->Anonymize(filesname,0);
           }
        
   }