3 from gdcmConfigDemo import *
4 from gdcmPython.core import *
10 print "%s <dicomDir>" % sys.argv[0]
11 print " dicomDir : path to the DICOMDIR to parse"
15 ### Get filename from command line or default it
17 fileName = sys.argv[1]
19 fileName = os.path.join(GDCM_DATA_ROOT, "DICOMDIR")
20 if( not os.path.isfile(fileName) ):
21 fileName=os.path.join(os.path.split(sys.argv[0])[0],"DICOMDIR")
24 printLevel = int(sys.argv[2])
28 ### Build the DicomDir element list
29 dicomdir = gdcm.DicomDir(fileName)
30 if not dicomdir.IsReadable():
32 raise RuntimeError,"The '%s' DicomDir is not readable with gdcm." % fileName
34 print "DICOMDIR -->",fileName
35 print "##############################################################"
36 print "## Display all the elements and their respective values"
37 print "## found in the ", fileName, " file."
38 print "##############################################################"
39 dicomdir.SetPrintLevel(-1)
43 patient=dicomdir.GetFirstPatient()
46 study=patient.GetFirstStudy()
49 serie=study.GetFirstSerie()
52 image=serie.GetFirstImage()
55 print " ---",image.GetValEntry(0x0004,0x1500).GetValue()
56 image=serie.GetNextImage()
57 serie=study.GetNextSerie()
58 study=patient.GetNextStudy()
59 patient=dicomdir.GetNextPatient()