3 from gdcmPython import *
5 from libvtkgdcmPython import *
7 from vtkgdcmPython import *
9 class gdcmTestCase(unittest.TestCase):
10 # The files whose name starts with a modality (e.g. CR-MONO1-10-chest.dcm)
11 # come from Sebastien Barre's Dicom2 highly recommendable site
12 # http://www.barre.nom.fr/medical/samples/index.html
17 # FOLLOWING FILE NOT IN GDCMDATA ANYMORE !?!?!?!
18 ["gdcm-MR-PHILIPS-16.dcm",
19 # Interest: - possesses a sequence
20 # - dicom file, with a recognition code of ACR-NEMA1
21 [ ["Transfer Syntax UID", "1.2.840.10008.1.2"], # Implicit VR, LE
22 ["Recognition Code (RET)", "ACR-NEMA 1.0"],
24 ["Photometric Interpretation", "MONOCHROME2"],
28 ["Bits Allocated", "16"],
30 ["Pixel Representation", "0"],
31 ["Manufacturer", "Philips Medical Systems"],
32 ["Manufacturer's Model Name", "Gyroscan Intera"],
33 ["Sequence Variant", "OTHER"],
34 ["Pixel Data", "gdcm::NotLoaded. Address:6584 Length:131072 x(20000)"]
38 def _BaseTest(self, FileSet):
40 fileName = os.path.join(GDCM_TEST_DATA_PATH, entry[0])
41 reader = gdcmFile(fileName)
42 assert reader.IsReadable(),\
43 "File '%s' is not readable by gdcmFile" % fileName
45 valDict = reader.GetEntryValue()
46 for subEntry in entry[1]:
49 self.assertEqual(valDict[element], value,
50 ("Wrong %s for file %s (got %s, shoud be %s)"
51 % (element,fileName, valDict[element], value)) )
54 gdcmTestCase._BaseTest(self, gdcmTestCase.GdcmFiles)
56 if __name__ == '__main__':
57 if not GDCM_TEST_DATA_PATH:
58 print "GDCM_TEST_DATA_PATH (internal variable) is not setup properly."
59 print " This test suite requires that some Dicom reference files be "
61 print " For further details on installation of gdcmData, please"
62 print " refer to the developper's section of page "
63 print " http://www.creatis.insa-lyon.fr/Public/Gdcm"
65 print "gdcmData directory (used in the test suite) must be placed in"
66 print "the gdcm directory. The gdcm tree must be :"
70 print " |____gdcmData (not in gdcm by default)"
71 print " |____gdcmPython"