]> Creatis software - gdcm.git/blob - gdcmPython/demo/explore.py
* Corrected a leak, the pSource was find thanks to valgrind. valgrind rules !
[gdcm.git] / gdcmPython / demo / explore.py
1 from gdcmPython import *
2
3 ### Get filename from command line or default it
4 try:
5    FileName = sys.argv[1]
6 except IndexError:
7    FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
8
9 if not os.path.isfile(FileName):
10    print "Cannot open file ", FileName
11    sys.exit()
12
13 toRead = gdcmHeader(FileName)
14 ValDict = toRead.GetPubElVal()
15 ExploreElements = ["Patient Name", "Patient ID",
16                                                  "Study Date", "Study Time", "Study ID",
17                                                  "Study Instance UID",
18                                                  "Series Number",
19                                                  "Modality"]
20
21 for elem in ExploreElements:
22         print "[%s] = " % elem,
23         try:
24                 print "[%s]" % ValDict[elem]
25         except KeyError:
26                 print "NOT FOUND"