Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
" Warning : the image is OVERWRITTEN ",
" to preserve image integrity, use a copy. ",
" usage: AnonymizeReWriteMultiPatient dirin=inputDirectoryName dicomdir ",
" Warning : the image is OVERWRITTEN ",
" to preserve image integrity, use a copy. ",
" usage: AnonymizeReWriteMultiPatient 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 ",
" listOfElementsToRubOut : group-elem,g2-e2,... (in hexa, no space) ",
" of extra Elements to rub out ",
" dicomdir : user wants to generate a DICOMDIR ",
bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
bool dicomdir = ( 0 != am->ArgMgrDefined("dicomdir") );
bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
bool dicomdir = ( 0 != am->ArgMgrDefined("dicomdir") );
int sequentialPatientNumber = 0;
char char_sequentialPatientNumber[10]; // 999999999 patients in a directory should be enough?
int sequentialPatientNumber = 0;
char char_sequentialPatientNumber[10]; // 999999999 patients in a directory should be enough?
patID = pa->GetEntryString(0x0010, 0x0020);
codedID = GDCM_NAME_SPACE::Util::ConvertToMD5(patID);
patID = pa->GetEntryString(0x0010, 0x0020);
codedID = GDCM_NAME_SPACE::Util::ConvertToMD5(patID);
- fullFileName += GDCM_NAME_SPACE::GDCM_FILESEPARATOR;
+ const char lastChar = dirName.c_str()[strlen(dirName.c_str())-1];
+ if ( lastChar != '/' && lastChar != '\\')
+ fullFileName += GDCM_NAME_SPACE::GDCM_FILESEPARATOR;
+
+ // -- remove trailing space, if any
+ int pos=fullFileName.length()-1;
+ if (fullFileName[pos] == ' ')
+ {
+ fullFileName.erase(pos);
+ }
+ // --
+
- f->SetMaxSizeLoadEntry(0x7fff); // we want to load entries of any length !
- f->SetLoadMode(loadMode);
- f->SetFileName( fullFileName );
+ f->SetMaxSizeLoadEntry(0x7fff); // we want to load entries of any length !
+ f->SetLoadMode(loadMode);
+ f->SetFileName( fullFileName );
- // We need a gdcm::FileHelper, since we want to load the pixels
- GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
-
- // unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one !
- // Feel free to cast if you know it's not.
+ // We need a gdcm::FileHelper, since we want to load the pixels
+ GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
- if ( imageData == 0 )
- {
- std::cerr << "Sorry, Pixels of" << fileName <<" are not "
- << " gdcm-readable." << std::endl
- << "Use exAnonymizeNoLoad" << std::endl;
- f->Delete();
- fh->Delete();
- return 0;
- }
-
-
- f->Anonymize();
+ uint8_t *imageData = fh->GetImageData();
+ if ( imageData == 0 )
+ {
+ std::cerr << "Sorry, Pixels of [" << fullFileName <<"] are not "
+ << " gdcm-readable." << std::endl
+ << "Use exAnonymizeNoLoad" << std::endl;
+ f->Delete();
+ fh->Delete();
+ return 0;
+ }
+
+ // ============================================================
+ f->AnonymizeFile();