]> Creatis software - gdcm.git/blobdiff - gdcmPython/demo/explore.py
* src/gdcmFile.h : bug fix. Variable type and variable name had same name
[gdcm.git] / gdcmPython / demo / explore.py
index 6ca9200be32d111c1b2dde158260de110064994a..a72c79cde38cadd080e2bca7744ec542a79ebf4a 100644 (file)
@@ -1,13 +1,22 @@
 from gdcmPython import *
 
+### Get filename from command line or default it
+try:
+   FileName = sys.argv[1]
+except IndexError:
+   FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
+
+if not os.path.isfile(FileName):
+   print "Cannot open file ", FileName
+   sys.exit()
+
 toRead = gdcmHeader(FileName)
-toRead.LoadElements()
-ValDict = toRead.GetPubElVal()
-ExploreElements = ["Patient Name", "Patient ID",
-                                                "Study Date", "Study Time", "Study ID",
-                                                "Study Instance UID",
-                                                "Series Number",
-                                                "Modality"]
+ValDict = toRead.GetEntry()
+ExploreElements = ["Patient's Name", "Patient ID",
+                   "Study Date", "Study Time", "Study ID",
+                   "Study Instance UID",
+                   "Series Number",
+                   "Modality"]
 
 for elem in ExploreElements:
        print "[%s] = " % elem,
@@ -15,3 +24,4 @@ for elem in ExploreElements:
                print "[%s]" % ValDict[elem]
        except KeyError:
                print "NOT FOUND"
+