3 from gdcmConfigDemo import *
4 from gdcmPython.core import *
10 print "%s" % sys.argv[0]
11 print " Create the DicomDir from the GDCM_DATA_ROOT path"
19 print "Progress",dicomdir.GetProgress()
23 ### Get filename from command line or default it
25 fileName = sys.argv[1]
27 fileName = os.path.join(GDCM_DATA_ROOT, "DICOMDIR")
28 if( not os.path.isfile(fileName) ):
29 fileName=os.path.join(os.path.split(sys.argv[0])[0],"DICOMDIR")
32 printLevel = int(sys.argv[2])
36 ### Build the DicomDir element list
37 dicomdir = gdcm.DicomDir.New()
39 cmd=gdcm.CommandPy.New()
40 cmd.SetCallback(startMethod)
41 gdcm.CommandManager.SetCommand(dicomdir,gdcm.CMD_STARTPROGRESS,cmd)
42 cmd=gdcm.CommandPy.New()
43 cmd.SetCallback(endMethod)
44 gdcm.CommandManager.SetCommand(dicomdir,gdcm.CMD_ENDPROGRESS,cmd)
45 cmd=gdcm.CommandPy.New()
46 cmd.SetCallback(progressMethod)
47 gdcm.CommandManager.SetCommand(dicomdir,gdcm.CMD_PROGRESS,cmd)
49 dicomdir.SetDirectoryName(GDCM_DATA_ROOT)
51 if not dicomdir.IsReadable():
53 raise RuntimeError,"The '%s' DicomDir is not readable with gdcm." % fileName
55 print "DICOMDIR -->",fileName
56 print "##############################################################"
57 print "## Display all the elements and their respective values"
58 print "## found in the ", fileName, " file."
59 print "##############################################################"
60 dicomdir.SetPrintLevel(-1)