dicom-microscopy-viewer 0.36.4 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/dicom-microscopy-viewer.js +1 -1
  2. package/dist/dicom-microscopy-viewer.js.map +1 -1
  3. package/docs/annotation.AnnotationGroup.html +1 -1
  4. package/docs/annotation.html +1 -1
  5. package/docs/annotation.js.html +1 -1
  6. package/docs/annotations__AnnotationManager.js.html +1 -1
  7. package/docs/annotations_markups__MarkupManager.js.html +1 -1
  8. package/docs/api.html +1 -1
  9. package/docs/color.PaletteColorLookupTable.html +4 -4
  10. package/docs/color.html +1 -1
  11. package/docs/color.js.html +17 -14
  12. package/docs/dicom-microscopy-viewer.js.html +1 -1
  13. package/docs/events.html +1 -1
  14. package/docs/events.js.html +1 -1
  15. package/docs/index.html +1 -1
  16. package/docs/mapping.ParameterMapping.html +1 -1
  17. package/docs/mapping.Transformation.html +1 -1
  18. package/docs/mapping.html +1 -1
  19. package/docs/mapping.js.html +1 -1
  20. package/docs/metadata.Comprehensive3DSR.html +1 -1
  21. package/docs/metadata.MicroscopyBulkSimpleAnnotations.html +1 -1
  22. package/docs/metadata.ParametricMap.html +1 -1
  23. package/docs/metadata.SOPClass.html +1 -1
  24. package/docs/metadata.Segmentation.html +1 -1
  25. package/docs/metadata.VLWholeSlideMicroscopyImage.html +1 -1
  26. package/docs/metadata.html +1 -1
  27. package/docs/metadata.js.html +1 -1
  28. package/docs/opticalPath.OpticalPath.html +1 -1
  29. package/docs/opticalPath.html +1 -1
  30. package/docs/opticalPath.js.html +2 -2
  31. package/docs/pyramid.js.html +1 -1
  32. package/docs/roi.ROI.html +1 -1
  33. package/docs/roi.html +1 -1
  34. package/docs/roi.js.html +1 -1
  35. package/docs/scoord3d.Ellipse.html +1 -1
  36. package/docs/scoord3d.Ellipsoid.html +1 -1
  37. package/docs/scoord3d.Multipoint.html +1 -1
  38. package/docs/scoord3d.Point.html +1 -1
  39. package/docs/scoord3d.Polygon.html +1 -1
  40. package/docs/scoord3d.Polyline.html +1 -1
  41. package/docs/scoord3d.Scoord3D.html +1 -1
  42. package/docs/scoord3d.html +1 -1
  43. package/docs/scoord3d.js.html +1 -1
  44. package/docs/segment.Segment.html +1 -1
  45. package/docs/segment.html +1 -1
  46. package/docs/segment.js.html +1 -1
  47. package/docs/utils.html +1 -1
  48. package/docs/utils.js.html +1 -1
  49. package/docs/viewer.LabelImageViewer.html +2 -2
  50. package/docs/viewer.OverviewImageViewer.html +2 -2
  51. package/docs/viewer.VolumeImageViewer.html +629 -236
  52. package/docs/viewer.html +1 -1
  53. package/docs/viewer.js.html +284 -292
  54. package/package.json +1 -1
  55. package/src/color.js +16 -13
  56. package/src/opticalPath.js +1 -1
  57. package/src/viewer.js +283 -291
