]> Creatis software - gdcm.git/blob - gdcmPython/demo/explore.py
* Eventually, python/gdcmPython was renamed to gdcmPython. This
[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 toRead.LoadElements()
15 ValDict = toRead.GetPubElVal()
16 ExploreElements = ["Patient Name", "Patient ID",
17                                                  "Study Date", "Study Time", "Study ID",
18                                                  "Study Instance UID",
19                                                  "Series Number",
20                                                  "Modality"]
21
22 for elem in ExploreElements:
23         print "[%s] = " % elem,
24         try:
25                 print "[%s]" % ValDict[elem]
26         except KeyError:
27                 print "NOT FOUND"