2 from gdcmConfigDemo import *
3 from gdcmPython.core import *
9 print "%s <fileName>" % sys.argv[0]
10 print " fileName : path to the DICOM file to parse"
14 ### Get filename from command line or default it
16 fileName = sys.argv[1]
18 fileName = os.path.join(GDCM_DATA_ROOT, "test.acr")
21 printLevel = int(sys.argv[2])
25 ### Build the file element list
26 file = gdcm.File(fileName)
27 if not file.IsReadable():
29 raise RuntimeError,"The '%s' file is not readable with gdcm." % fileName
31 print "File -->",fileName
32 print "##############################################################"
33 print "### Display all the elements and their respective values"
34 print "## found in the ", fileName, " file."
35 print "##############################################################"
37 val=file.GetFirstEntry()
41 val=file.GetNextEntry()
44 print "##############################################################"
45 val=file.GetFirstEntry()
47 if(isinstance(val,gdcm.ValEntryPtr)):
48 print "Val %04d|%04d [%s] : %s" % (val.GetGroup(),val.GetElement(),
49 val.GetName(),val.GetValue())
51 print "Bin %04d|%04d [%s] : %s" % (val.GetGroup(),val.GetElement(),
52 val.GetName(),val.GetValue())
53 val=file.GetNextEntry()