]> Creatis software - gdcm.git/blob - src/gdcmHeader.cxx
* Erroneous leading white fix:
[gdcm.git] / src / gdcmHeader.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmHeader.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/06/20 18:08:47 $
7   Version:   $Revision: 1.165 $
8                                                                                 
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.htm for details.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmHeader.h"
20 #include "gdcmGlobal.h"
21 #include "gdcmUtil.h"
22 #include "gdcmDebug.h"
23 #include "gdcmTS.h"
24 #include "gdcmValEntry.h"
25
26 #include <vector>
27
28 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
30 /**
31  * \brief  Constructor 
32  * @param  InFilename name of the file whose header we want to analyze
33  * @param  exception_on_error whether we want to throw an exception or not
34  * @param  enable_sequences = true to allow the header 
35  *         to be parsed *inside* the SeQuences, when they have an actual length 
36  * @param  ignore_shadow = true if user wants to skip shadow groups 
37  *         during parsing, to save memory space
38  */
39 gdcmHeader::gdcmHeader(const char *InFilename, 
40                        bool exception_on_error,
41                        bool enable_sequences, 
42                        bool ignore_shadow):
43    gdcmDocument(InFilename,exception_on_error,enable_sequences,ignore_shadow)
44
45 /*
46    typedef struct {
47       guint32 totalSQlength;
48       guint32 alreadyParsedlength;
49    } pileElem;
50 */
51    
52    // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010
53    // We may encounter the 'RETired' (0x0028, 0x0200) tag
54    // (Image Location") . This Element contains the number of
55    // the group that contains the pixel data (hence the "Pixel Data"
56    // is found by indirection through the "Image Location").
57    // Inside the group pointed by "Image Location" the searched element
58    // is conventionally the element 0x0010 (when the norm is respected).
59    // When the "Image Location" is absent we default to group 0x7fe0.
60    
61    // This IS the right place for the code
62  
63    std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
64    if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
65       GrPixel = 0x7fe0;                   // default value
66    } else {
67       GrPixel = (guint16) atoi( ImageLocation.c_str() );
68    }   
69    if (GrPixel == 0xe07f) // sometimes Image Location value doesn't follow 
70       GrPixel = 0x7fe0;   // the supposed processor endianity. 
71                           // see gdcmData/cr172241.dcm      
72    if (GrPixel != 0x7fe0) 
73       // This is a kludge for old dirty Philips imager.
74       NumPixel = 0x1010;
75    else
76       NumPixel = 0x0010;
77    
78 }
79
80 /**
81  * \brief Constructor  
82  * @param exception_on_error whether we want to throw an exception or not
83  */
84 gdcmHeader::gdcmHeader(bool exception_on_error) :
85    gdcmDocument(exception_on_error)
86 {
87 }
88
89 /**
90  * \ingroup gdcmHeader
91  * \brief   Canonical destructor.
92  */
93 gdcmHeader::~gdcmHeader (void) {
94 }
95
96 //-----------------------------------------------------------------------------
97 // Print
98
99
100 //-----------------------------------------------------------------------------
101 // Public
102
103 /**
104  * \brief  This predicate, based on hopefully reasonable heuristics,
105  *         decides whether or not the current gdcmHeader was properly parsed
106  *         and contains the mandatory information for being considered as
107  *         a well formed and usable Dicom/Acr File.
108  * @return true when gdcmHeader is the one of a reasonable Dicom/Acr file,
109  *         false otherwise. 
110  */
111 bool gdcmHeader::IsReadable(void) {
112    if(!gdcmDocument::IsReadable()) {
113       return(false);
114    }
115    std::string res = GetEntryByNumber(0x0028, 0x0005);
116    if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) 
117       return false; // Image Dimensions
118    if ( !GetDocEntryByNumber(0x0028, 0x0100) )
119       return false; // "Bits Allocated"
120    if ( !GetDocEntryByNumber(0x0028, 0x0101) )
121       return false; // "Bits Stored"
122    if ( !GetDocEntryByNumber(0x0028, 0x0102) )
123       return false; // "High Bit"
124    if ( !GetDocEntryByNumber(0x0028, 0x0103) )
125       return false; // "Pixel Representation" i.e. 'Sign'
126    return true;
127 }
128
129 /**
130  * \brief   Retrieve the number of columns of image.
131  * @return  The encountered size when found, 0 by default.
132  *          0 means the file is NOT USABLE. The caller will have to check
133  */
134 int gdcmHeader::GetXSize(void) {
135    std::string StrSize;
136    StrSize = GetEntryByNumber(0x0028,0x0011);
137    if (StrSize == GDCM_UNFOUND)
138       return 0;
139    return atoi(StrSize.c_str());
140 }
141
142 /**
143  * \ingroup gdcmHeader
144  * \brief   Retrieve the number of lines of image.
145  * \warning The defaulted value is 1 as opposed to gdcmHeader::GetXSize()
146  * @return  The encountered size when found, 1 by default 
147  *          (The ACR-MEMA file contains a Signal, not an Image).
148  */
149 int gdcmHeader::GetYSize(void) {
150    std::string StrSize = GetEntryByNumber(0x0028,0x0010);
151    if (StrSize != GDCM_UNFOUND)
152       return atoi(StrSize.c_str());
153    if ( IsDicomV3() )
154       return 0;
155    else
156       // The Rows (0028,0010) entry was optional for ACR/NEMA. It might
157       // hence be a signal (1d image). So we default to 1:
158       return 1;
159 }
160
161 /**
162  * \ingroup gdcmHeader
163  * \brief   Retrieve the number of planes of volume or the number
164  *          of frames of a multiframe.
165  * \warning When present we consider the "Number of Frames" as the third
166  *          dimension. When absent we consider the third dimension as
167  *          being the ACR-NEMA "Planes" tag content.
168  * @return  The encountered size when found, 1 by default (single image).
169  */
170 int gdcmHeader::GetZSize(void) {
171    // Both  DicomV3 and ACR/Nema consider the "Number of Frames"
172    // as the third dimension.
173    std::string StrSize = GetEntryByNumber(0x0028,0x0008);
174    if (StrSize != GDCM_UNFOUND)
175       return atoi(StrSize.c_str());
176
177    // We then consider the "Planes" entry as the third dimension 
178    StrSize = GetEntryByNumber(0x0028,0x0012);
179    if (StrSize != GDCM_UNFOUND)
180       return atoi(StrSize.c_str());
181    return 1;
182 }
183
184 /**
185  * \ingroup gdcmHeader
186  * \brief   Retrieve the number of Bits Stored (actually used)
187  *          (as opposite to number of Bits Allocated)
188  * @return  The encountered number of Bits Stored, 0 by default.
189  *          0 means the file is NOT USABLE. The caller has to check it !
190  */
191 int gdcmHeader::GetBitsStored(void) {  
192    std::string StrSize = GetEntryByNumber(0x0028,0x0101);
193    if (StrSize == GDCM_UNFOUND)
194       return 0;  // It's supposed to be mandatory
195                  // the caller will have to check
196    return atoi(StrSize.c_str());
197 }
198
199 /**
200  * \ingroup gdcmHeader
201  * \brief   Retrieve the number of Bits Allocated
202  *          (8, 12 -compacted ACR-NEMA files, 16, ...)
203  * @return  The encountered number of Bits Allocated, 0 by default.
204  *          0 means the file is NOT USABLE. The caller has to check it !
205  */
206 int gdcmHeader::GetBitsAllocated(void) {
207    std::string StrSize = GetEntryByNumber(0x0028,0x0100);
208    if (StrSize == GDCM_UNFOUND)
209       return 0; // It's supposed to be mandatory
210                 // the caller will have to check
211    return atoi(StrSize.c_str());
212 }
213
214 /**
215  * \ingroup gdcmHeader
216  * \brief   Retrieve the number of Samples Per Pixel
217  *          (1 : gray level, 3 : RGB -1 or 3 Planes-)
218  * @return  The encountered number of Samples Per Pixel, 1 by default.
219  *          (Gray level Pixels)
220  */
221 int gdcmHeader::GetSamplesPerPixel(void) {
222    std::string StrSize = GetEntryByNumber(0x0028,0x0002);
223    if (StrSize == GDCM_UNFOUND)
224       return 1; // Well, it's supposed to be mandatory ...
225                 // but sometimes it's missing : *we* assume Gray pixels
226    return atoi(StrSize.c_str());
227 }
228
229 /**
230  * \ingroup gdcmHeader
231  * \brief   Retrieve the Planar Configuration for RGB images
232  *          (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane)
233  * @return  The encountered Planar Configuration, 0 by default.
234  */
235 int gdcmHeader::GetPlanarConfiguration(void) {
236    std::string StrSize = GetEntryByNumber(0x0028,0x0006);
237    if (StrSize == GDCM_UNFOUND)
238       return 0;
239    return atoi(StrSize.c_str());
240 }
241
242 /**
243  * \ingroup gdcmHeader
244  * \brief   Return the size (in bytes) of a single pixel of data.
245  * @return  The size in bytes of a single pixel of data; 0 by default
246  *          0 means the file is NOT USABLE; the caller will have to check        
247  */
248 int gdcmHeader::GetPixelSize(void) {
249    std::string PixelType = GetPixelType();
250    if (PixelType == "8U"  || PixelType == "8S")
251       return 1;
252    if (PixelType == "16U" || PixelType == "16S")
253       return 2;
254    if (PixelType == "32U" || PixelType == "32S")
255       return 4;
256    if (PixelType == "FD")
257       return 8;         
258    dbg.Verbose(0, "gdcmHeader::GetPixelSize: Unknown pixel type");
259    return 0;
260 }
261
262 /**
263  * \ingroup gdcmHeader
264  * \brief   Build the Pixel Type of the image.
265  *          Possible values are:
266  *          - 8U  unsigned  8 bit,
267  *          - 8S    signed  8 bit,
268  *          - 16U unsigned 16 bit,
269  *          - 16S   signed 16 bit,
270  *          - 32U unsigned 32 bit,
271  *          - 32S   signed 32 bit,
272  *          - FD floating double 64 bits (Not kosher DICOM, but so usefull!)
273  * \warning 12 bit images appear as 16 bit.
274  *          24 bit images appear as 8 bit
275  * @return  0S if nothing found. NOT USABLE file. The caller has to check
276  */
277 std::string gdcmHeader::GetPixelType(void) { 
278    std::string BitsAlloc = GetEntryByNumber(0x0028, 0x0100); // Bits Allocated
279    if (BitsAlloc == GDCM_UNFOUND) {
280       dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Bits Allocated");
281       BitsAlloc = std::string("16");
282    }
283    if (BitsAlloc == "64")            // )
284       return ("FD");
285    if (BitsAlloc == "12")            // It will be unpacked
286       BitsAlloc = std::string("16");
287    else if (BitsAlloc == "24")       // (in order no to be messed up
288       BitsAlloc = std::string("8");  // by old RGB images)
289      
290    std::string Signed = GetEntryByNumber(0x0028, 0x0103); // "Pixel Representation"
291    if (Signed == GDCM_UNFOUND) {
292       dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Pixel Representation");
293       BitsAlloc = std::string("0");
294    }
295    if (Signed == "0")
296       Signed = std::string("U");
297    else
298       Signed = std::string("S");
299
300    return( BitsAlloc + Signed);
301 }
302
303
304 /**
305  * \ingroup gdcmHeader
306  * \brief   Recover the offset (from the beginning of the file) 
307  *          of *image* pixels (not *icone image* pixels, if any !)
308  * @return Pixel Offset
309  */
310 size_t gdcmHeader::GetPixelOffset(void) { 
311       
312    gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel);
313  
314    if (PixelElement) {
315       return PixelElement->GetOffset();
316    } else {
317 #ifdef GDCM_DEBUG
318       std::cout << "Big trouble : Pixel Element ("
319                 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
320                 << std::endl;  
321 #endif //GDCM_DEBUG
322       return 0;
323    }     
324 }
325 // TODO : unify those two (previous one and next one)
326 /**
327  * \ingroup gdcmHeader
328  * \brief   Recover the pixel area length (in Bytes)
329  * @return Pixel Element Length, as stored in the header
330  *         (NOT the memory space necessary to hold the Pixels 
331  *          -in case of embeded compressed image-)
332  *         0 : NOT USABLE file. The caller has to check.
333  */
334 size_t gdcmHeader::GetPixelAreaLength(void) { 
335           
336    gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel);
337
338    if (PixelElement) {
339       return PixelElement->GetLength();
340    } else {
341 #ifdef GDCM_DEBUG
342       std::cout << "Big trouble : Pixel Element ("
343                 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
344                 << std::endl;
345 #endif //GDCM_DEBUG
346       return 0;
347    }
348 }
349
350 /**
351   * \ingroup gdcmHeader
352   * \brief tells us if LUT are used
353   * \warning Right now, 'Segmented xxx Palette Color Lookup Table Data'
354   *          are NOT considered as LUT, since nobody knows
355   *          how to deal with them
356   *          Please warn me if you know sbdy that *does* know ... jprx
357   * @return true if LUT Descriptors and LUT Tables were found 
358   */
359 bool gdcmHeader::HasLUT(void) {
360
361    // Check the presence of the LUT Descriptors, and LUT Tables    
362    // LutDescriptorRed    
363    if ( !GetDocEntryByNumber(0x0028,0x1101) )
364       return false;
365    // LutDescriptorGreen 
366    if ( !GetDocEntryByNumber(0x0028,0x1102) )
367       return false;
368    // LutDescriptorBlue 
369    if ( !GetDocEntryByNumber(0x0028,0x1103) )
370       return false;   
371    // Red Palette Color Lookup Table Data
372    if ( !GetDocEntryByNumber(0x0028,0x1201) )
373       return false; 
374    // Green Palette Color Lookup Table Data       
375    if ( !GetDocEntryByNumber(0x0028,0x1202) )
376       return false;
377    // Blue Palette Color Lookup Table Data      
378    if ( !GetDocEntryByNumber(0x0028,0x1203) )
379       return false;
380    // FIXME : (0x0028,0x3006) : LUT Data (CTX dependent)
381    //         NOT taken into account, but we don't know how to use it ...   
382    return true;
383 }
384
385 /**
386   * \ingroup gdcmHeader
387   * \brief gets the info from 0028,1101 : Lookup Table Desc-Red
388   *             else 0
389   * @return Lookup Table number of Bits , 0 by default
390   *          when (0028,0004),Photometric Interpretation = [PALETTE COLOR ]
391   * @ return bit number of each LUT item 
392   */
393 int gdcmHeader::GetLUTNbits(void) {
394    std::vector<std::string> tokens;
395    //int LutLength;
396    //int LutDepth;
397    int LutNbits;
398    //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red = Lookup Table Desc-Blue
399    // Consistency already checked in GetLUTLength
400    std::string LutDescription = GetEntryByNumber(0x0028,0x1101);
401    if (LutDescription == GDCM_UNFOUND)
402       return 0;
403    tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
404    Tokenize (LutDescription, tokens, "\\");
405    //LutLength=atoi(tokens[0].c_str());
406    //LutDepth=atoi(tokens[1].c_str());
407    LutNbits=atoi(tokens[2].c_str());
408    tokens.clear();
409    return LutNbits;
410 }
411
412 /**
413   * \ingroup gdcmHeader
414   * \brief builts Red/Green/Blue/Alpha LUT from Header
415   *         when (0028,0004),Photometric Interpretation = [PALETTE COLOR ]
416   *          and (0028,1101),(0028,1102),(0028,1102)  
417   *            - xxx Palette Color Lookup Table Descriptor - are found
418   *          and (0028,1201),(0028,1202),(0028,1202) 
419   *            - xxx Palette Color Lookup Table Data - are found 
420   * \warning does NOT deal with :
421   *   0028 1100 Gray Lookup Table Descriptor (Retired)
422   *   0028 1221 Segmented Red Palette Color Lookup Table Data
423   *   0028 1222 Segmented Green Palette Color Lookup Table Data
424   *   0028 1223 Segmented Blue Palette Color Lookup Table Data 
425   *   no known Dicom reader deals with them :-(
426   * @return a RGBA Lookup Table 
427   */ 
428 unsigned char * gdcmHeader::GetLUTRGBA(void) {
429 // Not so easy : see 
430 // http://www.barre.nom.fr/medical/dicom2/limitations.html#Color%20Lookup%20Tables
431
432 //  if Photometric Interpretation # PALETTE COLOR, no LUT to be done
433    if (GetEntryByNumber(0x0028,0x0004) != "PALETTE COLOR ") {
434       return NULL;
435    }  
436    int lengthR, debR, nbitsR;
437    int lengthG, debG, nbitsG;
438    int lengthB, debB, nbitsB;
439    
440 // Get info from Lut Descriptors
441 // (the 3 LUT descriptors may be different)    
442    std::string LutDescriptionR = GetEntryByNumber(0x0028,0x1101);
443    if (LutDescriptionR == GDCM_UNFOUND)
444       return NULL;
445    std::string LutDescriptionG = GetEntryByNumber(0x0028,0x1102);
446    if (LutDescriptionG == GDCM_UNFOUND)
447       return NULL;   
448    std::string LutDescriptionB = GetEntryByNumber(0x0028,0x1103);
449    if (LutDescriptionB == GDCM_UNFOUND)
450       return NULL;
451       
452    std::vector<std::string> tokens;
453       
454    tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
455    Tokenize (LutDescriptionR, tokens, "\\");
456    lengthR=atoi(tokens[0].c_str()); // Red LUT length in Bytes
457    debR   =atoi(tokens[1].c_str()); // subscript of the first Lut Value
458    nbitsR =atoi(tokens[2].c_str()); // Lut item size (in Bits)
459    tokens.clear();
460    
461    tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
462    Tokenize (LutDescriptionG, tokens, "\\");
463    lengthG=atoi(tokens[0].c_str()); // Green LUT length in Bytes
464    debG   =atoi(tokens[1].c_str()); // subscript of the first Lut Value
465    nbitsG =atoi(tokens[2].c_str()); // Lut item size (in Bits)
466    tokens.clear();  
467    
468    tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
469    Tokenize (LutDescriptionB, tokens, "\\");
470    lengthB=atoi(tokens[0].c_str()); // Blue LUT length in Bytes
471    debB   =atoi(tokens[1].c_str()); // subscript of the first Lut Value
472    nbitsB =atoi(tokens[2].c_str()); // Lut item size (in Bits)
473    tokens.clear();
474  
475    // Load LUTs into memory, (as they were stored on disk)
476    unsigned char *lutR = (unsigned char *)
477                          GetEntryVoidAreaByNumber(0x0028,0x1201);
478    unsigned char *lutG = (unsigned char *)
479                          GetEntryVoidAreaByNumber(0x0028,0x1202);
480    unsigned char *lutB = (unsigned char *)
481                          GetEntryVoidAreaByNumber(0x0028,0x1203); 
482    
483    if (!lutR || !lutG || !lutB ) {
484       return NULL;
485    } 
486    // forge the 4 * 8 Bits Red/Green/Blue/Alpha LUT 
487    
488    unsigned char *LUTRGBA = new unsigned char[1024]; // 256 * 4 (R, G, B, Alpha) 
489    if (!LUTRGBA) {
490       return NULL;
491    }
492    memset(LUTRGBA, 0, 1024);
493    // Bits Allocated
494    int nb;
495    std::string str_nb = GetEntryByNumber(0x0028,0x0100);
496    if (str_nb == GDCM_UNFOUND ) {
497       nb = 16;
498    } else {
499       nb = atoi(str_nb.c_str() );
500    }  
501    int mult;
502
503    if (nbitsR==16 && nb==8) // when LUT item size is different than pixel size
504       mult=2;               // high byte must be = low byte 
505    else                     // See PS 3.3-2003 C.11.1.1.2 p 619
506       mult=1; 
507  
508    // if we get a black image, let's just remove the '+1'
509    // from 'i*mult+1' and check again 
510    // if it works, we shall have to check the 3 Palettes
511    // to see which byte is ==0 (first one, or second one)
512    // and fix the code
513    // We give up the checking to avoid some (useless ?)overhead 
514    // (optimistic asumption)
515    unsigned char *a;      
516    int i;
517
518    a = LUTRGBA+0;
519    for(i=0;i<lengthR;i++) {
520       *a = lutR[i*mult+1]; 
521       a+=4;       
522    }        
523    a = LUTRGBA+1;
524    for(i=0;i<lengthG;i++) {
525       *a = lutG[i*mult+1]; 
526       a+=4;       
527    }  
528    a = LUTRGBA+2;
529    for(i=0;i<lengthB;i++) {
530       *a = lutB[i*mult+1]; 
531       a+=4;       
532    }  
533    a = LUTRGBA+3;
534    for(i=0;i<256;i++) {
535       *a = 1; // Alpha component
536       a+=4; 
537    } 
538    
539    //How to free the now useless LUTs?
540    //free(LutR); free(LutB); free(LutG); // Seg Fault when used
541    return(LUTRGBA);   
542
543
544 /**
545  * \brief Accesses the info from 0002,0010 : Transfert Syntax and gdcmTS
546  *        else 1.
547  * @return The full Transfert Syntax Name (as opposed to Transfert Syntax UID)
548  */
549 std::string gdcmHeader::GetTransfertSyntaxName(void) { 
550    // use the gdcmTS (TS : Transfert Syntax)
551    std::string TransfertSyntax = GetEntryByNumber(0x0002,0x0010);
552    if (TransfertSyntax == GDCM_UNFOUND) {
553       dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:"
554                      " unfound Transfert Syntax (0002,0010)");
555       return "Uncompressed ACR-NEMA";
556    }
557    // we do it only when we need it
558    gdcmTS * ts = gdcmGlobal::GetTS();
559    std::string tsName=ts->GetValue(TransfertSyntax);
560    //delete ts; /// \todo Seg Fault when deleted ?!
561    return tsName;
562 }
563
564 /**
565  * \brief Sets the Pixel Area size in the Header
566  *        --> not-for-rats function
567  * @param ImageDataSize new Pixel Area Size
568  *        warning : nothing else is checked
569  */
570 void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
571    std::string content1;
572    char car[20];
573
574    sprintf(car,"%d",ImageDataSize);
575  
576    gdcmDocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel);
577    a->SetLength(ImageDataSize);
578
579    ImageDataSize+=8;
580    sprintf(car,"%d",ImageDataSize);
581    content1=car;
582    SetEntryByNumber(content1, GrPixel, NumPixel);
583 }
584
585 //-----------------------------------------------------------------------------
586 // Protected
587
588 /**
589  * \brief anonymize a Header (removes Patient's personal info)
590  *        (read the code to see which ones ...)
591  */
592 bool gdcmHeader::anonymizeHeader() {
593
594   gdcmDocEntry *patientNameHE = GetDocEntryByNumber (0x0010, 0x0010);
595     
596   ReplaceIfExistByNumber ("  ",0x0010, 0x2154); // Telephone   
597   ReplaceIfExistByNumber ("  ",0x0010, 0x1040); // Adress
598   ReplaceIfExistByNumber ("  ",0x0010, 0x0020); // Patient ID
599   
600   if (patientNameHE) {
601      std::string StudyInstanceUID =  GetEntryByNumber (0x0020, 0x000d);
602      if (StudyInstanceUID !=GDCM_UNFOUND)
603         ReplaceOrCreateByNumber(StudyInstanceUID, 0x0010, 0x0010);
604      else
605         ReplaceOrCreateByNumber(std::string("anonymised"), 0x0010, 0x0010);
606   }
607   
608   // Just for fun :-(
609   // (if any) remove or replace all the stuff that contains a Date
610   
611 //0008 0012 DA ID Instance Creation Date
612 //0008 0020 DA ID Study Date
613 //0008 0021 DA ID Series Date
614 //0008 0022 DA ID Acquisition Date
615 //0008 0023 DA ID Content Date
616 //0008 0024 DA ID Overlay Date
617 //0008 0025 DA ID Curve Date
618 //0008 002a DT ID Acquisition Datetime
619 //0018 9074 DT ACQ Frame Acquisition Datetime
620 //0018 9151 DT ACQ Frame Reference Datetime
621 //0018 a002 DT ACQ Contribution Date Time
622 //0020 3403 SH REL Modified Image Date (RET)
623 //0032 0032 DA SDY Study Verified Date
624 //0032 0034 DA SDY Study Read Date
625 //0032 1000 DA SDY Scheduled Study Start Date
626 //0032 1010 DA SDY Scheduled Study Stop Date
627 //0032 1040 DA SDY Study Arrival Date
628 //0032 1050 DA SDY Study Completion Date
629 //0038 001a DA VIS Scheduled Admission Date
630 //0038 001c DA VIS Scheduled Discharge Date
631 //0038 0020 DA VIS Admitting Date
632 //0038 0030 DA VIS Discharge Date
633 //0040 0002 DA PRC Scheduled Procedure Step Start Date
634 //0040 0004 DA PRC Scheduled Procedure Step End Date
635 //0040 0244 DA PRC Performed Procedure Step Start Date
636 //0040 0250 DA PRC Performed Procedure Step End Date
637 //0040 2004 DA PRC Issue Date of Imaging Service Request
638 //0040 4005 DT PRC Scheduled Procedure Step Start Date and Time
639 //0040 4011 DT PRC Expected Completion Date and Time
640 //0040 a030 DT PRC Verification Date Time
641 //0040 a032 DT PRC Observation Date Time
642 //0040 a120 DT PRC DateTime
643 //0040 a121 DA PRC Date
644 //0040 a13a DT PRC Referenced Datetime
645 //0070 0082 DA ??? Presentation Creation Date
646 //0100 0420 DT ??? SOP Autorization Date and Time
647 //0400 0105 DT ??? Digital Signature DateTime
648 //2100 0040 DA PJ Creation Date
649 //3006 0008 DA SSET Structure Set Date
650 //3008 0024 DA ??? Treatment Control Point Date
651 //3008 0054 DA ??? First Treatment Date
652 //3008 0056 DA ??? Most Recent Treatment Date
653 //3008 0162 DA ??? Safe Position Exit Date
654 //3008 0166 DA ??? Safe Position Return Date
655 //3008 0250 DA ??? Treatment Date
656 //300a 0006 DA RT RT Plan Date
657 //300a 022c DA RT Air Kerma Rate Reference Date
658 //300e 0004 DA RT Review Date
659  return true;  
660 }
661 //-----------------------------------------------------------------------------
662 // Private
663
664 //-----------------------------------------------------------------------------