From: regrain Date: Wed, 8 Jun 2005 09:04:22 +0000 (+0000) Subject: * Remove all old python demo using an older gdcm version X-Git-Tag: Version1.2.bp~573 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=04f3bbda36168ed865e04de8b94d2c60206f962a;p=gdcm.git * Remove all old python demo using an older gdcm version -- BeNours --- diff --git a/gdcmPython/demo/ReorganiseFiles.py b/gdcmPython/demo/ReorganiseFiles.py deleted file mode 100644 index 3db13f4d..00000000 --- a/gdcmPython/demo/ReorganiseFiles.py +++ /dev/null @@ -1,57 +0,0 @@ -# Rename the dcm extension files of a given directory according -# to series and image number information extracted in each respective header. - -from gdcmPython import * -import glob -import os -import sys - -def PrintUsage(): - print "Usage: python ReorganiseFiles.py " - print " is the directory containing the source" - print " images (defaulted to invocation directory." - -def Warning(DirName): - print "Warning: this script will rename files in the" - print " ", DirName, " directory." - a = raw_input("Proceed ?[y/n]") - if a != "y": - sys.exit() - -try: - SourceDirectory = sys.argv[1] -except IndexError: - SourceDirectory = os.getcwd() - -if not os.path.isdir(SourceDirectory): - PrintUsage -Warning(SourceDirectory) -SourceFiles=glob.glob(os.path.join(SourceDirectory, "*.dcm")) - -for file in SourceFiles: - header = gdcmHeader(file) - info = header.GetEntry() - try: - ImNum = info["Image Number"] - if len(ImNum) == 0 or ImNum == "gdcm::Unfound": - raise KeyError - except KeyError: - print "Skipped file ", file, " (unfound Image Number tag)." - continue - try: - SeNum = info["Series Number"] - if len(SeNum) == 0 or SeNum == "gdcm::Unfound": - raise KeyError - except KeyError: - print "Skipped file ", file, " (unfound Series Number tag)." - continue - DestFile = "image_%02d_%04d.dcm" - DestFile %= (int(info["Image Number"]), int(info["Series Number"])) - DestFile = os.path.join(SourceDirectory, DestFile) - # necessary to close the file descriptor to enable further rename. - del header - if os.path.isfile(DestFile): - print "Skipped file ", file, " (allready existing destination" - print " file ", DestFile - continue - os.rename(file, DestFile) diff --git a/gdcmPython/demo/explore.py b/gdcmPython/demo/explore.py deleted file mode 100644 index a72c79cd..00000000 --- a/gdcmPython/demo/explore.py +++ /dev/null @@ -1,27 +0,0 @@ -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) -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, - try: - print "[%s]" % ValDict[elem] - except KeyError: - print "NOT FOUND" - diff --git a/gdcmPython/demo/makeDicomDir.py b/gdcmPython/demo/makeDicomDir.py deleted file mode 100644 index 869441fb..00000000 --- a/gdcmPython/demo/makeDicomDir.py +++ /dev/null @@ -1,43 +0,0 @@ -from gdcmPython import * -import sys - -### Get filename from command line or default it -try: - FileName = sys.argv[1] -except IndexError: - FileName = os.path.join(GDCM_DATA_PATH, "DICOMDIR") - -try: - printLevel = int(sys.argv[2]) -except IndexError: - printLevel = 1 -print FileName - -### Build the header element list -toRead = gdcmDicomDir(FileName) - -def startMethod(): - print "Python start" - -def endMethod(): - print "Python end" - -def progressMethod(): - print "Python progress",toRead.GetProgress() - -toRead.SetStartMethod(None) -toRead.SetProgressMethod(progressMethod) -toRead.SetEndMethod(endMethod) -toRead.ParseDirectory() - -print "##############################################################" -print "### Display all the elements and their respective values" -print "## found in the ", FileName, " file." -print "##############################################################" -toRead.SetPrintLevel(-1) -toRead.Print() - -ValDict = toRead.GetEntry() -for key in ValDict.keys(): - print "[%s] = [%s]" %(key, ValDict[key]) - diff --git a/gdcmPython/demo/printGroupedPublicDict.py b/gdcmPython/demo/printGroupedPublicDict.py deleted file mode 100644 index fa03c30f..00000000 --- a/gdcmPython/demo/printGroupedPublicDict.py +++ /dev/null @@ -1,21 +0,0 @@ -from gdcmPython import * - -print "##############################################################" -print "### Display all the possible tags of the current public" -print "### dictionary" -print "##############################################################" -PubList = GetPubDictEntryNames() -for i in range(0, len(PubList)): - print " ", PubList[i] - -print "##############################################################" -print "### Display all the possible tags of the current public" -print "### dictionary, but grouped by using the Fourth field" -print "##############################################################" -print " WARNING : the 'fourth' fiels IS NOT part of DICOM" -print " DO NOT use it" -PubDict = GetPubDictEntryNamesByCategory() -for fourth in PubDict: - print " ############ Fourth group = ", fourth, " ##############" - for key in PubDict[fourth]: - print " ", key diff --git a/gdcmPython/demo/testAll.py b/gdcmPython/demo/testAll.py deleted file mode 100644 index f210f8db..00000000 --- a/gdcmPython/demo/testAll.py +++ /dev/null @@ -1,38 +0,0 @@ -import glob, os -import sys -from gdcmPython import * - -# Test each file of the Data directory - -AllFiles = [ - "CR-MONO1-10-chest.dcm", - "CT-MONO2-16-brain.dcm", - "CT-MONO2-16-ort.dcm", - "CT-MONO2-16-ankle.dcm", - "CT-MONO2-8-abdo.dcm", - "CT-MONO2-12-lomb-an2.acr2", - "CT-MONO2-16-chest.dcm", - "MR-MONO2-12-angio-an1.acr1", - "MR-MONO2-12-an2.acr2", - "MR-MONO2-16-head.dcm", - "MR-MONO2-12-shoulder.dcm", - "OT-PAL-8-face.dcm", - "OT-MONO2-8-a7.dcm", - "US-RGB-8-esopecho.dcm", - "US-RGB-8-epicard.dcm", - "MR-MONO2-8-16x-heart.dcm", - "NM-MONO2-16-13x-heart.dcm", - "US-MONO2-8-8x-execho.dcm", - "US-PAL-8-10x-echo.dcm", - "XA-MONO2-8-12x-catheter.dcm", - ] - -if __name__ == '__main__': - # AllFiles = glob.glob(os.path.join(GDCM_TEST_DATA_PATH,"*.dcm")) - for file in AllFiles: - fileName = os.path.join(GDCM_TEST_DATA_PATH, file) - print "############## file :", fileName - toRead = gdcmHeader(fileName) - ValDict = toRead.GetEntry() - for key in ValDict.keys(): - print " [%s] = [%s]" %(key, ValDict[key])