-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",
print "[%s]" % ValDict[elem]
except KeyError:
print "NOT FOUND"
+