comparison Plugins/DicomWeb/Run.py @ 228:84244277413b

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 27 Feb 2019 15:41:35 +0100
parents 875ff7460ae8
children a4804d3f7499
comparison
equal deleted inserted replaced
227:875ff7460ae8 228:84244277413b
415 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % ('nope', series))) 415 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % ('nope', series)))
416 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % (study, 'nope'))) 416 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % (study, 'nope')))
417 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % 'nope')) 417 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % 'nope'))
418 418
419 419
420 def test_wado_bulk(self): 420 def test_wado_pixel_data(self):
421 orthanc = UploadInstance(ORTHANC, 'Issue29.dcm') ['ID']
422 a = DoGet(ORTHANC, '/dicom-web/instances')
423 self.assertEqual(1, len(a))
424 url = a[0]['00081190']['Value'][0]
425
426 prefix = 'http://localhost:8042'
427 self.assertTrue(url.startswith(prefix))
428
429 b = DoGet(ORTHANC, url[len(prefix):] + '/metadata')
430 self.assertEqual('OB', b[0]['7FE00010']['vr'])
431 self.assertEqual(2, len(b[0]['7FE00010']))
432 self.assertTrue('BulkDataURI' in b[0]['7FE00010'])
433
434 url = b[0]['7FE00010']['BulkDataURI']
435 self.assertTrue(url.startswith(prefix))
436
437 p = DoGetMultipart(ORTHANC, url[len(prefix):])
438 print(p)
439 print(len(p))
440 for i in len(p):
441 print(len(p[i]))
442
443 self.assertEqual(2, len(p)) # There are 2 fragments in this image
444 self.assertEqual(4, len(p[0]))
445 self.assertEqual(114486, len(p[1]))
446
447
448 def test_wado_hierarchy_bulk(self):
421 def CheckBulk(value, bulk): 449 def CheckBulk(value, bulk):
422 self.assertEqual(2, len(value)) 450 self.assertEqual(2, len(value))
423 self.assertTrue('BulkDataURI' in value) 451 self.assertTrue('BulkDataURI' in value)
424 self.assertTrue('vr' in value) 452 self.assertTrue('vr' in value)
425 self.assertEqual(value['BulkDataURI'], bulk) 453 self.assertEqual(value['BulkDataURI'], bulk)
427 orthanc = UploadInstance(ORTHANC, 'PrivateTags.dcm') ['ID'] 455 orthanc = UploadInstance(ORTHANC, 'PrivateTags.dcm') ['ID']
428 study = '1.2.840.113619.2.115.147416.1094281639.0.29' 456 study = '1.2.840.113619.2.115.147416.1094281639.0.29'
429 series = '1.2.840.113619.2.115.147416.1094281639.0.30' 457 series = '1.2.840.113619.2.115.147416.1094281639.0.30'
430 sop = '1.2.840.113619.2.115.147416.1094281639.0.38' 458 sop = '1.2.840.113619.2.115.147416.1094281639.0.38'
431 459
460 # WARNING: This test will fail on Orthanc <= 1.5.5, because
461 # the following fix is not included yet:
462 # https://bitbucket.org/sjodogne/orthanc/commits/b88937ef597b33c4387a546c751827019bcdc205
463
432 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study) 464 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study)
433 self.assertEqual(1, len(a)) 465 self.assertEqual(1, len(a))
434 466
435 BASE_URI = '/dicom-web/studies/%s/series/%s/instances/%s/bulk' % (study, series, sop) 467 BASE_URI = '/dicom-web/studies/%s/series/%s/instances/%s/bulk' % (study, series, sop)
436 BASE_URL = 'http://localhost:8042%s' % BASE_URI 468 BASE_URL = 'http://localhost:8042%s' % BASE_URI
512 def test_bitbucket_issue_96(self): 544 def test_bitbucket_issue_96(self):
513 # WADO-RS RetrieveFrames rejects valid accept headers 545 # WADO-RS RetrieveFrames rejects valid accept headers
514 # https://bitbucket.org/sjodogne/orthanc/issues/96 546 # https://bitbucket.org/sjodogne/orthanc/issues/96
515 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/5/ 547 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/5/
516 548
517 UploadInstance(ORTHANC, 'LenaTwiceWithFragments.dcm') 549 UploadInstance(ORTHANC, 'Brainix/Epi/IM-0001-0001.dcm')
518 550
519 a = DoGet(ORTHANC, '/dicom-web/instances') 551 a = DoGet(ORTHANC, '/dicom-web/instances')
520 self.assertEqual(1, len(a)) 552 self.assertEqual(1, len(a))
521 self.assertEqual(2, a[0]['00280008']['Value'][0]) # Number of frames 553 self.assertEqual(256, a[0]['00280010']['Value'][0]) # Rows
522 self.assertEqual(512, a[0]['00280010']['Value'][0]) # Rows 554 self.assertEqual(256, a[0]['00280011']['Value'][0]) # Columns
523 self.assertEqual(512, a[0]['00280011']['Value'][0]) # Columns 555 self.assertEqual(16, a[0]['00280100']['Value'][0]) # Bits allocated
524 self.assertEqual(8, a[0]['00280100']['Value'][0]) # Bits allocated
525 556
526 url = a[0]['00081190']['Value'][0] 557 url = a[0]['00081190']['Value'][0]
527 558
528 prefix = 'http://localhost:8042' 559 prefix = 'http://localhost:8042'
529 self.assertTrue(url.startswith(prefix)) 560 self.assertTrue(url.startswith(prefix))
530 uri = url[len(prefix):] 561 uri = url[len(prefix):]
531 562
532 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 0))) 563 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 0)))
533 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 3))) 564 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2)))
534 565
566 print('%s/frames/%d' % (uri, 1))
535 b = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1)) 567 b = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1))
536 self.assertEqual(1, len(b)) 568 self.assertEqual(1, len(b))
537 self.assertEqual(512 * 512 * 3, len(b[0])) 569 self.assertEqual(256 * 256 * 2, len(b[0]))
538 570
539 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2)) 571 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
540 self.assertEqual(1, len(c))
541 self.assertEqual(512 * 512 * 3, len(c[0]))
542
543 self.assertEqual(b[0], c[0])
544
545 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2),
546 headers = { 'Accept' : 'multipart/related; type=application/octet-stream' }) 572 headers = { 'Accept' : 'multipart/related; type=application/octet-stream' })
547 self.assertEqual(1, len(c)) 573 self.assertEqual(1, len(c))
548 self.assertEqual(b[0], c[0]) 574 self.assertEqual(b[0], c[0])
549 575
550 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2), 576 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
551 headers = { 'Accept' : 'multipart/related; type="application/octet-stream"' }) 577 headers = { 'Accept' : 'multipart/related; type="application/octet-stream"' })
552 self.assertEqual(1, len(c)) 578 self.assertEqual(1, len(c))
553 self.assertEqual(b[0], c[0]) 579 self.assertEqual(b[0], c[0])
580
581 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
582 headers = { 'Accept' : 'multipart/related; type="nope"' }))
583
584 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
585 headers = { 'Accept' : 'multipart/related; type=nope' }))
586
587 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
588 headers = { 'Accept' : 'nope' }))
554 589
555 590
556 def test_qido_fields(self): 591 def test_qido_fields(self):
557 UploadInstance(ORTHANC, 'DummyCT.dcm') 592 UploadInstance(ORTHANC, 'DummyCT.dcm')
558 593