1 /*=========================================================================
4 Module: $RCSfile: AnonymizeNoLoad.cxx,v $
6 Date: $Date: 2005/06/07 13:10:57 $
7 Version: $Revision: 1.1 $
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 f1 = new gdcm::File( );
71 f1->SetLoadMode(loadMode);
72 int res = f1->Load(fileName);
74 // gdcm::File::IsReadable() is no usable here, because we deal with
75 // any kind of gdcm::Readable *document*
76 // not only gdcm::File (as opposed to gdcm::DicomDir)
80 << "Sorry, " << fileName <<" not a gdcm-readable "
81 << "DICOM / ACR Document"
86 std::cout << fileName << " is readable " << std::endl;
88 // ============================================================
89 // No need to load the pixels in memory.
90 // File will be overwritten
91 // ============================================================
94 // ============================================================
95 // Choose the fields to anonymize.
96 // ============================================================
98 f1->AddAnonymizeElement( 0x0008, 0x0080, "Xanadoo" );
100 f1->AddAnonymizeElement( 0x0010, 0x0010, "Fantomas" );
102 f1->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
103 // Patient's Birthdate
104 f1->AddAnonymizeElement( 0x0010, 0x0030,"11.11.1111" );
106 f1->AddAnonymizeElement( 0x0010, 0x1040,"Sing-sing" );
107 // Patient's Mother's Birth Name
108 f1->AddAnonymizeElement( 0x0010, 0x1060,"Vampirella" );
109 // Study Instance UID
110 f1->AddAnonymizeElement( 0x0020, 0x000d, "9.99.999.9999" );
112 f1->AddAnonymizeElement(0x0010, 0x2154, "3615" );
114 // Aware use will add new fields here
116 // ============================================================
117 // Overwrite the file
118 // ============================================================
120 std::cout <<"Let's AnonymizeNoLoad " << std::endl;;
122 // The gdcm::File remains untouched in memory
124 f1->AnonymizeNoLoad();
126 // No need to write the File : modif were done on disc !
127 // File was overwritten ...
129 std::cout <<"End AnonymizeNoLoad" << std::endl;
131 // ============================================================
132 // Remove the Anonymize list
133 // ============================================================
134 f1->ClearAnonymizeList();