Mercurial > hg > orthanc-tests
changeset 543:8722f7f95a38
fix
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 20 Jun 2023 17:24:56 +0200 |
parents | 3f8eebe85c37 |
children | 47c43fdaf91d |
files | Plugins/DicomWeb/Run.py Tests/Tests.py Tests/Toolbox.py |
diffstat | 3 files changed, 35 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/DicomWeb/Run.py Mon Jun 19 21:15:48 2023 +0200 +++ b/Plugins/DicomWeb/Run.py Tue Jun 20 17:24:56 2023 +0200 @@ -1084,11 +1084,12 @@ metadata = DoGet(ORTHANC, 'dicom-web/studies/1.2.276.0.26.1.1.1.2.2020.45.52293.1506048/series/1.2.276.0.26.1.1.1.2.2020.45.52293.6384450/instances/1.2.276.0.26.1.1.1.2.2020.45.52366.2551599.179568640/metadata') self.assertEqual("YBR_FULL_422", metadata[0]['00280004']['Value'][0]) - # starting from 1.12.1, Orthanc does not convert YBR to RGB anymore -> new checksum (https://discourse.orthanc-server.org/t/orthanc-convert-ybr-to-rgb-but-does-not-change-metadata/3533) - if IsOrthancVersionAbove(ORTHANC, 1, 12, 1): - expectedDcmtkChecksum = '7535a11e7da0fa590c467ac9d323c5c1' - else: - expectedDcmtkChecksum = 'b3662c4bfa24a0c73abb08548c63319b' + # TODO + # # starting from X.XX.X, Orthanc won't convert YBR to RGB anymore -> new checksum (https://discourse.orthanc-server.org/t/orthanc-convert-ybr-to-rgb-but-does-not-change-metadata/3533) + # if IsOrthancVersionAbove(ORTHANC, 1, XX, 1): + # expectedDcmtkChecksum = '7535a11e7da0fa590c467ac9d323c5c1' + # else: + expectedDcmtkChecksum = 'b3662c4bfa24a0c73abb08548c63319b' if HasGdcmPlugin(ORTHANC): self.assertTrue(ComputeMD5(p[0]) in [ @@ -1248,8 +1249,11 @@ uri = 'dicom-web%s' % UploadAndGetWadoPath('TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm') truthRGB = Image.open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.png')) - with open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.YBR.raw'), 'rb') as f: - truthRawYbr = f.read() + + # TODO + # # starting from X.XX.X, Orthanc won't convert YBR to RGB anymore -> new checksum (https://discourse.orthanc-server.org/t/orthanc-convert-ybr-to-rgb-but-does-not-change-metadata/3533) + # with open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.YBR.raw'), 'rb') as f: + # truthRawYbr = f.read() # first test: no transcoding since we accept the JPEG transfer syntax a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri, @@ -1270,13 +1274,15 @@ self.assertEqual(480 * 640 * 3, len(a[0])) # Orthanc is now returning the YBR image instead of the RGB - if IsOrthancVersionAbove(ORTHANC, 1, 12, 1) and not HasGdcmPlugin(ORTHANC): - # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg - self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0])) - else: - # http://effbot.org/zone/pil-comparing-images.htm - img = Image.frombytes('RGB', [ 640, 480 ], a[0]) - self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2) + # TODO + # # starting from X.XX.X, Orthanc won't convert YBR to RGB anymore -> new checksum (https://discourse.orthanc-server.org/t/orthanc-convert-ybr-to-rgb-but-does-not-change-metadata/3533) + # if IsOrthancVersionAbove(ORTHANC, 1, XX, 1) and not HasGdcmPlugin(ORTHANC): + # # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg + # self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0])) + # else: + # http://effbot.org/zone/pil-comparing-images.htm + img = Image.frombytes('RGB', [ 640, 480 ], a[0]) + self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2) ACCEPT2 = copy.deepcopy(ACCEPT) if HasGdcmPlugin(ORTHANC): @@ -1293,15 +1299,18 @@ self.assertEqual(1, len(a)) self.assertEqual(480 * 640 * 3, len(a[0])) - if IsOrthancVersionAbove(ORTHANC, 1, 12, 1) and not HasGdcmPlugin(ORTHANC): - # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg - self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0])) - else: - # http://effbot.org/zone/pil-comparing-images.htm - img = Image.frombytes('RGB', [ 640, 480 ], a[0]) - self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2) + # TODO + # # starting from X.XX.X, Orthanc won't convert YBR to RGB anymore -> new checksum (https://discourse.orthanc-server.org/t/orthanc-convert-ybr-to-rgb-but-does-not-change-metadata/3533) + # if IsOrthancVersionAbove(ORTHANC, 1, XX, X) and not HasGdcmPlugin(ORTHANC): + # # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg + # self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0])) + # else: + # http://effbot.org/zone/pil-comparing-images.htm + img = Image.frombytes('RGB', [ 640, 480 ], a[0]) + self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2) - if not IS_GDCM and not IsOrthancVersionAbove(ORTHANC, 1, 12, 1): + # TODO: if not IS_GDCM and not IsOrthancVersionAbove(ORTHANC, 1, XX, X): + if not IS_GDCM: self.assertEqual('dfdc79f5070926bbb8ac079ee91f5b91', ComputeMD5(a[0]))
--- a/Tests/Tests.py Mon Jun 19 21:15:48 2023 +0200 +++ b/Tests/Tests.py Tue Jun 20 17:24:56 2023 +0200 @@ -6737,7 +6737,7 @@ f1 = '/tmp/GETSCU/MR.1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549' self.assertTrue(os.path.isfile(f1)) with open(f1, 'rb') as f: - self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(f.read())) + self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(f.read(), encoding='ISO-8859-1')) CleanTarget() @@ -6757,7 +6757,7 @@ self.assertTrue(os.path.isfile(f1)) with open(f1, 'rb') as f: - self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(f.read())) + self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(f.read(), encoding='ISO-8859-1')) # This file is transcoded from "1.2.840.10008.1.2.4.50" to "1.2.840.10008.1.2.1" # (LittleEndianExplicit is proposed by default by "getscu")
--- a/Tests/Toolbox.py Mon Jun 19 21:15:48 2023 +0200 +++ b/Tests/Toolbox.py Tue Jun 20 17:24:56 2023 +0200 @@ -423,7 +423,7 @@ self.assertAlmostEqual(a, b, places = places) -def GetTransferSyntax(dicom): +def GetTransferSyntax(dicom, encoding='utf-8'): with tempfile.NamedTemporaryFile(delete = True) as f: f.write(dicom) f.flush() @@ -431,7 +431,7 @@ with open(os.devnull, 'w') as devnull: data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ], stderr = devnull) - return re.search('<data-set xfer="(.*?)"', data.decode('utf-8')).group(1) + return re.search('<data-set xfer="(.*?)"', data.decode(encoding)).group(1) def HasGdcmPlugin(orthanc):