package/src/viewer.js CHANGED
@@ -694,6 +694,60 @@ function _getColorPaletteStyleForTileLayer ({
694
694
  return { color: expression, variables }
695
695
  }
696
696
 
697
+ /**
698
+ * Build OpenLayers style expression for coloring a WebGL TileLayer.
699
+ *
700
+ * @param {Object} styleOptions - Style options
701
+ * @param {number} styleOptions.windowCenter - Center of the window used for contrast stretching
702
+ * @param {number} styleOptions.windowWidth - Width of the window used for contrast stretching
703
+ * @param {number[]} styleOptions.color - RGB color triplet
704
+ *
705
+ * @returns {Object} color style expression and corresponding variables
706
+ *
707
+ * @private
708
+ */
709
+ function _getColorInterpolationStyleForTileLayer ({
710
+ windowCenter,
711
+ windowWidth,
712
+ color
713
+ }) {
714
+ /*
715
+ * If no Palette Color Lookup Table is available, don't create one
716
+ * but let WebGL interpolate colors for improved performance.
717
+ */
718
+ const expression = [
719
+ 'interpolate',
720
+ ['linear'],
721
+ [
722
+ '+',
723
+ [
724
+ '/',
725
+ [
726
+ '-',
727
+ ['band', 1],
728
+ ['var', 'windowCenter']
729
+ ],
730
+ ['var', 'windowWidth']
731
+ ],
732
+ 0.5
733
+ ],
734
+ 0,
735
+ [0, 0, 0, 1],
736
+ 1,
737
+ ['color', ['var', 'red'], ['var', 'green'], ['var', 'blue'], 1]
738
+ ]
739
+
740
+ const variables = {
741
+ red: color[0],
742
+ green: color[1],
743
+ blue: color[2],
744
+ windowCenter,
745
+ windowWidth
746
+ }
747
+
748
+ return { color: expression, variables }
749
+ }
750
+
697
751
  /**
698
752
  * Build OpenLayers style expression for coloring a WebGL PointLayer.
699
753
  *
@@ -797,6 +851,8 @@ class VolumeImageViewer {
797
851
  * @param {metadata.VLWholeSlideMicroscopyImage[]} options.metadata -
798
852
  * Metadata of DICOM VL Whole Slide Microscopy Image instances that should be
799
853
  * diplayed.
854
+ * @param {number} [options.preload=0] - Number of resolution levels that should
855
+ * be preloaded
800
856
  * @param {string[]} [options.controls=[]] - Names of viewer control elements
801
857
  * that should be included in the viewport
802
858
  * @param {boolean} [options.debug=false] - Whether debug features should be
@@ -809,6 +865,14 @@ class VolumeImageViewer {
809
865
 
810
866
  if (this[_options].debug == null) {
811
867
  this[_options].debug = false
868
+ } else {
869
+ this[_options].debug = true
870
+ }
871
+
872
+ if (this[_options].preload == null) {
873
+ this[_options].preload = false
874
+ } else {
875
+ this[_options].preload = true
812
876
  }
813
877
 
814
878
  if (this[_options].tilesCacheSize == null) {
@@ -1050,7 +1114,6 @@ class VolumeImageViewer {
1050
1114
  paletteColorLookupTable: paletteColorLookupTable
1051
1115
  },
1052
1116
  bitsAllocated: bitsAllocated,
1053
- isColorable: paletteColorLookupTableUID == null,
1054
1117
  minStoredValue,
1055
1118
  maxStoredValue,
1056
1119
  loaderParams: {
@@ -1106,46 +1169,17 @@ class VolumeImageViewer {
1106
1169
  colormap: opticalPath.style.paletteColorLookupTable.data
1107
1170
  })
1108
1171
  } else {
1109
- /*
1110
- * If no Palette Color Lookup Table is available, don't create one
1111
- * but let WebGL interpolate colors for improved performance.
1112
- */
1113
- style = {
1114
- color: [
1115
- 'interpolate',
1116
- ['linear'],
1117
- [
1118
- '+',
1119
- [
1120
- '/',
1121
- [
1122
- '-',
1123
- ['band', 1],
1124
- ['var', 'windowCenter']
1125
- ],
1126
- ['var', 'windowWidth']
1127
- ],
1128
- 0.5
1129
- ],
1130
- 0,
1131
- [0, 0, 0, 1],
1132
- 1,
1133
- ['color', ['var', 'red'], ['var', 'green'], ['var', 'blue'], 1]
1134
- ],
1135
- variables: {
1136
- red: opticalPath.style.color[0],
1137
- green: opticalPath.style.color[1],
1138
- blue: opticalPath.style.color[2],
1139
- windowCenter,
1140
- windowWidth
1141
- }
1142
- }
1172
+ style = _getColorInterpolationStyleForTileLayer({
1173
+ windowCenter,
1174
+ windowWidth,
1175
+ color: opticalPath.style.color
1176
+ })
1143
1177
  }
1144
1178
 
