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"
17 print gdcm.DataEntryPtr
21 ### Get filename from command line or default it
23 fileName = sys.argv[1]
25 fileName = os.path.join(GDCM_DATA_ROOT, "test.acr")
26 if( not os.path.isfile(fileName) ):
27 fileName=os.path.join(os.path.split(sys.argv[0])[0],"test.acr")
30 printLevel = int(sys.argv[2])
34 ### Build the file element list
35 file = gdcm.File.New()
36 file.SetFileName(fileName)
38 if not file.IsReadable():
40 raise RuntimeError,"The '%s' file is not readable with gdcm." % fileName
42 print "File -->",fileName
43 print "##############################################################"
44 print "### Display all the elements and their respective values"
45 print "## found in the ", fileName, " file."
46 print "##############################################################"
48 val=file.GetFirstEntry()
52 val=file.GetNextEntry()
55 print "##############################################################"
56 val=file.GetFirstEntry()
58 if(isinstance(val,gdcm.DataEntry)):
59 print "Data %s [%s] [%s] : %s" % (val.GetKey().str(),val.GetVR().str(),
60 val.GetName(),val.GetString())
61 val=file.GetNextEntry()