]> Creatis software - gdcm.git/blob - Example/PrintFile.cxx
Normalization
[gdcm.git] / Example / PrintFile.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintFile.cxx,v $
5   Language:  C++
6   Date:      $Date: 2007/09/26 08:07:42 $
7   Version:   $Revision: 1.86 $
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.html 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 #include "gdcmFile.h"
19 #include "gdcmDocument.h"
20 #include "gdcmSeqEntry.h"
21 #include "gdcmSQItem.h"
22 #include "gdcmDataEntry.h"
23
24 #include "gdcmFileHelper.h"
25 #include "gdcmDebug.h"
26 #include "gdcmDirList.h"
27 #include "gdcmGlobal.h"
28 #include "gdcmDictSet.h"
29 #include "gdcmArgMgr.h"
30 #include "gdcmOrientation.h"
31 #include <iostream>
32
33 // TODO : code factorization, for 'single file' an 'whole directory' processing
34
35 void ShowLutData(GDCM_NAME_SPACE::File *f);
36
37      // Nothing is written yet to get LUT Data user friendly
38      // The following is to be moved into a PixelReadConvert method
39      // Let here, waiting for a clever idea on the way to do it.
40
41 void ShowLutData(GDCM_NAME_SPACE::File *f)
42 {  
43    GDCM_NAME_SPACE::SeqEntry *modLutSeq = f->GetSeqEntry(0x0028,0x3000);
44    if ( modLutSeq !=0 )
45    {
46       GDCM_NAME_SPACE::SQItem *sqi= modLutSeq->GetFirstSQItem();
47       if ( sqi != 0 )
48       {
49          std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
50          if (   /*lutDescriptor   == GDCM_UNFOUND*/ 0 )
51          {
52             std::cout << "LUT Descriptor is missing" << std::endl;
53             return;
54          }
55          int length;   // LUT length in Bytes
56          int deb;      // Subscript of the first Lut Value
57          int nbits;    // Lut item size (in Bits)
58
59          int nbRead;    // nb of items in LUT descriptor (must be = 3)
60
61          nbRead = sscanf( lutDescriptor.c_str(),
62                            "%d\\%d\\%d",
63                               &length, &deb, &nbits );
64          std::cout << "length " << length 
65                   << " deb " << deb 
66                   << " nbits " << nbits
67                   << std::endl;
68          if ( nbRead != 3 )
69          {
70             std::cout << "Wrong LUT descriptor" << std::endl;
71          }
72          //LUT Data (CTX dependent)    
73          GDCM_NAME_SPACE::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006); 
74          if ( b != 0 )
75          { 
76             int BitsAllocated = f->GetBitsAllocated();
77             if ( BitsAllocated <= 8 )
78             { 
79                int mult;
80                if ( ( nbits == 16 ) && ( BitsAllocated == 8 ) )
81                {
82                // when LUT item size is different than pixel size
83                   mult = 2; // high byte must be = low byte
84                }
85                else
86                {
87                // See PS 3.3-2003 C.11.1.1.2 p 619
88                   mult = 1;
89                }
90                uint8_t *lut = b->GetBinArea();
91                for( int i=0; i < length; ++i )
92                {
93                   std::cout << i+deb << " : \t"
94                               << (int) (lut[i*mult + 1]) << std::endl;
95                }
96             }
97             else
98             {
99                uint16_t *lut = (uint16_t *)(b->GetBinArea());  
100                for( int i=0; i < length; ++i )
101                {
102                   std::cout << i+deb << " : \t"
103                               << (int) (((uint16_t *)lut)[i])
104                               << std::endl;
105                }             
106             }
107          }  
108          else
109             std::cout << "No LUT Data DataEntry (0x0028,0x3006) found?!? " 
110                         << std::endl;
111       }
112       else
113          std::cout << "No First SQ Item within (0x0028,0x3000) ?!? " 
114                      << std::endl;      
115    }
116    else
117       std::cout << "No LUT Data SeqEntry (0x0028,0x3000) found " 
118                   << std::endl;
119 }
120
121 int main(int argc, char *argv[])
122 {
123
124    START_USAGE(usage)
125    " \n PrintFile : \n                                                        ",
126    " Display the header of a ACR-NEMA/PAPYRUS/DICOM File                      ",
127    " usage: PrintFile {filein=inputFileName|dirin=inputDirectoryName}[level=n]",
128    "                       [forceload=listOfElementsToForceLoad] [rec] [noex] ",
129    "                       [4DLoc= ][dict= privateDirectory]                  ",
130    "                       [ { [noshadowseq] | [noshadow][noseq] } ]          ",
131    "                       [debug] [warning]                                  ",
132    "      level = 0,1,2 : depending on the amount of details user wants to see",
133    "      rec : user wants to parse recursively the directory                 ",
134    "      noex : user doen't want extra 'user friendly' info                  ",   
135    "      4DLoc: group-elem(in hexa, no space) of the DataEntry holdind 4thDim",
136    "      listOfElementsToForceLoad : group-elem,g2-e2,... (in hexa, no space)",
137    "                                of Elements to load whatever their length ",
138    "      privateDirectory : source file full path name of Shadow Group elems ",
139    "      noshadowseq: user doesn't want to load Private Sequences            ",
140    "      noshadow   : user doesn't want to load Private groups (odd number)  ",
141    "      noseq      : user doesn't want to load Sequences                    ",
142    "      debug      : user wants to run the program in 'debug mode'          ",
143    "      warning    : user wants to be warned about any oddity in the File   ",
144    "      showlut :user wants to display the Palette Color (as an int array)  ",
145    FINISH_USAGE
146
147    // Initialize Arguments Manager   
148    GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
149   
150    if (argc == 1 || am->ArgMgrDefined("usage") )
151    {
152       am->ArgMgrUsage(usage); // Display 'usage'
153       delete am;
154       return 1;
155    }
156
157    const char *fileName = am->ArgMgrGetString("filein");
158    const char *dirName  = am->ArgMgrGetString("dirin");
159
160    if ( (fileName == 0 && dirName == 0) ||
161         (fileName != 0 && dirName != 0) )
162    {
163       std::cerr << std::endl
164         << "Either 'filein=' or 'dirin=' must be present;" 
165         << std::endl << "Not both" << std::endl;
166       am->ArgMgrUsage(usage); // Display 'usage'  
167       delete am;
168       return 1;
169    }   
170       
171    bool noex = ( 0 != am->ArgMgrDefined("noex") );
172    bool rec  = ( 0 != am->ArgMgrDefined("rec") );   
173         
174    if (am->ArgMgrDefined("debug"))
175       GDCM_NAME_SPACE::Debug::DebugOn();
176
177    if (am->ArgMgrDefined("warning"))
178       GDCM_NAME_SPACE::Debug::WarningOn();
179        
180    int loadMode = GDCM_NAME_SPACE::LD_ALL;
181    if ( am->ArgMgrDefined("noshadowseq") )
182       loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
183    else 
184    {
185       if ( am->ArgMgrDefined("noshadow") )
186          loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW;
187       if ( am->ArgMgrDefined("noseq") )
188          loadMode |= GDCM_NAME_SPACE::LD_NOSEQ;
189    }
190
191    int level = am->ArgMgrGetInt("level", 1);
192
193    int forceLoadNb;
194    uint16_t *elemsToForceLoad 
195                            = am->ArgMgrGetXInt16Enum("forceload", &forceLoadNb);
196    
197    int nbP =0;
198    uint16_t *FourthDimLoc;
199    if ( am->ArgMgrDefined("4DLoc") )
200    {
201       FourthDimLoc = am->ArgMgrGetXInt16Enum("4DLoc", &nbP);
202    
203       if (nbP != 1) 
204       {   
205          std::cout << "4DLoc must have 2 and only 2 components!" << std::endl;
206          delete am;
207          return 1;      
208       }
209    }
210
211    bool showlut = ( 0 != am->ArgMgrDefined("SHOWLUT") );
212
213    bool ddict = am->ArgMgrDefined("dict") ? true : false;
214    const char *dict = 0;
215
216    if (ddict)
217    {
218      dict = am->ArgMgrGetString("dict",0);
219    }
220
221    /* if unused Param we give up */
222    if ( am->ArgMgrPrintUnusedLabels() )
223    {
224       am->ArgMgrUsage(usage);
225       delete am;
226       return 1;
227    } 
228
229    delete am;  // we don't need Argument Manager any longer
230
231    // ----------- End Arguments Manager ---------
232
233  
234    if (ddict)
235    {
236       GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->AddDict(dict);   
237    }
238
239    if ( fileName != 0 ) // ====== Deal with a single file ======
240    { 
241       GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
242       f->SetLoadMode(loadMode);
243       f->SetFileName( fileName );
244
245       for (int ri=0; ri<forceLoadNb; ri++)
246       {
247          f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri], 
248                                 (uint32_t)elemsToForceLoad[2*ri+1] ); 
249       }
250 // TODO : find why such a polution
251 // To avoid polluting the output with messages 
252 // 'Last system error was : No such file or directory'
253
254 errno = 0; 
255
256
257       bool res = f->Load();
258       // GDCM_NAME_SPACE::File::IsReadable() is no usable here, because we deal with
259       // any kind of gdcm-Parsable *document* 
260       // not only GDCM_NAME_SPACE::File (as opposed to GDCM_NAME_SPACE::DicomDir)
261       if ( !res )
262       {
263          std::cout << "Cannot process file [" << fileName << "]" << std::endl;
264          std::cout << "Either it doesn't exist, or it's read protected " 
265                    << std::endl;
266          std::cout << "or it's not a Dicom File, or its 'header' is bugged" 
267                    << std::endl;
268          std::cout << "use 'PrintFile filein=... debug' to try to guess the pb"
269                    << std::endl;
270          f->Delete();
271          return 0;
272       }
273       
274       if (nbP == 1)
275          f->SetFourthDimensionLocation(FourthDimLoc[0],FourthDimLoc[1]);
276
277
278       GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
279       fh->SetPrintLevel( level );
280
281       fh->Print();
282
283       std::cout << "\n\n" << std::endl; 
284
285       std::cout <<std::endl;
286       std::cout <<" dataSize    " << fh->GetImageDataSize()    << std::endl;
287       std::cout <<" dataSizeRaw " << fh->GetImageDataRawSize() << std::endl;
288 if (!noex)
289 {
290       int nX,nY,nZ,nT,sPP,planarConfig;
291       std::string pixelType;
292       nX=f->GetXSize();
293       nY=f->GetYSize();
294       nZ=f->GetZSize();
295       nT=f->GetTSize();
296       std::cout << " DIMX=" << nX << " DIMY=" << nY 
297                 << " DIMZ=" << nZ << " DIMT=" << nT
298                 << std::endl;
299
300       pixelType    = f->GetPixelType();
301       sPP          = f->GetSamplesPerPixel();
302       std::cout << " pixelType= ["            << pixelType 
303                 << "] SamplesPerPixel= ["     << sPP
304                 << "] ";
305
306       if (sPP == 3)
307       {
308          planarConfig = f->GetPlanarConfiguration();
309          std::cout << " PlanarConfiguration= [" << planarConfig 
310                 << "] "<< std::endl;
311       } 
312       std::cout << " PhotometricInterpretation= [" 
313                 << f->GetEntryString(0x0028,0x0004)
314                 << "] "<< std::endl;
315
316       int numberOfScalarComponents=f->GetNumberOfScalarComponents();
317       std::cout << " NumberOfScalarComponents = " << numberOfScalarComponents 
318                 <<std::endl
319                 << " LUT = " << (f->HasLUT() ? "TRUE" : "FALSE")
320                 << std::endl;
321
322       if ( f->GetDataEntry(0x0002,0x0010) )
323          if ( f->GetDataEntry(0x0002,0x0010)->IsNotLoaded() ) 
324          {
325             std::cout << "Transfer Syntax not loaded. " << std::endl
326                      << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
327                   << std::endl;
328             f->Delete();
329             return 0;
330          }
331   
332       std::string transferSyntaxName = f->GetTransferSyntaxName();
333       std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" 
334                 << std::endl;
335       std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
336       std::cout << " ------" << std::endl;
337
338       std::cout << "\n\n" << std::endl; 
339       std::cout << "X spacing " << f->GetXSpacing() << std::endl;
340       std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
341       std::cout << "Z spacing " << f->GetZSpacing() << std::endl;
342     
343 //------------------------------
344
345       // Let's get and print some usefull fields about 'Orientation'
346       // ------------------------------------------------------------
347
348       std::string strPatientPosition = 
349                                       f->GetEntryString(0x0018,0x5100);
350       if ( strPatientPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
351         && strPatientPosition != "" )  
352             std::cout << "PatientPosition (0x0010,0x5100)= [" 
353                       << strPatientPosition << "]" << std::endl;
354  
355       std::string strViewPosition = 
356                                       f->GetEntryString(0x0018,0x5101);
357       if ( strViewPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
358         && strViewPosition != "" )  
359             std::cout << "View Position (0x0018,0x5101)= [" 
360                       << strViewPosition << "]" << std::endl;
361       
362      std::string strPatientOrientation = 
363                                       f->GetEntryString(0x0020,0x0020);
364       if ( strPatientOrientation != GDCM_NAME_SPACE::GDCM_UNFOUND
365         && strPatientOrientation != "")  
366          std::cout << "PatientOrientation (0x0020,0x0020)= [" 
367                    << strPatientOrientation << "]" << std::endl;
368
369       std::string strImageOrientationPatient = 
370                                       f->GetEntryString(0x0020,0x0037);  
371       if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND
372         && strImageOrientationPatient != "" )  
373          std::cout << "ImageOrientationPatient (0x0020,0x0037)= [" 
374                    << strImageOrientationPatient << "]" << std::endl;
375
376       std::string strImageOrientationRET = 
377                                       f->GetEntryString(0x0020,0x0035);
378       if ( strImageOrientationRET != GDCM_NAME_SPACE::GDCM_UNFOUND
379         && strImageOrientationRET != "" )  
380          std::cout << "ImageOrientationRET (0x0020,0x0035)= [" 
381                    << strImageOrientationRET << "]" << std::endl;
382
383       std::string strImagePositionPatient = 
384                                       f->GetEntryString(0x0020,0x0032);  
385       if ( strImagePositionPatient != GDCM_NAME_SPACE::GDCM_UNFOUND
386         && strImagePositionPatient != "" )  
387          std::cout << "ImagePositionPatient (0x0020,0x0032)= [" 
388                    << strImagePositionPatient << "]" << std::endl;
389
390       std::string strImagePositionPatientRET = 
391                                       f->GetEntryString(0x0020,0x0030);
392       if ( strImagePositionPatientRET != GDCM_NAME_SPACE::GDCM_UNFOUND
393         && strImagePositionPatientRET != "" )  
394          std::cout << "ImagePositionPatientRET (0x0020,0x0030)= [" 
395                    << strImagePositionPatientRET << "]" << std::endl;
396   
397      float iop[6];
398      /*bool riop = */f->GetImageOrientationPatient(iop);  
399      float ipp[3];
400      /*bool ripp = */f->GetImagePositionPatient(ipp);
401
402      std::cout << "Image Position (0x0020,0x0032|0x0030) : "
403                << ipp[0] << " , " << ipp[1] << " , "<< ipp[2]
404                << std::endl;
405      std::cout << "Image Orientation (0x0020,0x0037|0x0035) : "
406                << iop[0] << " , " << iop[1] << " , "<< iop[2] << " , "
407                << iop[3] << " , " << iop[4] << " , "<< iop[5]
408                << std::endl; 
409
410
411       // Let's compute 'user friendly' results about 'Orientation'
412       // ---------------------------------------------------------
413  
414       GDCM_NAME_SPACE::Orientation *o = GDCM_NAME_SPACE::Orientation::New();
415
416       if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND ||
417            strImageOrientationRET     != GDCM_NAME_SPACE::GDCM_UNFOUND )
418       {
419   
420          GDCM_NAME_SPACE::OrientationType orient = o->GetOrientationType( f );
421  
422          std::cout << "TypeOrientation = " << orient << " (-> " 
423                    << o->GetOrientationTypeString(orient) << " )" << std::endl;
424       }
425
426       std::string ori = o->GetOrientation ( f );
427       if (ori != "\\" )
428          std::cout << "Orientation [" << ori << "]" << std::endl;
429       o->Delete();
430 }  
431 //------------------------------
432
433
434       // Display the LUT as an int array (for debugging purpose)
435       if ( f->HasLUT() && showlut )
436       {
437          uint8_t* lutrgba = fh->GetLutRGBA();
438          if ( lutrgba == 0 )
439          {
440             std::cout << "Lut RGBA (Palette Color) not built " << std::endl;
441  
442            // Nothing is written yet to get LUT Data user friendly
443            // The following is to be moved into a PixelRedaConvert method
444   
445             GDCM_NAME_SPACE::SeqEntry *modLutSeq = f->GetSeqEntry(0x0028,0x3000);
446             if ( modLutSeq !=0 )
447             {
448                GDCM_NAME_SPACE::SQItem *sqi= modLutSeq->GetFirstSQItem();
449                if ( !sqi )
450                {
451                   std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
452                   int length;   // LUT length in Bytes
453                   int deb;      // Subscript of the first Lut Value
454                   int nbits;    // Lut item size (in Bits)
455                   int nbRead;   // nb of items in LUT descriptor (must be = 3)
456
457                   nbRead = sscanf( lutDescriptor.c_str(),
458                                     "%d\\%d\\%d",
459                                      &length, &deb, &nbits );
460                   if ( nbRead != 3 )
461                   {
462                       std::cout << "Wrong LUT descriptor" << std::endl;
463                   }                                                  
464                   GDCM_NAME_SPACE::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006);
465                   if ( b != 0 )
466                   {
467                      if ( b->GetLength() != 0 )
468                      {
469                         std::cout << "---------------------------------------"
470                                << " We should never reach this point      "
471                                << std::endl;
472                         //LoadEntryBinArea(b);    //LUT Data (CTX dependent)
473                      }   
474                  }
475               }      
476             }
477             else
478                std::cout << "No LUT Data (0x0028,0x3000) found " << std::endl;
479         }
480          else
481          {
482             if ( fh->GetLutItemSize() == 8 )
483             {
484                for (int i=0;i<fh->GetLutItemNumber();i++)
485                   std::cout << i << " : \t"
486                          << (int)(lutrgba[i*4])   << " "
487                          << (int)(lutrgba[i*4+1]) << " "
488                          << (int)(lutrgba[i*4+2]) << std::endl;
489             }
490             else // LutItemSize assumed to be = 16
491             {
492                uint16_t* lutrgba16 = (uint16_t*)lutrgba;
493                for (int i=0;i<fh->GetLutItemNumber();i++)
494                   std::cout << i << " : \t"
495                          << (int)(lutrgba16[i*4])   << " "
496                          << (int)(lutrgba16[i*4+1]) << " "
497                          << (int)(lutrgba16[i*4+2]) << std::endl;
498             }
499          }
500       }
501       else if (showlut)
502       {
503          std::cout << "Try LUT Data "<< std::endl;
504          ShowLutData(f);
505       }
506
507       // Parsability of the GDCM_NAME_SPACE::Document already checked, after Load() !
508       
509       if ( f->IsReadable() )
510       {
511          std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
512       }
513       else if ( f->GetSeqEntry(0x0041,0x1010) )
514       {
515          std::cout <<std::endl<<fileName<<" looks like a 'PAPYRUS image' file"
516                    <<std::endl;
517       }
518       else if ( f->GetSeqEntry(0x0004,0x1220) )
519       {
520          std::cout <<std::endl<<fileName<<" looks like a 'DICOMDIR file'"
521                    <<std::endl;
522       }
523       else 
524       {
525          std::cout <<std::endl<<fileName<<" doesn't look like an image file "
526              <<std::endl; 
527       }
528  
529       std::cout<<std::flush;
530       f->Delete();
531       fh->Delete();
532    }
533    else  // ====== Deal with a Directory ======
534    {
535       std::cout << "dirName [" << dirName << "]" << std::endl;
536       
537       GDCM_NAME_SPACE::DirList dirList(dirName,rec); // gets recursively (or not) the file list
538       GDCM_NAME_SPACE::DirListType fileList = dirList.GetFilenames();
539       GDCM_NAME_SPACE::File *f;
540       bool res;
541
542       for( GDCM_NAME_SPACE::DirListType::iterator it  = fileList.begin();
543                                  it != fileList.end();
544                                  ++it )
545       {
546          std::cout << std::endl<<" Start processing :[" << it->c_str() << "]"
547                    << std::endl;
548          f = GDCM_NAME_SPACE::File::New();
549          f->SetLoadMode(loadMode);
550          f->SetFileName( it->c_str() );
551
552          for (int ri=0; ri<forceLoadNb; ri++)
553          {
554             printf("%04x,%04x\n",elemsToForceLoad[2*ri], 
555                                  elemsToForceLoad[2*ri+1]);
556             f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri], 
557                                    (uint32_t)elemsToForceLoad[2*ri+1]); 
558          }
559          res = f->Load();
560
561          if ( !res )
562          {
563             std::cout << "Cannot process file [" << it->c_str() << "]" 
564                       << std::endl;
565             std::cout << "Either it doesn't exist, or it's read protected " 
566                       << std::endl;
567             std::cout << "or it's not a Dicom File, or its 'header' is bugged" 
568                       << std::endl;
569             std::cout << "use 'PrintFile filein=... debug' "
570                       << "to try to guess the pb"
571                       << std::endl;
572             f->Delete();
573             continue;
574          }
575
576          GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
577          fh->SetPrintLevel( level );
578          fh->Print();
579
580 //------------------------------
581 if (!noex)
582 {
583          // Lets's get and print some usefull fields about 'Orientation'
584          // ------------------------------------------------------------
585
586          std::string strPatientPosition = 
587                                        f->GetEntryString(0x0018,0x5100);
588          if ( strPatientPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
589          && strPatientPosition != "" )  
590                std::cout << "PatientPosition (0x0010,0x5100)= [" 
591                         << strPatientPosition << "]" << std::endl;
592     
593          std::string strViewPosition = 
594                                        f->GetEntryString(0x0018,0x5101);
595          if ( strViewPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
596          && strViewPosition != "" )  
597                std::cout << "strViewPosition (0x0010,0x5101)= [" 
598                         << strViewPosition << "]" << std::endl;
599          
600          std::string strPatientOrientation = 
601                                        f->GetEntryString(0x0020,0x0020);
602          if ( strPatientOrientation != GDCM_NAME_SPACE::GDCM_UNFOUND
603          && strPatientOrientation != "")  
604             std::cout << "PatientOrientation (0x0020,0x0020)= [" 
605                       << strPatientOrientation << "]" << std::endl;
606
607          std::string strImageOrientationPatient = 
608                                        f->GetEntryString(0x0020,0x0037);  
609          if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND
610          && strImageOrientationPatient != "" )  
611             std::cout << "ImageOrientationPatient (0x0020,0x0037)= [" 
612                      << strImageOrientationPatient << "]" << std::endl;
613
614          std::string strImageOrientationRET = 
615                                        f->GetEntryString(0x0020,0x0035);
616          if ( strImageOrientationRET != GDCM_NAME_SPACE::GDCM_UNFOUND
617          && strImageOrientationRET != "" )
618          {
619             std::cout << "ImageOrientationRET (0x0020,0x0035)= [" 
620                      << strImageOrientationRET << "]" << std::endl;
621          }
622
623          // Let's compute 'user friendly' results about 'Orientation'
624          // ---------------------------------------------------------
625     
626          GDCM_NAME_SPACE::Orientation *o = GDCM_NAME_SPACE::Orientation::New(); 
627
628
629          if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND ||
630             strImageOrientationRET     != GDCM_NAME_SPACE::GDCM_UNFOUND )
631          {
632      
633             GDCM_NAME_SPACE::OrientationType orient = o->GetOrientationType( f );
634     
635             std::cout << "TypeOrientation = " << orient << " (-> " 
636                      << o->GetOrientationTypeString(orient) << " )" << std::endl;
637          }
638
639          std::string ori = o->GetOrientation ( f );
640          if (ori != "\\" )
641             std::cout << "Orientation [" << ori << "]" << std::endl;
642          o->Delete(); 
643 }
644 //------------------------------- 
645         
646          if (f->IsReadable())
647             std::cout <<std::endl<<it->c_str()<<" is Readable"<<std::endl;
648          else
649             std::cout <<std::endl<<it->c_str()<<" is NOT Readable"<<std::endl;
650          std::cout << "\n\n" << std::endl;
651          f->Delete();
652          fh->Delete();
653       }
654       std::cout<<std::flush;
655    }
656    return 0;
657 }