Program: gdcm
Module: $RCSfile: AnonymizeMultiPatient.cxx,v $
Language: C++
- Date: $Date: 2006/06/01 09:35:01 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2007/11/13 11:49:09 $
+ Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
START_USAGE(usage)
" \n AnonymizeMultiPatient :\n ",
" AnonymizeMultiPatient a full gdcm-readable Dicom image ",
+ " optionnaly, creates the DICOMDIR ",
" Warning : the image is OVERWRITTEN ",
" to preserve image integrity, use a copy. ",
- " usage: AnonymizeMultiPatient dirin=inputDirectoryName ",
+ " usage: AnonymizeMultiPatient dirin=inputDirectoryName dicomdir ",
" listOfElementsToRubOut : group-elem,g2-e2,... (in hexa, no space) ",
" of extra Elements to rub out ",
+ " dicomdir : user wants to generate a DICOMDIR ",
" noshadowseq: user doesn't want to load Private Sequences ",
" noshadow : user doesn't want to load Private groups (odd number) ",
" noseq : user doesn't want to load Sequences ",
// ----- Initialize Arguments Manager ------
- gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv);
+ GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
if (argc == 1 || am->ArgMgrDefined("usage"))
{
}
std::string dirName = name;
-
- bool verbose = am->ArgMgrDefined("verbose");
+
+ bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
+ bool dicomdir = ( 0 != am->ArgMgrDefined("dicomdir") );
if (am->ArgMgrDefined("debug"))
- gdcm::Debug::DebugOn();
+ GDCM_NAME_SPACE::Debug::DebugOn();
- int loadMode = gdcm::LD_ALL;
+ int loadMode = GDCM_NAME_SPACE::LD_ALL;
if ( am->ArgMgrDefined("noshadowseq") )
- loadMode |= gdcm::LD_NOSHADOWSEQ;
+ loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
else
{
if ( am->ArgMgrDefined("noshadow") )
- loadMode |= gdcm::LD_NOSHADOW;
+ loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW;
if ( am->ArgMgrDefined("noseq") )
- loadMode |= gdcm::LD_NOSEQ;
+ loadMode |= GDCM_NAME_SPACE::LD_NOSEQ;
}
// ----- Begin Processing -----
- gdcm::DicomDir *dcmdir;
+ GDCM_NAME_SPACE::DicomDir *dcmdir;
// we ask for Directory parsing
- dcmdir = gdcm::DicomDir::New( );
+ dcmdir = GDCM_NAME_SPACE::DicomDir::New( );
dcmdir->SetLoadMode(loadMode);
dcmdir->SetDirectoryName(dirName);
dcmdir->Load();
return 1;
}
- gdcm::DicomDirPatient *pa;
- gdcm::DicomDirStudy *st;
- gdcm::DicomDirSerie *se;
- gdcm::DicomDirImage *im;
+ GDCM_NAME_SPACE::DicomDirPatient *pa;
+ GDCM_NAME_SPACE::DicomDirStudy *st;
+ GDCM_NAME_SPACE::DicomDirSerie *se;
+ GDCM_NAME_SPACE::DicomDirImage *im;
- std::string codedName;
+ std::string codedName;
+ std::string codedID;
std::string fullFileName;
std::string patName;
-
- gdcm::File *f;
+ std::string patID;
+
+ GDCM_NAME_SPACE::File *f;
pa = dcmdir->GetFirstPatient();
while ( pa )
{ // on degouline les PATIENT du DICOMDIR
patName = pa->GetEntryString(0x0010, 0x0010);
- codedName = "g^" + gdcm::Util::ConvertToMD5(patName);
- if (verbose)
- std::cout << patName << " --> " << codedName << std::endl;
+ codedName = "g^" + GDCM_NAME_SPACE::Util::ConvertToMD5(patName);
+ patID = pa->GetEntryString(0x0010, 0x0020);
+ codedID = GDCM_NAME_SPACE::Util::ConvertToMD5(patID);
+
+ if (verbose) {
+ std::cout << "[" << patName << "] --> [" << codedName << "]" << std::endl;
+ std::cout << "[" << patID << "] --> [" << codedID << "]" << std::endl;
+ }
st = pa->GetFirstStudy();
while ( st )
{ // on degouline les STUDY de ce patient
while ( im )
{ // on degouline les Images de cette serie
fullFileName = dirName;
- fullFileName += gdcm::GDCM_FILESEPARATOR;
+ fullFileName += GDCM_NAME_SPACE::GDCM_FILESEPARATOR;
fullFileName += im->GetEntryString(0x0004, 0x1500);
if (verbose)
std::cout << "FileName " << fullFileName << std::endl;
- f = gdcm::File::New( );
+ f = GDCM_NAME_SPACE::File::New( );
f->SetLoadMode(loadMode);
f->SetFileName( fullFileName );
if ( !f->Load() )
f->AddAnonymizeElement( 0x0010, 0x0010, codedName );
// Patient's ID
- f->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
+ //f->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
+ f->AddAnonymizeElement( 0x0010, 0x0020,codedID );
// Patient's Birthdate
f->AddAnonymizeElement( 0x0010, 0x0030,"11111111" );
// Patient's Adress
//
// Overwrite the file
//
- // The gdcm::File remains untouched in memory
+ // The GDCM_NAME_SPACE::File remains untouched in memory
f->AnonymizeNoLoad();
pa = dcmdir->GetNextPatient();
}
- dcmdir->Delete();
+ dcmdir->Delete();
+
+ if (dicomdir)
+ {
+ std::cout << "DICOMDIR creation in progress ..." << std::endl;
+ dcmdir = GDCM_NAME_SPACE::DicomDir::New( );
+ dcmdir->SetLoadMode(loadMode);
+ dcmdir->SetDirectoryName(dirName);
+ dcmdir->Load();
+ dcmdir->Write("DICOMDIR");
+ }
+
return 0;
}