1 /*=========================================================================
4 Module: $RCSfile: AnonymizeNoLoad.cxx,v $
6 Date: $Date: 2005/07/07 17:31:53 $
7 Version: $Revision: 1.3 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmFileHelper.h"
20 #include "gdcmCommon.h"
21 #include "gdcmDebug.h"
23 #include "gdcmArgMgr.h"
27 int main(int argc, char *argv[])
30 " \n AnonymizeNoLoad :\n",
31 " Anonymize a gdcm-readable Dicom image even if pixels aren't gdcm readable",
32 " Warning : Warning : the image is overwritten",
33 " to preserve image integrity, use a copy.",
34 " usage: AnonymizeNoLoad filein=inputFileName fileout=[debug] ",
35 " debug : user wants to run the program in 'debug mode' ",
38 // ----- Initialize Arguments Manager ------
39 gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv);
41 if (am->ArgMgrDefined("usage"))
43 am->ArgMgrUsage(usage); // Display 'usage'
48 if (am->ArgMgrDefined("debug"))
49 gdcm::Debug::DebugOn();
51 char *fileName = am->ArgMgrWantString("filein",usage);
54 if ( am->ArgMgrDefined("noshadow") && am->ArgMgrDefined("noseq") )
55 loadMode = NO_SEQ | NO_SHADOW;
56 else if ( am->ArgMgrDefined("noshadow") )
58 else if ( am->ArgMgrDefined("noseq") )
63 delete am; // we don't need Argument Manager any longer
65 // ============================================================
66 // Parse the input file.
67 // ============================================================
70 f = new gdcm::File( );
71 f->SetLoadMode(loadMode);
72 f->SetFileName( fileName );
75 // gdcm::File::IsReadable() is no usable here, because we deal with
76 // any kind of gdcm::Readable *document*
77 // not only gdcm::File (as opposed to gdcm::DicomDir)
81 << "Sorry, " << fileName <<" not a gdcm-readable "
82 << "DICOM / ACR Document"
87 std::cout << fileName << " is readable " << std::endl;
89 // ============================================================
90 // No need to load the pixels in memory.
91 // File will be overwritten
92 // ============================================================
95 // ============================================================
96 // Choose the fields to anonymize.
97 // ============================================================
99 f->AddAnonymizeElement( 0x0008, 0x0080, "Xanadoo" );
101 f->AddAnonymizeElement( 0x0010, 0x0010, "Fantomas" );
103 f->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
104 // Patient's Birthdate
105 f->AddAnonymizeElement( 0x0010, 0x0030,"11.11.1111" );
107 f->AddAnonymizeElement( 0x0010, 0x1040,"Sing-sing" );
108 // Patient's Mother's Birth Name
109 f->AddAnonymizeElement( 0x0010, 0x1060,"Vampirella" );
110 // Study Instance UID
111 f->AddAnonymizeElement( 0x0020, 0x000d, "9.99.999.9999" );
113 f->AddAnonymizeElement(0x0010, 0x2154, "3615" );
115 // Aware use will add new fields here
117 // ============================================================
118 // Overwrite the file
119 // ============================================================
121 std::cout <<"Let's AnonymizeNoLoad " << std::endl;;
123 // The gdcm::File remains untouched in memory
125 f->AnonymizeNoLoad();
127 // No need to write the File : modif were done on disc !
128 // File was overwritten ...
130 std::cout <<"End AnonymizeNoLoad" << std::endl;
132 // ============================================================
133 // Remove the Anonymize list
134 // ============================================================
135 f->ClearAnonymizeList();