X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOGimmickView.cpp;fp=src%2FcreaImageIOGimmickView.cpp;h=02d18a7d490af03bb2eab27f1540d000f6b5aea3;hb=a881ab2fb97d10dd3cff975444f81b0b497b2ad7;hp=76342d64da63897103dbdf17b01575d587b4341a;hpb=571ba36f99e308623afc6f6cd0e7e3ae0a4bc09e;p=creaImageIO.git diff --git a/src/creaImageIOGimmickView.cpp b/src/creaImageIOGimmickView.cpp index 76342d6..02d18a7 100644 --- a/src/creaImageIOGimmickView.cpp +++ b/src/creaImageIOGimmickView.cpp @@ -5,6 +5,8 @@ #if defined(USE_GDCM) #include #include +#include +#include #include #endif @@ -839,6 +841,66 @@ void GimmickView::ReadImagesNotThreadedInVector(std::vector& s, s +//////////////////////////////////////////////////////////////////////// +void GimmickView::Anonymize(std::vector i_filenames, int type) +{ + bool res = true; + std::vector filesH; + std::vector suid; + std::map msuid; + std::string tempuid = GDCM_NAME_SPACE::Util::CreateUniqueUID(); + int i = 1; + std::vector::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" <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 i_filenames, int type) //{