3 from gdcmConfigDemo import *
4 from gdcmPython.core import *
10 print "%s <fileName>" % sys.argv[0]
11 print " fileName : path to the DICOM file to parse"
15 ### Get filename from command line or default it
17 fileName = sys.argv[1]
19 fileName = os.path.join(GDCM_DATA_ROOT, "test.acr")
20 if( not os.path.isfile(fileName) ):
21 fileName=os.path.join(os.path.split(sys.argv[0])[0],"test.acr")
24 printLevel = int(sys.argv[2])
28 ### Build the file element list
30 file.SetFileName(fileName)
32 if not file.IsReadable():
34 raise RuntimeError,"The '%s' file is not readable with gdcm." % fileName
36 print "File -->",fileName
37 print "##############################################################"
38 print "### Display all the elements and their respective values"
39 print "## found in the ", fileName, " file."
40 print "##############################################################"
42 val=file.GetFirstEntry()
46 val=file.GetNextEntry()
49 print "##############################################################"
50 val=file.GetFirstEntry()
52 if(isinstance(val,gdcm.ValEntryPtr)):
53 print "Val %04d|%04d [%s] : %s" % (val.GetGroup(),val.GetElement(),
54 val.GetName(),val.GetValue())
56 print "Bin %04d|%04d [%s] : %s" % (val.GetGroup(),val.GetElement(),
57 val.GetName(),val.GetValue())
58 val=file.GetNextEntry()