X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=gdcmPython%2Fdemo%2Fexplore.py;h=a72c79cde38cadd080e2bca7744ec542a79ebf4a;hb=8d10ccb6794a0f22234983990e2181a24625fbd8;hp=c11a9aebb94d87ca1e7b41d4972ae0ae28c7d6c5;hpb=9676e37a52824da2f69d22c721178a4b5dc12191;p=gdcm.git diff --git a/gdcmPython/demo/explore.py b/gdcmPython/demo/explore.py index c11a9aeb..a72c79cd 100644 --- a/gdcmPython/demo/explore.py +++ b/gdcmPython/demo/explore.py @@ -1,14 +1,22 @@ -from load import * +from gdcmPython import * -########## Real usage of Pygdcm starts here -toRead = gdcm.gdcmHeader(FileName) -toRead.LoadElements() -ValDict = toRead.GetPubElVal() -ExploreElements = ["Patient Name", "Patient ID", - "Study Date", "Study Time", "Study ID", - "Study Instance UID", - "Series Number", - "Modality"] +### 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.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, @@ -16,3 +24,4 @@ for elem in ExploreElements: print "[%s]" % ValDict[elem] except KeyError: print "NOT FOUND" +