]> Creatis software - gdcm.git/blob - gdcmPython/demo/makeDicomDir.py
ENH: as frog mention there were images that could be read, but still blacklisted
[gdcm.git] / gdcmPython / demo / makeDicomDir.py
1 from gdcmPython import *
2 import sys
3
4 ### Get filename from command line or default it
5 try:
6    FileName = sys.argv[1]
7 except IndexError:
8    FileName = os.path.join(GDCM_DATA_PATH, "DICOMDIR")
9
10 try:
11    printLevel = int(sys.argv[2])
12 except IndexError:
13    printLevel = 1
14 print FileName
15
16 ### Build the header element list
17 toRead = gdcmDicomDir(FileName)
18
19 def startMethod():
20         print "Python start"
21
22 def endMethod():
23         print "Python end"
24
25 def progressMethod():
26         print "Python progress",toRead.GetProgress()
27
28 toRead.SetStartMethod(None)
29 toRead.SetProgressMethod(progressMethod)
30 toRead.SetEndMethod(endMethod)
31 toRead.ParseDirectory()
32
33 print "##############################################################"
34 print "### Display all the elements and their respective values"
35 print "## found in the ", FileName, " file."
36 print "##############################################################"
37 toRead.SetPrintLevel(-1)
38 toRead.Print()
39
40 ValDict = toRead.GetEntry()
41 for key in ValDict.keys():
42         print "[%s] = [%s]" %(key, ValDict[key])
43