]> Creatis software - gdcm.git/blobdiff - gdcmPython/demo/explore.py
* gdcmPython/demo/*.py : bug fix due to method names
[gdcm.git] / gdcmPython / demo / explore.py
index c11a9aebb94d87ca1e7b41d4972ae0ae28c7d6c5..defb226b2a72ab3aac6706491ad0f3e2c4d36643 100644 (file)
@@ -1,9 +1,17 @@
-from load import *
+from gdcmPython import *
 
-########## Real usage of Pygdcm starts here
-toRead = gdcm.gdcmHeader(FileName)
-toRead.LoadElements()
-ValDict = toRead.GetPubElVal()
+### 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)
+ValDict = toRead.GetPubEntry()
 ExploreElements = ["Patient Name", "Patient ID",
                                                 "Study Date", "Study Time", "Study ID",
                                                 "Study Instance UID",
@@ -16,3 +24,4 @@ for elem in ExploreElements:
                print "[%s]" % ValDict[elem]
        except KeyError:
                print "NOT FOUND"
+