1145
1179
  opticalPath.layer = new TileLayer({
1146
1180
  source,
1147
1181
  extent: pyramid.extent,
1148
- preload: 1,
1182
+ preload: this[_options].preload ? 1 : 0,
1149
1183
  style: style,
1150
1184
  visible: false,
1151
1185
  useInterimTilesOnError: false,
@@ -1227,7 +1261,6 @@ class VolumeImageViewer {
1227
1261
  projection: this[_projection],
1228
1262
  wrapX: false,
1229
1263
  transition: 0,
1230
- preload: 1,
1231
1264
  bandCount: 3
1232
1265
  })
1233
1266
  source.on('tileloaderror', (event) => {
@@ -1248,7 +1281,7 @@ class VolumeImageViewer {
1248
1281
  opticalPath.layer = new TileLayer({
1249
1282
  source,
1250
1283
  extent: this[_tileGrid].extent,
1251
- preload: 1,
1284
+ preload: this[_options].preload ? 1 : 0,
1252
1285
  useInterimTilesOnError: false,
1253
1286
  cacheSize: this[_options].tilesCacheSize
1254
1287
  })
@@ -1288,24 +1321,28 @@ class VolumeImageViewer {
1288
1321
  layers.push(tileDebugLayer)
1289
1322
  }
1290
1323
 
1291
- const overviewView = new View({
1292
- projection: this[_projection],
1293
- rotation: this[_rotation],
1294
- constrainOnlyCenter: false,
1295
- smoothExtentConstraint: true,
1296
- smoothResolutionConstraint: true,
1297
- minZoom: 0,
1298
- maxZoom: 0,
1299
- extent: this[_pyramid].extent
1300
- })
1324
+ if (Math.max(...this[_pyramid].gridSizes[0]) <= 10) {
1325
+ const overviewView = new View({
1326
+ projection: this[_projection],
1327
+ rotation: this[_rotation],
1328
+ constrainOnlyCenter: false,
1329
+ smoothExtentConstraint: true,
1330
+ smoothResolutionConstraint: true,
1331
+ minZoom: 0,
1332
+ maxZoom: 0,
1333
+ extent: this[_pyramid].extent
1334
+ })
1301
1335
 
1302
- this[_overviewMap] = new OverviewMap({
1303
- view: overviewView,
1304
- layers: overviewLayers,
1305
- collapsed: false,
1306
- collapsible: false,
1307
- rotateWithView: true
1308
- })
1336
+ this[_overviewMap] = new OverviewMap({
1337
+ view: overviewView,
1338
+ layers: overviewLayers,
1339
+ collapsed: false,
1340
+ collapsible: true,
1341
+ rotateWithView: true
1342
+ })
1343
+ } else {
1344
+ this[_overviewMap] = null
1345
+ }
1309
1346
 
1310
1347
  this[_drawingSource] = new VectorSource({
1311
1348
  tileGrid: this[_tileGrid],
@@ -1376,7 +1413,9 @@ class VolumeImageViewer {
1376
1413
  }
1377
1414
 
1378
1415
  if (this[_options].controls.has('overview')) {
1379
- this[_controls].overview = this[_overviewMap]
1416
+ if (this[_overviewMap]) {
1417
+ this[_controls].overview = this[_overviewMap]
1418
+ }
1380
1419
  }
1381
1420
 
1382
1421
  for (const control in this[_controls]) {
@@ -1408,13 +1447,17 @@ class VolumeImageViewer {
1408
1447
  * grayscale display values are then used as input to the second
1409
1448
  * transformation, which maps them to pseudo-color values ranging from black
1410
1449
  * color (R=0, G=0, B=0) to the color defined by parameter "color" using
1411
- * linear interpolation.
1450
+ * linear interpolation. Alternatively, a palette color lookup table can be
1451
+ * provided to perform more sophisticated pseudo-coloring.
1412
1452
  *
1413
1453
  * @param {string} opticalPathIdentifier - Optical Path Identifier
1414
1454
  * @param {Object} styleOptions
1415
- * @param {number[]} styleOptions.color - RGB color triplet
1416
- * @param {number} styleOptions.opacity - Opacity
1417
- * @param {number[]} styleOptions.limitValues - Upper and lower windowing limits
1455
+ * @param {number[]} [styleOptions.color] - RGB color triplet
1456
+ * @param {number[]} [styleOptions.paletteColorLookupTable] - palette color
1457
+ * lookup table
1458
+ * @param {number} [styleOptions.opacity] - Opacity
1459
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
1460
+ * limits
1418
1461
  */
1419
1462
  setOpticalPathStyle (opticalPathIdentifier, styleOptions = {}) {
1420
1463
  const opticalPath = this[_opticalPaths][opticalPathIdentifier]
@@ -1436,36 +1479,60 @@ class VolumeImageViewer {
1436
1479
  if (styleOptions.opacity != null) {
1437
1480
  opticalPath.style.opacity = styleOptions.opacity
1438
1481
  opticalPath.layer.setOpacity(styleOptions.opacity)
1482
+ opticalPath.overviewTileLayer.setOpacity(styleOptions.opacity)
1439
1483
  }
1440
1484
 
1441
- const styleVariables = {}
1442
1485
  if (opticalPath.opticalPath.isMonochromatic) {
1443
- if (styleOptions.color != null) {
1444
- if (opticalPath.opticalPath.isColorable) {
1445
- opticalPath.style.color = styleOptions.color
1446
- styleVariables.red = opticalPath.style.color[0]
1447
- styleVariables.green = opticalPath.style.color[1]
1448
- styleVariables.blue = opticalPath.style.color[2]
1449
- } else {
1450
- console.warn(
1451
- `optical path "${opticalPathIdentifier}" is not colorable`
1452
- )
1453
- }
1454
- }
1455
1486
  if (styleOptions.limitValues != null) {
1456
1487
  opticalPath.style.limitValues = [
1457
1488
  Math.max(styleOptions.limitValues[0], opticalPath.minStoredValue),
1458
1489
  Math.min(styleOptions.limitValues[1], opticalPath.maxStoredValue)
1459
1490
  ]
1460
- const [windowCenter, windowWidth] = createWindow(
1461
- styleOptions.limitValues[0],
1462
- styleOptions.limitValues[1]
1463
- )
1464
- styleVariables.windowCenter = windowCenter
1465
- styleVariables.windowWidth = windowWidth
1466
1491
  }
1467
- opticalPath.layer.updateStyleVariables(styleVariables)
1468
- opticalPath.overviewTileLayer.updateStyleVariables(styleVariables)
1492
+ const [windowCenter, windowWidth] = createWindow(
1493
+ opticalPath.style.limitValues[0],
1494
+ opticalPath.style.limitValues[1]
1495
+ )
1496
+
1497
+ if (styleOptions.paletteColorLookupTable != null) {
1498
+ const style = _getColorPaletteStyleForTileLayer({
1499
+ windowCenter,
1500
+ windowWidth,
1501
+ colormap: styleOptions.paletteColorLookupTable.data
1502
+ })
1503
+ opticalPath.style.paletteColorLookupTable = styleOptions.paletteColorLookupTable
1504
+ opticalPath.layer.setStyle(style)
1505
+ opticalPath.overviewTileLayer.setStyle(style)
1506
+ } else if (styleOptions.color != null) {
1507
+ opticalPath.style.color = styleOptions.color
1508
+ if (opticalPath.style.paletteColorLookupTable) {
1509
+ const style = _getColorInterpolationStyleForTileLayer({
1510
+ windowCenter,
1511
+ windowWidth,
1512
+ color: opticalPath.style.color
1513
+ })
1514
+ opticalPath.style.paletteColorLookupTable = undefined
1515
+ opticalPath.layer.setStyle(style)
1516
+ opticalPath.overviewTileLayer.setStyle(style)
1517
+ } else {
1518
+ const styleVariables = {
1519
+ windowCenter: windowCenter,
1520
+ windowWidth: windowWidth,
1521
+ red: opticalPath.style.color[0],
1522
+ green: opticalPath.style.color[1],
1523
+ blue: opticalPath.style.color[2]
1524
+ }
1525
+ opticalPath.layer.updateStyleVariables(styleVariables)
1526
+ opticalPath.overviewTileLayer.updateStyleVariables(styleVariables)
1527
+ }
1528
+ } else {
1529
+ const styleVariables = {
1530
+ windowCenter: windowCenter,
1531
+ windowWidth: windowWidth
1532
+ }
1533
+ opticalPath.layer.updateStyleVariables(styleVariables)
1534
+ opticalPath.overviewTileLayer.updateStyleVariables(styleVariables)
1535
+ }
1469
1536
  }
1470
1537
  }
1471
1538
 
@@ -1512,15 +1579,15 @@ class VolumeImageViewer {
1512
1579
  )
1513
1580
  }
1514
1581
  if (opticalPath.opticalPath.isMonochromatic) {
1515
- if (opticalPath.opticalPath.isColorable) {
1582
+ if (opticalPath.style.paletteColorLookupTable) {
1516
1583
  return {
1517
- color: opticalPath.style.color,
1584
+ paletteColorLookupTable: opticalPath.style.paletteColorLookupTable,
1518
1585
  opacity: opticalPath.style.opacity,
1519
1586
  limitValues: opticalPath.style.limitValues
1520
1587
  }
1521
1588
  }
1522
1589
  return {
1523
- paletteColorLookupTable: opticalPath.style.paletteColorLookupTable,
1590
+ color: opticalPath.style.color,
1524
1591
  opacity: opticalPath.style.opacity,
1525
1592
  limitValues: opticalPath.style.limitValues
1526
1593
  }
@@ -1532,7 +1599,8 @@ class VolumeImageViewer {
1532
1599
  * Get image metadata for an optical path.
1533
1600
  *
1534
1601
  * @param {string} opticalPathIdentifier - Optical Path Identifier
1535
- * @returns {VLWholeSlideMicroscopyImage[]} Slide microscopy image metadata
1602
+ * @returns {metadata.VLWholeSlideMicroscopyImage[]} Slide microscopy image
1603
+ * metadata
1536
1604
  */
1537
1605
  getOpticalPathMetadata (opticalPathIdentifier) {
1538
1606
  const opticalPath = this[_opticalPaths][opticalPathIdentifier]
@@ -1555,7 +1623,7 @@ class VolumeImageViewer {
1555
1623
  for (const opticalPathIdentifier in this[_opticalPaths]) {
1556
1624
  opticalPaths.push(this[_opticalPaths][opticalPathIdentifier].opticalPath)
1557
1625
  }
1558
- return opticalPaths
1626
+ return opticalPaths.sort(item => (item.OpticalPathIdentifier))
1559
1627
  }
1560
1628
 
1561
1629
  /**
@@ -1578,10 +1646,12 @@ class VolumeImageViewer {
1578
1646
  0,
1579
1647
  opticalPath.layer
1580
1648
  )
1581
- this[_overviewMap].getOverviewMap().getLayers().insertAt(
1582
- 0,
1583
- opticalPath.overviewTileLayer
1584
- )
1649
+ if (this[_overviewMap]) {
1650
+ this[_overviewMap].getOverviewMap().getLayers().insertAt(
1651
+ 0,
1652
+ opticalPath.overviewTileLayer
1653
+ )
1654
+ }
1585
1655
  }
1586
1656
 
1587
1657
  /**
@@ -1601,9 +1671,11 @@ class VolumeImageViewer {
1601
1671
  return
1602
1672
  }
1603
1673
  this[_map].removeLayer(opticalPath.layer)
1604
- this[_overviewMap].getOverviewMap().removeLayer(
1605
- opticalPath.overviewTileLayer
1606
- )
1674
+ if (this[_overviewMap]) {
1675
+ this[_overviewMap].getOverviewMap().removeLayer(
1676
+ opticalPath.overviewTileLayer
1677
+ )
1678
+ }
1607
1679
  }
1608
1680
 
1609
1681
  /**
@@ -1626,10 +1698,13 @@ class VolumeImageViewer {
1626
1698
  * Show an optical path.
1627
1699
  *
1628
1700
  * @param {string} opticalPathIdentifier - Optical Path Identifier
1629
- * @param {Object} styleOptions
1630
- * @param {number[]} styleOptions.color - RGB color triplet
1631
- * @param {number} styleOptions.opacity - Opacity
1632
- * @param {number[]} styleOptions.limitValues - Upper and lower clipping values
1701
+ * @param {Object} [styleOptions]
1702
+ * @param {number[]} [styleOptions.color] - RGB color triplet
1703
+ * @param {number[]} [styleOptions.paletteColorLookupTable] - palette color
1704
+ * lookup table
1705
+ * @param {number} [styleOptions.opacity] - Opacity
1706
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
1707
+ * limits
1633
1708
  */
1634
1709
  showOpticalPath (opticalPathIdentifier, styleOptions = {}) {
1635
1710
  const opticalPath = this[_opticalPaths][opticalPathIdentifier]
@@ -1843,43 +1918,53 @@ class VolumeImageViewer {
1843
1918
  scaleInnerElement.style.margin = '1px'
1844
1919
  scaleInnerElement.style.willChange = 'contents,width'
1845
1920
 
1846
- const overviewElement = this[_overviewMap].element
1847
- const overviewmapElement = Object.values(overviewElement.children).find(
1848
- c => c.className === 'ol-overviewmap-map'
1849
- )
1850
- overviewmapElement.style.border = '1px solid black'
1851
- // Try to fit the overview map into the target control overlay container
1852
- const height = Math.abs(this[_pyramid].extent[1])
1853
- const width = Math.abs(this[_pyramid].extent[2])
1854
- const rotation = this[_rotation] / Math.PI * 180
1855
- const windowSize = _getWindowSize()
1856
- let targetHeight
1857
- let resizeFactor
1858
- let targetWidth
1859
- if (Math.abs(rotation - 180) < 0.01 || Math.abs(rotation - 0) < 0.01) {
1860
- if (windowSize[1] > windowSize[0]) {
1861
- targetHeight = Math.ceil(windowSize[1] * 0.2)
1862
- resizeFactor = targetHeight / height
1863
- targetWidth = width * resizeFactor
1864
- } else {
1865
- targetWidth = Math.ceil(windowSize[0] * 0.15)
1866
- resizeFactor = targetWidth / width
1867
- targetHeight = height * resizeFactor
1921
+ if (this[_overviewMap]) {
1922
+ const overviewElement = this[_overviewMap].element
1923
+ const overviewmapElement = Object.values(overviewElement.children).find(
1924
+ c => c.className === 'ol-overviewmap-map'
1925
+ )
1926
+ const buttonElement = Object.values(overviewElement.children).find(
1927
+ c => c.type === 'button'
1928
+ )
1929
+ if (buttonElement) {
1930
+ buttonElement.style.border = '0.25px solid black'
1931
+ buttonElement.style.backgroundColor = 'white'
1868
1932
  }
1869
- } else {
1870
- if (windowSize[1] > windowSize[0]) {
1871
- targetHeight = Math.ceil(windowSize[1] * 0.2)
1872
- resizeFactor = targetHeight / width
1873
- targetWidth = height * resizeFactor
1933
+ overviewmapElement.style.border = '1px solid black'
1934
+ overviewmapElement.style.color = 'black'
1935
+ // Try to fit the overview map into the target control overlay container
1936
+ const height = Math.abs(this[_pyramid].extent[1])
1937
+ const width = Math.abs(this[_pyramid].extent[2])
1938
+ const rotation = this[_rotation] / Math.PI * 180
1939
+ const windowSize = _getWindowSize()
1940
+ let targetHeight
1941
+ let resizeFactor
1942
+ let targetWidth
1943
+ if (Math.abs(rotation - 180) < 0.01 || Math.abs(rotation - 0) < 0.01) {
1944
+ if (windowSize[1] > windowSize[0]) {
1945
+ targetHeight = Math.ceil(windowSize[1] * 0.2)
1946
+ resizeFactor = targetHeight / height
1947
+ targetWidth = width * resizeFactor
1948
+ } else {
1949
+ targetWidth = Math.ceil(windowSize[0] * 0.15)
1950
+ resizeFactor = targetWidth / width
1951
+ targetHeight = height * resizeFactor
1952
+ }
1874
1953
  } else {
1875
- targetWidth = Math.ceil(windowSize[0] * 0.15)
1876
- resizeFactor = targetWidth / height
1877
- targetHeight = width * resizeFactor
1954
+ if (windowSize[1] > windowSize[0]) {
1955
+ targetHeight = Math.ceil(windowSize[1] * 0.2)
1956
+ resizeFactor = targetHeight / width
1957
+ targetWidth = height * resizeFactor
1958
+ } else {
1959
+ targetWidth = Math.ceil(windowSize[0] * 0.15)
1960
+ resizeFactor = targetWidth / height
1961
+ targetHeight = width * resizeFactor
1962
+ }
1878
1963
  }
1964
+ overviewmapElement.style.width = `${targetWidth}px`
1965
+ overviewmapElement.style.height = `${targetHeight}px`
1966
+ this[_overviewMap].getOverviewMap().updateSize()
1879
1967
  }
1880
- overviewmapElement.style.width = `${targetWidth}px`
1881
- overviewmapElement.style.height = `${targetHeight}px`
1882
- this[_overviewMap].getOverviewMap().updateSize()
1883
1968
  })
1884
1969
  }
1885
1970
 
@@ -1888,19 +1973,20 @@ class VolumeImageViewer {
1888
1973
  *
1889
1974
  * @param {Object} options - Drawing options
1890
1975
  * @param {string} options.geometryType - Name of the geometry type (point, circle, box, polygon, freehandpolygon, line, freehandline)
1891
- * @param {string} options.marker - Marker
1892
- * @param {string} options.markup - Markup
1893
- * @param {number} options.maxPoints - Geometry max points
1894
- * @param {number} options.minPoints - Geometry min points
1895
- * @param {Object} options.styleOptions - Style options
1896
- * @param {Object} options.styleOptions.stroke - Style options for the outline of the geometry
1897
- * @param {number[]} options.styleOptions.stroke.color - RGBA color of the outline
1898
- * @param {number} options.styleOptions.stroke.width - Width of the outline
1899
- * @param {Object} options.styleOptions.fill - Style options for body the geometry
1900
- * @param {number[]} options.styleOptions.fill.color - RGBA color of the body
1901
- * @param {Object} options.styleOptions.image - Style options for image
1976
+ * @param {number} [options.maxPoints] - Maximum number of points for "line"
1977
+ * geometry
1978
+ * @param {number} [options.minPoints] - Mininum number of points for "line"
1979
+ * geometry
1980
+ * @param {Object} [options.styleOptions] - Style options
1981
+ * @param {Object} [styleOptions.stroke] - Style options for the contour of
1982
+ * the geometry
1983
+ * @param {number[]} styleOptions.stroke.color - RGBA color of the contour
1984
+ * @param {number} styleOptions.stroke.width - Width of the contour
1985
+ * @param {Object} [styleOptions.fill] - Style options for the body of the
1986
+ * geometry
1987
+ * @param {number[]} styleOptions.fill.color - RGBA color of the body
1902
1988
  */
1903
- activateDrawInteraction (options = {}) {
1989
+ activateDrawInteraction (options) {
1904
1990
  this.deactivateDrawInteraction()
1905
1991
  console.info('activate "draw" interaction')
1906
1992
 
@@ -2128,17 +2214,19 @@ class VolumeImageViewer {
2128
2214
  * @returns {void}
2129
2215
  */
2130
2216
  toggleOverviewMap () {
2131
- const controls = this[_map].getControls()
2132
- const overview = controls.getArray().find((c) => c === this[_overviewMap])
2133
- if (overview) {
2134
- this[_map].removeControl(this[_overviewMap])
2135
- return
2217
+ if (this[_overviewMap]) {
2218
+ const controls = this[_map].getControls()
2219
+ const overview = controls.getArray().find((c) => c === this[_overviewMap])
2220
+ if (overview) {
2221
+ this[_map].removeControl(this[_overviewMap])
2222
+ return
2223
+ }
2224
+ this[_map].addControl(this[_overviewMap])
2225
+ const map = this[_overviewMap].getOverviewMap()
2226
+ const view = map.getView()
2227
+ const projection = view.getProjection()
2228
+ view.fit(projection.getExtent(), { size: map.getSize() })
2136
2229
  }
2137
- this[_map].addControl(this[_overviewMap])
2138
- const map = this[_overviewMap].getOverviewMap()
2139
- const view = map.getView()
2140
- const projection = view.getProjection()
2141
- view.fit(projection.getExtent(), { size: map.getSize() })
2142
2230
  }
2143
2231
 
2144
2232
  /**
@@ -2392,11 +2480,15 @@ class VolumeImageViewer {
2392
2480
  }
2393
2481
 
2394
2482
  collapseOverviewMap () {
2395
- this[_overviewMap].setCollapsed(true)
2483
+ if (this[_overviewMap]) {
2484
+ this[_overviewMap].setCollapsed(true)
2485
+ }
2396
2486
  }
2397
2487
 
2398
2488
  expandOverviewMap () {
2399
- this[_overviewMap].setCollapsed(true)
2489
+ if (this[_overviewMap]) {
2490
+ this[_overviewMap].setCollapsed(true)
2491
+ }
2400
2492
  }
2401
2493
 
2402
2494
  /**
@@ -2481,14 +2573,14 @@ class VolumeImageViewer {
2481
2573
  * Add a regions of interest.
2482
2574
  *
2483
2575
  * @param {roi.ROI} roi - Regions of interest
2484
- * @param {Object} styleOptions - Style options
2485
- * @param {Object} styleOptions.stroke - Style options for the outline of the geometry
2486
- * @param {number[]} styleOptions.stroke.color - RGBA color of the outline
2487
- * @param {number} styleOptions.stroke.width - Width of the outline
2488
- * @param {Object} styleOptions.fill - Style options for body the geometry
2576
+ * @param {Object} [styleOptions] - Style options
2577
+ * @param {Object} [styleOptions.stroke] - Style options for the contour of
2578
+ * the geometry
2579
+ * @param {number[]} styleOptions.stroke.color - RGBA color of the contour
2580
+ * @param {number} styleOptions.stroke.width - Width of the contour
2581
+ * @param {Object} [styleOptions.fill] - Style options for the body of the
2582
+ * geometry
2489
2583
  * @param {number[]} styleOptions.fill.color - RGBA color of the body
2490
- * @param {Object} styleOptions.image - Style options for image
2491
- *
2492
2584
  */
2493
2585
  addROI (roi, styleOptions = {}) {
2494
2586
  console.info(`add ROI ${roi.uid}`)
@@ -2527,10 +2619,10 @@ class VolumeImageViewer {
2527
2619
  * @param {Object} roi - ROI to be updated
2528
2620
  * @param {string} roi.uid - Unique identifier of the region of interest
2529
2621
  * @param {Object} roi.properties - ROI properties
2530
- * @param {Object} roi.properties.measurements - ROI measurements
2531
- * @param {Object} roi.properties.evaluations - ROI evaluations
2532
- * @param {Object} roi.properties.label - ROI label
2533
- * @param {Object} roi.properties.marker - ROI marker
2622
+ * @param {Object} [roi.properties.measurements] - ROI measurements
2623
+ * @param {Object} [roi.properties.evaluations] - ROI evaluations
2624
+ * @param {Object} [roi.properties.label] - ROI label
2625
+ * @param {Object} [roi.properties.marker] - ROI marker
2534
2626
  */
2535
2627
  updateROI ({ uid, properties = {} }) {
2536
2628
  if (!uid) return
@@ -2576,12 +2668,13 @@ class VolumeImageViewer {
2576
2668
  *
2577
2669
  * @param {string} uid - Unique identifier of the regions of interest
2578
2670
  * @param {Object} styleOptions - Style options
2579
- * @param {Object} styleOptions.stroke - Style options for the outline of the geometry
2580
- * @param {number[]} styleOptions.stroke.color - RGBA color of the outline
2581
- * @param {number} styleOptions.stroke.width - Width of the outline
2582
- * @param {Object} styleOptions.fill - Style options for body the geometry
2671
+ * @param {Object} [styleOptions.stroke] - Style options for the contour of
2672
+ * the geometry
2673
+ * @param {number[]} styleOptions.stroke.color - RGBA color of the contour
2674
+ * @param {number} styleOptions.stroke.width - Width of the contour
2675
+ * @param {Object} [styleOptions.fill] - Style options for the body of the
2676
+ * geometry
2583
2677
  * @param {number[]} styleOptions.fill.color - RGBA color of the body
2584
- *
2585
2678
  */
2586
2679
  setROIStyle (uid, styleOptions = {}) {
2587
2680
  this[_features].forEach((feature) => {
@@ -2747,7 +2840,9 @@ class VolumeImageViewer {
2747
2840
 
2748
2841
  const numberOfAnnotations = Number(metadataItem.NumberOfAnnotations)
2749
2842
  const graphicType = metadataItem.GraphicType
2750
- const coordinateDimensionality = _getCoordinateDimensionality(metadataItem)
2843
+ const coordinateDimensionality = _getCoordinateDimensionality(
2844
+ metadataItem
2845
+ )
2751
2846
  const commonZCoordinate = _getCommonZCoordinate(metadataItem)
2752
2847
 
2753
2848
  const features = this.getFeatures()
@@ -2776,10 +2871,12 @@ class VolumeImageViewer {
2776
2871
  i,
2777
2872
  numberOfAnnotations
2778
2873
  )
2874
+ const coordinates = _scoord3dCoordinates2geometryCoordinates(
2875
+ point,
2876
+ pyramid
2877
+ )
2779
2878
  const feature = new Feature({
2780
- geometry: new PointGeometry(
2781
- _scoord3dCoordinates2geometryCoordinates(point, pyramid)
2782
- )
2879
+ geometry: new PointGeometry(coordinates)
2783
2880
  })
2784
2881
  const properties = {}
2785
2882
  measurements.forEach(item => {
@@ -2830,7 +2927,7 @@ class VolumeImageViewer {
2830
2927
  const container = this[_map].getTargetElement()
2831
2928
  publish(container, EVENT.LOADING_ENDED)
2832
2929
  })
2833
- source.on('featureserror', (event) => {
2930
+ source.on('featuresloaderror', (event) => {
2834
2931
  const container = this[_map].getTargetElement()
2835
2932
  publish(container, EVENT.LOADING_ENDED)
2836
2933
  })
@@ -2916,112 +3013,6 @@ class VolumeImageViewer {
2916
3013
  annotationGroup.layer.setVisible(true)
2917
3014
  }
2918
3015
 
2919
- _retrieveAnnotationGroupBulkdata (annotationGroupUID) {
2920
- if (!(annotationGroupUID in this[_annotationGroups])) {
2921
- throw new Error(
2922
- 'Cannot retrieve bulkdata of annotation group. ' +
2923
- `Could not find annotation group "${annotationGroupUID}".`
2924
- )
2925
- }
2926
- const annotationGroup = this[_annotationGroups][annotationGroupUID]
2927
- console.log(
2928
- `retrieve bulkdata for annotation group "${annotationGroupUID}"`
2929
- )
2930
- const container = this[_map].getTargetElement()
2931
- if (container == null) {
2932
- throw new Error(
2933
- 'Cannot retrieve bulkdata of annotation group. ' +
2934
- 'Viewport has not been rendered. Call render() first.'
2935
- )
2936
- }
2937
- publish(container, EVENT.LOADING_STARTED)
2938
-
2939
- const index = annotationGroup.annotationGroup.number - 1
2940
- const metadataItem = annotationGroup.metadata.AnnotationGroupSequence[index]
2941
- /**
2942
- * Bulkdata may not be available, since it's possible that all information
2943
- * has been included into the metadata by value as InlineBinary. It must
2944
- * only be provided if information has been included by reference as
2945
- * BulkDataURI.
2946
- */
2947
- const bulkdataReferences = annotationGroup.metadata.bulkdataReferences
2948
- let bulkdataItem
2949
- if (bulkdataReferences.AnnotationGroupSequence != null) {
2950
- bulkdataItem = bulkdataReferences.AnnotationGroupSequence[index]
2951
- }
2952
-
2953
- const numberOfAnnotations = Number(metadataItem.NumberOfAnnotations)
2954
- const graphicType = metadataItem.GraphicType
2955
- const coordinateDimensionality = _getCoordinateDimensionality(metadataItem)
2956
- const commonZCoordinate = _getCommonZCoordinate(metadataItem)
2957
-
2958
- const source = annotationGroup.layer.getSource()
2959
- const features = source.getFeatures()
2960
-
2961
- const client = this[_options].client
2962
- const promises = [
2963
- _fetchGraphicData({ metadataItem, bulkdataItem, client }),
2964
- _fetchGraphicIndex({ metadataItem, bulkdataItem, client }),
2965
- _fetchMeasurements({ metadataItem, bulkdataItem, client })
2966
- ]
2967
- Promise.all(promises).then(retrievedBulkdata => {
2968
- const graphicData = retrievedBulkdata[0]
2969
- const graphicIndex = retrievedBulkdata[1]
2970
- const measurements = retrievedBulkdata[2]
2971
-
2972
- for (let i = 0; i < numberOfAnnotations; i++) {
2973
- const point = _getCentroid(
2974
- graphicType,
2975
- graphicData,
2976
- graphicIndex,
2977
- coordinateDimensionality,
2978
- commonZCoordinate,
2979
- i,
2980
- numberOfAnnotations
2981
- )
2982
- const feature = new Feature({
2983
- geometry: new PointGeometry(
2984
- _scoord3dCoordinates2geometryCoordinates(
2985
- point,
2986
- this[_pyramid].metadata
2987
- )
2988
- )
2989
- })
2990
- const properties = {}
2991
- measurements.forEach(item => {
2992
- const name = item.name
2993
- const key = `${name.CodingSchemeDesignator}${name.CodeValue}`
2994
- const value = item.values[i]
2995
- properties[key] = value
2996
- })
2997
- feature.setProperties(properties)
2998
- feature.setId(i + 1)
2999
- features.push(feature)
3000
- }
3001
-
3002
- console.log(
3003
- `add n=${features.length} annotations ` +
3004
- `for annotation group "${annotationGroupUID}"`
3005
- )
3006
- source.addFeatures(features)
3007
- const properties = {}
3008
- measurements.forEach(item => {
3009
- const name = item.name
3010
- const key = `${name.CodingSchemeDesignator}${name.CodeValue}`
3011
- const value = quantileSeq(
3012
- [...item.values],
3013
- [0, 0.015, 0.25, 0.5, 0.75, 0.95, 1]
3014
- )
3015
- properties[key] = value
3016
- })
3017
- source.setProperties(properties)
3018
- publish(container, EVENT.LOADING_ENDED)
3019
- }).catch(error => {
3020
- console.error(error)
3021
- publish(container, EVENT.LOADING_ENDED)
3022
- })
3023
- }
3024
-
3025
3016
  /**
3026
3017
  * Hide an annotation group.
3027
3018
  *
@@ -3352,7 +3343,7 @@ class VolumeImageViewer {
3352
3343
  extent: this[_pyramid].extent,
3353
3344
  visible: false,
3354
3345
  opacity: 0.9,
3355
- preload: 0,
3346
+ preload: this[_options].preload ? 1 : 0,
3356
3347
  transition: 0,
3357
3348
  style: _getColorPaletteStyleForTileLayer({
3358
3349
  windowCenter,
@@ -3403,8 +3394,8 @@ class VolumeImageViewer {
3403
3394
  * Show a segment.
3404
3395
  *
3405
3396
  * @param {string} segmentUID - Unique tracking identifier of a segment
3406
- * @param {Object} styleOptions
3407
- * @param {number} styleOptions.opacity - Opacity
3397
+ * @param {Object} [styleOptions]
3398
+ * @param {number} [styleOptions.opacity] - Opacity
3408
3399
  */
3409
3400
  showSegment (segmentUID, styleOptions = {}) {
3410
3401
  if (!(segmentUID in this[_segments])) {
@@ -3457,7 +3448,7 @@ class VolumeImageViewer {
3457
3448
  *
3458
3449
  * @param {string} segmentUID - Unique tracking identifier of segment
3459
3450
  * @param {Object} styleOptions - Style options
3460
- * @param {number} styleOptions.opacity - Opacity
3451
+ * @param {number} [styleOptions.opacity] - Opacity
3461
3452
  */
3462
3453
  setSegmentStyle (segmentUID, styleOptions = {}) {
3463
3454
  if (!(segmentUID in this[_segments])) {
@@ -3572,7 +3563,7 @@ class VolumeImageViewer {
3572
3563
  /**
3573
3564
  * Add parameter mappings.
3574
3565
  *
3575
- * @param {ParametricMap[]} metadata - Metadata of one or more DICOM Parametric Map instances
3566
+ * @param {metadata.ParametricMap[]} metadata - Metadata of one or more DICOM Parametric Map instances
3576
3567
  */
3577
3568
  addParameterMappings (metadata) {
3578
3569
  if (metadata.length === 0) {
@@ -3783,7 +3774,7 @@ class VolumeImageViewer {
3783
3774
  projection: this[_projection],
3784
3775
  visible: false,
3785
3776
  opacity: 1,
3786
- preload: 1,
3777
+ preload: this[_options].preload ? 1 : 0,
3787
3778
  transition: 0,
3788
3779
  style: _getColorPaletteStyleForTileLayer({
3789
3780
  windowCenter,
@@ -3833,9 +3824,9 @@ class VolumeImageViewer {
3833
3824
  * Show a parameter mapping.
3834
3825
  *
3835
3826
  * @param {string} mappingUID - Unique tracking identifier of a mapping
3836
- * @param {Object} styleOptions
3837
- * @param {number} styleOptions.opacity - Opacity
3838
- * @param {number} styleOptions.limitValues - Opacity
3827
+ * @param {Object} [styleOptions]
3828
+ * @param {number} [styleOptions.opacity] - Opacity
3829
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
3839
3830
  */
3840
3831
  showParameterMapping (mappingUID, styleOptions = {}) {
3841
3832
  if (!(mappingUID in this[_mappings])) {
@@ -3888,7 +3879,8 @@ class VolumeImageViewer {
3888
3879
  *
3889
3880
  * @param {string} mappingUID - Unique tracking identifier of mapping
3890
3881
  * @param {Object} styleOptions
3891
- * @param {number} styleOptions.opacity - Opacity
3882
+ * @param {number} [styleOptions.opacity] - Opacity
3883
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
3892
3884
  */
3893
3885
  setParameterMappingStyle (mappingUID, styleOptions = {}) {
3894
3886
  if (!(mappingUID in this[_mappings])) {