comparison Plugins/DicomWeb/Run.py @ 543:8722f7f95a38

fix
author Alain Mazy <am@osimis.io>
date Tue, 20 Jun 2023 17:24:56 +0200
parents ef41b62b456e
children bcd87bf59630
comparison
equal deleted inserted replaced
542:3f8eebe85c37 543:8722f7f95a38
1082 self.assertEqual(743 * 975 * 3, len(p[0])) 1082 self.assertEqual(743 * 975 * 3, len(p[0]))
1083 1083
1084 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') 1084 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')
1085 self.assertEqual("YBR_FULL_422", metadata[0]['00280004']['Value'][0]) 1085 self.assertEqual("YBR_FULL_422", metadata[0]['00280004']['Value'][0])
1086 1086
1087 # 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) 1087 # TODO
1088 if IsOrthancVersionAbove(ORTHANC, 1, 12, 1): 1088 # # 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)
1089 expectedDcmtkChecksum = '7535a11e7da0fa590c467ac9d323c5c1' 1089 # if IsOrthancVersionAbove(ORTHANC, 1, XX, 1):
1090 else: 1090 # expectedDcmtkChecksum = '7535a11e7da0fa590c467ac9d323c5c1'
1091 expectedDcmtkChecksum = 'b3662c4bfa24a0c73abb08548c63319b' 1091 # else:
1092 expectedDcmtkChecksum = 'b3662c4bfa24a0c73abb08548c63319b'
1092 1093
1093 if HasGdcmPlugin(ORTHANC): 1094 if HasGdcmPlugin(ORTHANC):
1094 self.assertTrue(ComputeMD5(p[0]) in [ 1095 self.assertTrue(ComputeMD5(p[0]) in [
1095 'b952d67da9ff004b0adae3982e89d620', # GDCM >= 3.0 1096 'b952d67da9ff004b0adae3982e89d620', # GDCM >= 3.0
1096 expectedDcmtkChecksum # Fallback to DCMTK 1097 expectedDcmtkChecksum # Fallback to DCMTK
1246 '1.2.840.10008.1.2.4.70' : 'multipart/related; type=image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.70', 1247 '1.2.840.10008.1.2.4.70' : 'multipart/related; type=image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.70',
1247 } 1248 }
1248 1249
1249 uri = 'dicom-web%s' % UploadAndGetWadoPath('TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm') 1250 uri = 'dicom-web%s' % UploadAndGetWadoPath('TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm')
1250 truthRGB = Image.open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.png')) 1251 truthRGB = Image.open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.png'))
1251 with open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.YBR.raw'), 'rb') as f: 1252
1252 truthRawYbr = f.read() 1253 # TODO
1254 # # 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)
1255 # with open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.YBR.raw'), 'rb') as f:
1256 # truthRawYbr = f.read()
1253 1257
1254 # first test: no transcoding since we accept the JPEG transfer syntax 1258 # first test: no transcoding since we accept the JPEG transfer syntax
1255 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri, 1259 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri,
1256 headers = { 'Accept' : ACCEPT['1.2.840.10008.1.2.4.50'] }, 1260 headers = { 'Accept' : ACCEPT['1.2.840.10008.1.2.4.50'] },
1257 returnHeaders = True) 1261 returnHeaders = True)
1268 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri) 1272 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri)
1269 self.assertEqual(1, len(a)) 1273 self.assertEqual(1, len(a))
1270 self.assertEqual(480 * 640 * 3, len(a[0])) 1274 self.assertEqual(480 * 640 * 3, len(a[0]))
1271 1275
1272 # Orthanc is now returning the YBR image instead of the RGB 1276 # Orthanc is now returning the YBR image instead of the RGB
1273 if IsOrthancVersionAbove(ORTHANC, 1, 12, 1) and not HasGdcmPlugin(ORTHANC): 1277 # TODO
1274 # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg 1278 # # 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)
1275 self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0])) 1279 # if IsOrthancVersionAbove(ORTHANC, 1, XX, 1) and not HasGdcmPlugin(ORTHANC):
1276 else: 1280 # # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg
1277 # http://effbot.org/zone/pil-comparing-images.htm 1281 # self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0]))
1278 img = Image.frombytes('RGB', [ 640, 480 ], a[0]) 1282 # else:
1279 self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2) 1283 # http://effbot.org/zone/pil-comparing-images.htm
1284 img = Image.frombytes('RGB', [ 640, 480 ], a[0])
1285 self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2)
1280 1286
1281 ACCEPT2 = copy.deepcopy(ACCEPT) 1287 ACCEPT2 = copy.deepcopy(ACCEPT)
1282 if HasGdcmPlugin(ORTHANC): 1288 if HasGdcmPlugin(ORTHANC):
1283 IS_GDCM = True 1289 IS_GDCM = True
1284 ACCEPT2['1.2.840.10008.1.2.1'] = 'multipart/related; type=application/octet-stream' 1290 ACCEPT2['1.2.840.10008.1.2.1'] = 'multipart/related; type=application/octet-stream'
1291 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri, 1297 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri,
1292 headers = { 'Accept' : ACCEPT2['1.2.840.10008.1.2.1'] }) 1298 headers = { 'Accept' : ACCEPT2['1.2.840.10008.1.2.1'] })
1293 self.assertEqual(1, len(a)) 1299 self.assertEqual(1, len(a))
1294 self.assertEqual(480 * 640 * 3, len(a[0])) 1300 self.assertEqual(480 * 640 * 3, len(a[0]))
1295 1301
1296 if IsOrthancVersionAbove(ORTHANC, 1, 12, 1) and not HasGdcmPlugin(ORTHANC): 1302 # TODO
1297 # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg 1303 # # 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)
1298 self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0])) 1304 # if IsOrthancVersionAbove(ORTHANC, 1, XX, X) and not HasGdcmPlugin(ORTHANC):
1299 else: 1305 # # GetMaxImageDifference does not work with YBR images -> strict comparison with the output of dcmdjpeg
1300 # http://effbot.org/zone/pil-comparing-images.htm 1306 # self.assertEqual('d4aacc6c7758c7c968a4fc8d59b041d5', ComputeMD5(a[0]))
1301 img = Image.frombytes('RGB', [ 640, 480 ], a[0]) 1307 # else:
1302 self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2) 1308 # http://effbot.org/zone/pil-comparing-images.htm
1303 1309 img = Image.frombytes('RGB', [ 640, 480 ], a[0])
1304 if not IS_GDCM and not IsOrthancVersionAbove(ORTHANC, 1, 12, 1): 1310 self.assertLessEqual(GetMaxImageDifference(img, truthRGB), 2)
1311
1312 # TODO: if not IS_GDCM and not IsOrthancVersionAbove(ORTHANC, 1, XX, X):
1313 if not IS_GDCM:
1305 self.assertEqual('dfdc79f5070926bbb8ac079ee91f5b91', ComputeMD5(a[0])) 1314 self.assertEqual('dfdc79f5070926bbb8ac079ee91f5b91', ComputeMD5(a[0]))
1306 1315
1307 1316
1308 # Test download using the same transfer syntax 1317 # Test download using the same transfer syntax
1309 RESULTS = { 1318 RESULTS = {