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
@@ -722,6 +722,60 @@ function _getColorPaletteStyleForTileLayer ({
722
722
  return { color: expression, variables }
723
723
  }
724
724
 
725
+ /**
726
+ * Build OpenLayers style expression for coloring a WebGL TileLayer.
727
+ *
728
+ * @param {Object} styleOptions - Style options
729
+ * @param {number} styleOptions.windowCenter - Center of the window used for contrast stretching
730
+ * @param {number} styleOptions.windowWidth - Width of the window used for contrast stretching
731
+ * @param {number[]} styleOptions.color - RGB color triplet
732
+ *
733
+ * @returns {Object} color style expression and corresponding variables
734
+ *
735
+ * @private
736
+ */
737
+ function _getColorInterpolationStyleForTileLayer ({
738
+ windowCenter,
739
+ windowWidth,
740
+ color
741
+ }) {
742
+ /*
743
+ * If no Palette Color Lookup Table is available, don't create one
744
+ * but let WebGL interpolate colors for improved performance.
745
+ */
746
+ const expression = [
747
+ 'interpolate',
748
+ ['linear'],
749
+ [
750
+ '+',
751
+ [
752
+ '/',
753
+ [
754
+ '-',
755
+ ['band', 1],
756
+ ['var', 'windowCenter']
757
+ ],
758
+ ['var', 'windowWidth']
759
+ ],
760
+ 0.5
761
+ ],
762
+ 0,
763
+ [0, 0, 0, 1],
764
+ 1,
765
+ ['color', ['var', 'red'], ['var', 'green'], ['var', 'blue'], 1]
766
+ ]
767
+
768
+ const variables = {
769
+ red: color[0],
770
+ green: color[1],
771
+ blue: color[2],
772
+ windowCenter,
773
+ windowWidth
774
+ }
775
+
776
+ return { color: expression, variables }
777
+ }
778
+
725
779
  /**
726
780
  * Build OpenLayers style expression for coloring a WebGL PointLayer.
727
781
  *
@@ -825,6 +879,8 @@ class VolumeImageViewer {
825
879
  * @param {metadata.VLWholeSlideMicroscopyImage[]} options.metadata -
826
880
  * Metadata of DICOM VL Whole Slide Microscopy Image instances that should be
827
881
  * diplayed.
882
+ * @param {number} [options.preload=0] - Number of resolution levels that should
883
+ * be preloaded
828
884
  * @param {string[]} [options.controls=[]] - Names of viewer control elements
829
885
  * that should be included in the viewport
830
886
  * @param {boolean} [options.debug=false] - Whether debug features should be
@@ -837,6 +893,14 @@ class VolumeImageViewer {
837
893
 
838
894
  if (this[_options].debug == null) {
839
895
  this[_options].debug = false
896
+ } else {
897
+ this[_options].debug = true
898
+ }
899
+
900
+ if (this[_options].preload == null) {
901
+ this[_options].preload = false
902
+ } else {
903
+ this[_options].preload = true
840
904
  }
841
905
 
842
906
  if (this[_options].tilesCacheSize == null) {
@@ -1078,7 +1142,6 @@ class VolumeImageViewer {
1078
1142
  paletteColorLookupTable: paletteColorLookupTable
1079
1143
  },
1080
1144
  bitsAllocated: bitsAllocated,
1081
- isColorable: paletteColorLookupTableUID == null,
1082
1145
  minStoredValue,
1083
1146
  maxStoredValue,
1084
1147
  loaderParams: {
@@ -1134,46 +1197,17 @@ class VolumeImageViewer {
1134
1197
  colormap: opticalPath.style.paletteColorLookupTable.data
1135
1198
  })
1136
1199
  } else {
1137
- /*
1138
- * If no Palette Color Lookup Table is available, don't create one
1139
- * but let WebGL interpolate colors for improved performance.
1140
- */
1141
- style = {
1142
- color: [
1143
- 'interpolate',
1144
- ['linear'],
1145
- [
1146
- '+',
1147
- [
1148
- '/',
1149
- [
1150
- '-',
1151
- ['band', 1],
1152
- ['var', 'windowCenter']
1153
- ],
1154
- ['var', 'windowWidth']
1155
- ],
1156
- 0.5
1157
- ],
1158
- 0,
1159
- [0, 0, 0, 1],
1160
- 1,
1161
- ['color', ['var', 'red'], ['var', 'green'], ['var', 'blue'], 1]
1162
- ],
1163
- variables: {
1164
- red: opticalPath.style.color[0],
1165
- green: opticalPath.style.color[1],
1166
- blue: opticalPath.style.color[2],
1167
- windowCenter,
1168
- windowWidth
1169
- }
1170
- }
1200
+ style = _getColorInterpolationStyleForTileLayer({
1201
+ windowCenter,
1202
+ windowWidth,
1203
+ color: opticalPath.style.color
1204
+ })
1171
1205
  }
1172
1206
 
1173
1207
  opticalPath.layer = new TileLayer({
1174
1208
  source,
1175
1209
  extent: pyramid.extent,
1176
- preload: 1,
1210
+ preload: this[_options].preload ? 1 : 0,
1177
1211
  style: style,
1178
1212
  visible: false,
1179
1213
  useInterimTilesOnError: false,
@@ -1255,7 +1289,6 @@ class VolumeImageViewer {
1255
1289
  projection: this[_projection],
1256
1290
  wrapX: false,
1257
1291
  transition: 0,
1258
- preload: 1,
1259
1292
  bandCount: 3
1260
1293
  })
1261
1294
  source.on('tileloaderror', (event) => {
@@ -1276,7 +1309,7 @@ class VolumeImageViewer {
1276
1309
  opticalPath.layer = new TileLayer({
1277
1310
  source,
1278
1311
  extent: this[_tileGrid].extent,
1279
- preload: 1,
1312
+ preload: this[_options].preload ? 1 : 0,
1280
1313
  useInterimTilesOnError: false,
1281
1314
  cacheSize: this[_options].tilesCacheSize
1282
1315
  })
@@ -1316,24 +1349,28 @@ class VolumeImageViewer {
1316
1349
  layers.push(tileDebugLayer)
1317
1350
  }
1318
1351
 
1319
- const overviewView = new View({
1320
- projection: this[_projection],
1321
- rotation: this[_rotation],
1322
- constrainOnlyCenter: false,
1323
- smoothExtentConstraint: true,
1324
- smoothResolutionConstraint: true,
1325
- minZoom: 0,
1326
- maxZoom: 0,
1327
- extent: this[_pyramid].extent
1328
- })
1352
+ if (Math.max(...this[_pyramid].gridSizes[0]) <= 10) {
1353
+ const overviewView = new View({
1354
+ projection: this[_projection],
1355
+ rotation: this[_rotation],
1356
+ constrainOnlyCenter: false,
1357
+ smoothExtentConstraint: true,
1358
+ smoothResolutionConstraint: true,
1359
+ minZoom: 0,
1360
+ maxZoom: 0,
1361
+ extent: this[_pyramid].extent
1362
+ })
1329
1363
 
1330
- this[_overviewMap] = new OverviewMap({
1331
- view: overviewView,
1332
- layers: overviewLayers,
1333
- collapsed: false,
1334
- collapsible: false,
1335
- rotateWithView: true
1336
- })
1364
+ this[_overviewMap] = new OverviewMap({
1365
+ view: overviewView,
1366
+ layers: overviewLayers,
1367
+ collapsed: false,
1368
+ collapsible: true,
1369
+ rotateWithView: true
1370
+ })
1371
+ } else {
1372
+ this[_overviewMap] = null
1373
+ }
1337
1374
 
1338
1375
  this[_drawingSource] = new VectorSource({
1339
1376
  tileGrid: this[_tileGrid],
@@ -1404,7 +1441,9 @@ class VolumeImageViewer {
1404
1441
  }
1405
1442
 
1406
1443
  if (this[_options].controls.has('overview')) {
1407
- this[_controls].overview = this[_overviewMap]
1444
+ if (this[_overviewMap]) {
1445
+ this[_controls].overview = this[_overviewMap]
1446
+ }
1408
1447
  }
1409
1448
 
1410
1449
  for (const control in this[_controls]) {
@@ -1436,13 +1475,17 @@ class VolumeImageViewer {
1436
1475
  * grayscale display values are then used as input to the second
1437
1476
  * transformation, which maps them to pseudo-color values ranging from black
1438
1477
  * color (R=0, G=0, B=0) to the color defined by parameter "color" using
1439
- * linear interpolation.
1478
+ * linear interpolation. Alternatively, a palette color lookup table can be
1479
+ * provided to perform more sophisticated pseudo-coloring.
1440
1480
  *
1441
1481
  * @param {string} opticalPathIdentifier - Optical Path Identifier
1442
1482
  * @param {Object} styleOptions
1443
- * @param {number[]} styleOptions.color - RGB color triplet
1444
- * @param {number} styleOptions.opacity - Opacity
1445
- * @param {number[]} styleOptions.limitValues - Upper and lower windowing limits
1483
+ * @param {number[]} [styleOptions.color] - RGB color triplet
1484
+ * @param {number[]} [styleOptions.paletteColorLookupTable] - palette color
1485
+ * lookup table
1486
+ * @param {number} [styleOptions.opacity] - Opacity
1487
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
1488
+ * limits
1446
1489
  */
1447
1490
  setOpticalPathStyle (opticalPathIdentifier, styleOptions = {}) {
1448
1491
  const opticalPath = this[_opticalPaths][opticalPathIdentifier]
@@ -1464,36 +1507,60 @@ class VolumeImageViewer {
1464
1507
  if (styleOptions.opacity != null) {
1465
1508
  opticalPath.style.opacity = styleOptions.opacity
1466
1509
  opticalPath.layer.setOpacity(styleOptions.opacity)
1510
+ opticalPath.overviewTileLayer.setOpacity(styleOptions.opacity)
1467
1511
  }
1468
1512
 
1469
- const styleVariables = {}
1470
1513
  if (opticalPath.opticalPath.isMonochromatic) {
1471
- if (styleOptions.color != null) {
1472
- if (opticalPath.opticalPath.isColorable) {
1473
- opticalPath.style.color = styleOptions.color
1474
- styleVariables.red = opticalPath.style.color[0]
1475
- styleVariables.green = opticalPath.style.color[1]
1476
- styleVariables.blue = opticalPath.style.color[2]
1477
- } else {
1478
- console.warn(
1479
- `optical path "${opticalPathIdentifier}" is not colorable`
1480
- )
1481
- }
1482
- }
1483
1514
  if (styleOptions.limitValues != null) {
1484
1515
  opticalPath.style.limitValues = [
1485
1516
  Math.max(styleOptions.limitValues[0], opticalPath.minStoredValue),
1486
1517
  Math.min(styleOptions.limitValues[1], opticalPath.maxStoredValue)
1487
1518
  ]
1488
- const [windowCenter, windowWidth] = createWindow(
1489
- styleOptions.limitValues[0],
1490
- styleOptions.limitValues[1]
1491
- )
1492
- styleVariables.windowCenter = windowCenter
1493
- styleVariables.windowWidth = windowWidth
1494
1519
  }
1495
- opticalPath.layer.updateStyleVariables(styleVariables)
1496
- opticalPath.overviewTileLayer.updateStyleVariables(styleVariables)
1520
+ const [windowCenter, windowWidth] = createWindow(
1521
+ opticalPath.style.limitValues[0],
1522
+ opticalPath.style.limitValues[1]
1523
+ )
1524
+
1525
+ if (styleOptions.paletteColorLookupTable != null) {
1526
+ const style = _getColorPaletteStyleForTileLayer({
1527
+ windowCenter,
1528
+ windowWidth,
1529
+ colormap: styleOptions.paletteColorLookupTable.data
1530
+ })
1531
+ opticalPath.style.paletteColorLookupTable = styleOptions.paletteColorLookupTable
1532
+ opticalPath.layer.setStyle(style)
1533
+ opticalPath.overviewTileLayer.setStyle(style)
1534
+ } else if (styleOptions.color != null) {
1535
+ opticalPath.style.color = styleOptions.color
1536
+ if (opticalPath.style.paletteColorLookupTable) {
1537
+ const style = _getColorInterpolationStyleForTileLayer({
1538
+ windowCenter,
1539
+ windowWidth,
1540
+ color: opticalPath.style.color
1541
+ })
1542
+ opticalPath.style.paletteColorLookupTable = undefined
1543
+ opticalPath.layer.setStyle(style)
1544
+ opticalPath.overviewTileLayer.setStyle(style)
1545
+ } else {
1546
+ const styleVariables = {
1547
+ windowCenter: windowCenter,
1548
+ windowWidth: windowWidth,
1549
+ red: opticalPath.style.color[0],
1550
+ green: opticalPath.style.color[1],
1551
+ blue: opticalPath.style.color[2]
1552
+ }
1553
+ opticalPath.layer.updateStyleVariables(styleVariables)
1554
+ opticalPath.overviewTileLayer.updateStyleVariables(styleVariables)
1555
+ }
1556
+ } else {
1557
+ const styleVariables = {
1558
+ windowCenter: windowCenter,
1559
+ windowWidth: windowWidth
1560
+ }
1561
+ opticalPath.layer.updateStyleVariables(styleVariables)
1562
+ opticalPath.overviewTileLayer.updateStyleVariables(styleVariables)
1563
+ }
1497
1564
  }
1498
1565
  }
1499
1566
 
@@ -1540,15 +1607,15 @@ class VolumeImageViewer {
1540
1607
  )
1541
1608
  }
1542
1609
  if (opticalPath.opticalPath.isMonochromatic) {
1543
- if (opticalPath.opticalPath.isColorable) {
1610
+ if (opticalPath.style.paletteColorLookupTable) {
1544
1611
  return {
1545
- color: opticalPath.style.color,
1612
+ paletteColorLookupTable: opticalPath.style.paletteColorLookupTable,
1546
1613
  opacity: opticalPath.style.opacity,
1547
1614
  limitValues: opticalPath.style.limitValues
1548
1615
  }
1549
1616
  }
1550
1617
  return {
1551
- paletteColorLookupTable: opticalPath.style.paletteColorLookupTable,
1618
+ color: opticalPath.style.color,
1552
1619
  opacity: opticalPath.style.opacity,
1553
1620
  limitValues: opticalPath.style.limitValues
1554
1621
  }
@@ -1560,7 +1627,8 @@ class VolumeImageViewer {
1560
1627
  * Get image metadata for an optical path.
1561
1628
  *
1562
1629
  * @param {string} opticalPathIdentifier - Optical Path Identifier
1563
- * @returns {VLWholeSlideMicroscopyImage[]} Slide microscopy image metadata
1630
+ * @returns {metadata.VLWholeSlideMicroscopyImage[]} Slide microscopy image
1631
+ * metadata
1564
1632
  */
1565
1633
  getOpticalPathMetadata (opticalPathIdentifier) {
1566
1634
  const opticalPath = this[_opticalPaths][opticalPathIdentifier]
@@ -1583,7 +1651,7 @@ class VolumeImageViewer {
1583
1651
  for (const opticalPathIdentifier in this[_opticalPaths]) {
1584
1652
  opticalPaths.push(this[_opticalPaths][opticalPathIdentifier].opticalPath)
1585
1653
  }
1586
- return opticalPaths
1654
+ return opticalPaths.sort(item => (item.OpticalPathIdentifier))
1587
1655
  }
1588
1656
 
1589
1657
  /**
@@ -1606,10 +1674,12 @@ class VolumeImageViewer {
1606
1674
  0,
1607
1675
  opticalPath.layer
1608
1676
  )
1609
- this[_overviewMap].getOverviewMap().getLayers().insertAt(
1610
- 0,
1611
- opticalPath.overviewTileLayer
1612
- )
1677
+ if (this[_overviewMap]) {
1678
+ this[_overviewMap].getOverviewMap().getLayers().insertAt(
1679
+ 0,
1680
+ opticalPath.overviewTileLayer
1681
+ )
1682
+ }
1613
1683
  }
1614
1684
 
1615
1685
  /**
@@ -1629,9 +1699,11 @@ class VolumeImageViewer {
1629
1699
  return
1630
1700
  }
1631
1701
  this[_map].removeLayer(opticalPath.layer)
1632
- this[_overviewMap].getOverviewMap().removeLayer(
1633
- opticalPath.overviewTileLayer
1634
- )
1702
+ if (this[_overviewMap]) {
1703
+ this[_overviewMap].getOverviewMap().removeLayer(
1704
+ opticalPath.overviewTileLayer
1705
+ )
1706
+ }
1635
1707
  }
1636
1708
 
1637
1709
  /**
@@ -1654,10 +1726,13 @@ class VolumeImageViewer {
1654
1726
  * Show an optical path.
1655
1727
  *
1656
1728
  * @param {string} opticalPathIdentifier - Optical Path Identifier
1657
- * @param {Object} styleOptions
1658
- * @param {number[]} styleOptions.color - RGB color triplet
1659
- * @param {number} styleOptions.opacity - Opacity
1660
- * @param {number[]} styleOptions.limitValues - Upper and lower clipping values
1729
+ * @param {Object} [styleOptions]
1730
+ * @param {number[]} [styleOptions.color] - RGB color triplet
1731
+ * @param {number[]} [styleOptions.paletteColorLookupTable] - palette color
1732
+ * lookup table
1733
+ * @param {number} [styleOptions.opacity] - Opacity
1734
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
1735
+ * limits
1661
1736
  */
1662
1737
  showOpticalPath (opticalPathIdentifier, styleOptions = {}) {
1663
1738
  const opticalPath = this[_opticalPaths][opticalPathIdentifier]
@@ -1871,43 +1946,53 @@ class VolumeImageViewer {
1871
1946
  scaleInnerElement.style.margin = '1px'
1872
1947
  scaleInnerElement.style.willChange = 'contents,width'
1873
1948
 
1874
- const overviewElement = this[_overviewMap].element
1875
- const overviewmapElement = Object.values(overviewElement.children).find(
1876
- c => c.className === 'ol-overviewmap-map'
1877
- )
1878
- overviewmapElement.style.border = '1px solid black'
1879
- // Try to fit the overview map into the target control overlay container
1880
- const height = Math.abs(this[_pyramid].extent[1])
1881
- const width = Math.abs(this[_pyramid].extent[2])
1882
- const rotation = this[_rotation] / Math.PI * 180
1883
- const windowSize = _getWindowSize()
1884
- let targetHeight
1885
- let resizeFactor
1886
- let targetWidth
1887
- if (Math.abs(rotation - 180) < 0.01 || Math.abs(rotation - 0) < 0.01) {
1888
- if (windowSize[1] > windowSize[0]) {
1889
- targetHeight = Math.ceil(windowSize[1] * 0.2)
1890
- resizeFactor = targetHeight / height
1891
- targetWidth = width * resizeFactor
1892
- } else {
1893
- targetWidth = Math.ceil(windowSize[0] * 0.15)
1894
- resizeFactor = targetWidth / width
1895
- targetHeight = height * resizeFactor
1949
+ if (this[_overviewMap]) {
1950
+ const overviewElement = this[_overviewMap].element
1951
+ const overviewmapElement = Object.values(overviewElement.children).find(
1952
+ c => c.className === 'ol-overviewmap-map'
1953
+ )
1954
+ const buttonElement = Object.values(overviewElement.children).find(
1955
+ c => c.type === 'button'
1956
+ )
1957
+ if (buttonElement) {
1958
+ buttonElement.style.border = '0.25px solid black'
1959
+ buttonElement.style.backgroundColor = 'white'
1896
1960
  }
1897
- } else {
1898
- if (windowSize[1] > windowSize[0]) {
1899
- targetHeight = Math.ceil(windowSize[1] * 0.2)
1900
- resizeFactor = targetHeight / width
1901
- targetWidth = height * resizeFactor
1961
+ overviewmapElement.style.border = '1px solid black'
1962
+ overviewmapElement.style.color = 'black'
1963
+ // Try to fit the overview map into the target control overlay container
1964
+ const height = Math.abs(this[_pyramid].extent[1])
1965
+ const width = Math.abs(this[_pyramid].extent[2])
1966
+ const rotation = this[_rotation] / Math.PI * 180
1967
+ const windowSize = _getWindowSize()
1968
+ let targetHeight
1969
+ let resizeFactor
1970
+ let targetWidth
1971
+ if (Math.abs(rotation - 180) < 0.01 || Math.abs(rotation - 0) < 0.01) {
1972
+ if (windowSize[1] > windowSize[0]) {
1973
+ targetHeight = Math.ceil(windowSize[1] * 0.2)
1974
+ resizeFactor = targetHeight / height
1975
+ targetWidth = width * resizeFactor
1976
+ } else {
1977
+ targetWidth = Math.ceil(windowSize[0] * 0.15)
1978
+ resizeFactor = targetWidth / width
1979
+ targetHeight = height * resizeFactor
1980
+ }
1902
1981
  } else {
1903
- targetWidth = Math.ceil(windowSize[0] * 0.15)
1904
- resizeFactor = targetWidth / height
1905
- targetHeight = width * resizeFactor
1982
+ if (windowSize[1] > windowSize[0]) {
1983
+ targetHeight = Math.ceil(windowSize[1] * 0.2)
1984
+ resizeFactor = targetHeight / width
1985
+ targetWidth = height * resizeFactor
1986
+ } else {
1987
+ targetWidth = Math.ceil(windowSize[0] * 0.15)
1988
+ resizeFactor = targetWidth / height
1989
+ targetHeight = width * resizeFactor
1990
+ }
1906
1991
  }
1992
+ overviewmapElement.style.width = `${targetWidth}px`
1993
+ overviewmapElement.style.height = `${targetHeight}px`
1994
+ this[_overviewMap].getOverviewMap().updateSize()
1907
1995
  }
1908
- overviewmapElement.style.width = `${targetWidth}px`
1909
- overviewmapElement.style.height = `${targetHeight}px`
1910
- this[_overviewMap].getOverviewMap().updateSize()
1911
1996
  })
1912
1997
  }
1913
1998
 
@@ -1916,19 +2001,20 @@ class VolumeImageViewer {
1916
2001
  *
1917
2002
  * @param {Object} options - Drawing options
1918
2003
  * @param {string} options.geometryType - Name of the geometry type (point, circle, box, polygon, freehandpolygon, line, freehandline)
1919
- * @param {string} options.marker - Marker
1920
- * @param {string} options.markup - Markup
1921
- * @param {number} options.maxPoints - Geometry max points
1922
- * @param {number} options.minPoints - Geometry min points
1923
- * @param {Object} options.styleOptions - Style options
1924
- * @param {Object} options.styleOptions.stroke - Style options for the outline of the geometry
1925
- * @param {number[]} options.styleOptions.stroke.color - RGBA color of the outline
1926
- * @param {number} options.styleOptions.stroke.width - Width of the outline
1927
- * @param {Object} options.styleOptions.fill - Style options for body the geometry
1928
- * @param {number[]} options.styleOptions.fill.color - RGBA color of the body
1929
- * @param {Object} options.styleOptions.image - Style options for image
2004
+ * @param {number} [options.maxPoints] - Maximum number of points for "line"
2005
+ * geometry
2006
+ * @param {number} [options.minPoints] - Mininum number of points for "line"
2007
+ * geometry
2008
+ * @param {Object} [options.styleOptions] - Style options
2009
+ * @param {Object} [styleOptions.stroke] - Style options for the contour of
2010
+ * the geometry
2011
+ * @param {number[]} styleOptions.stroke.color - RGBA color of the contour
2012
+ * @param {number} styleOptions.stroke.width - Width of the contour
2013
+ * @param {Object} [styleOptions.fill] - Style options for the body of the
2014
+ * geometry
2015
+ * @param {number[]} styleOptions.fill.color - RGBA color of the body
1930
2016
  */
1931
- activateDrawInteraction (options = {}) {
2017
+ activateDrawInteraction (options) {
1932
2018
  this.deactivateDrawInteraction()
1933
2019
  console.info('activate "draw" interaction')
1934
2020
 
@@ -2156,17 +2242,19 @@ class VolumeImageViewer {
2156
2242
  * @returns {void}
2157
2243
  */
2158
2244
  toggleOverviewMap () {
2159
- const controls = this[_map].getControls()
2160
- const overview = controls.getArray().find((c) => c === this[_overviewMap])
2161
- if (overview) {
2162
- this[_map].removeControl(this[_overviewMap])
2163
- return
2245
+ if (this[_overviewMap]) {
2246
+ const controls = this[_map].getControls()
2247
+ const overview = controls.getArray().find((c) => c === this[_overviewMap])
2248
+ if (overview) {
2249
+ this[_map].removeControl(this[_overviewMap])
2250
+ return
2251
+ }
2252
+ this[_map].addControl(this[_overviewMap])
2253
+ const map = this[_overviewMap].getOverviewMap()
2254
+ const view = map.getView()
2255
+ const projection = view.getProjection()
2256
+ view.fit(projection.getExtent(), { size: map.getSize() })
2164
2257
  }
2165
- this[_map].addControl(this[_overviewMap])
2166
- const map = this[_overviewMap].getOverviewMap()
2167
- const view = map.getView()
2168
- const projection = view.getProjection()
2169
- view.fit(projection.getExtent(), { size: map.getSize() })
2170
2258
  }
2171
2259
 
2172
2260
  /**
@@ -2420,11 +2508,15 @@ class VolumeImageViewer {
2420
2508
  }
2421
2509
 
2422
2510
  collapseOverviewMap () {
2423
- this[_overviewMap].setCollapsed(true)
2511
+ if (this[_overviewMap]) {
2512
+ this[_overviewMap].setCollapsed(true)
2513
+ }
2424
2514
  }
2425
2515
 
2426
2516
  expandOverviewMap () {
2427
- this[_overviewMap].setCollapsed(true)
2517
+ if (this[_overviewMap]) {
2518
+ this[_overviewMap].setCollapsed(true)
2519
+ }
2428
2520
  }
2429
2521
 
2430
2522
  /**
@@ -2509,14 +2601,14 @@ class VolumeImageViewer {
2509
2601
  * Add a regions of interest.
2510
2602
  *
2511
2603
  * @param {roi.ROI} roi - Regions of interest
2512
- * @param {Object} styleOptions - Style options
2513
- * @param {Object} styleOptions.stroke - Style options for the outline of the geometry
2514
- * @param {number[]} styleOptions.stroke.color - RGBA color of the outline
2515
- * @param {number} styleOptions.stroke.width - Width of the outline
2516
- * @param {Object} styleOptions.fill - Style options for body the geometry
2604
+ * @param {Object} [styleOptions] - Style options
2605
+ * @param {Object} [styleOptions.stroke] - Style options for the contour of
2606
+ * the geometry
2607
+ * @param {number[]} styleOptions.stroke.color - RGBA color of the contour
2608
+ * @param {number} styleOptions.stroke.width - Width of the contour
2609
+ * @param {Object} [styleOptions.fill] - Style options for the body of the
2610
+ * geometry
2517
2611
  * @param {number[]} styleOptions.fill.color - RGBA color of the body
2518
- * @param {Object} styleOptions.image - Style options for image
2519
- *
2520
2612
  */
2521
2613
  addROI (roi, styleOptions = {}) {
2522
2614
  console.info(`add ROI ${roi.uid}`)
@@ -2555,10 +2647,10 @@ class VolumeImageViewer {
2555
2647
  * @param {Object} roi - ROI to be updated
2556
2648
  * @param {string} roi.uid - Unique identifier of the region of interest
2557
2649
  * @param {Object} roi.properties - ROI properties
2558
- * @param {Object} roi.properties.measurements - ROI measurements
2559
- * @param {Object} roi.properties.evaluations - ROI evaluations
2560
- * @param {Object} roi.properties.label - ROI label
2561
- * @param {Object} roi.properties.marker - ROI marker
2650
+ * @param {Object} [roi.properties.measurements] - ROI measurements
2651
+ * @param {Object} [roi.properties.evaluations] - ROI evaluations
2652
+ * @param {Object} [roi.properties.label] - ROI label
2653
+ * @param {Object} [roi.properties.marker] - ROI marker
2562
2654
  */
2563
2655
  updateROI ({ uid, properties = {} }) {
2564
2656
  if (!uid) return
@@ -2604,12 +2696,13 @@ class VolumeImageViewer {
2604
2696
  *
2605
2697
  * @param {string} uid - Unique identifier of the regions of interest
2606
2698
  * @param {Object} styleOptions - Style options
2607
- * @param {Object} styleOptions.stroke - Style options for the outline of the geometry
2608
- * @param {number[]} styleOptions.stroke.color - RGBA color of the outline
2609
- * @param {number} styleOptions.stroke.width - Width of the outline
2610
- * @param {Object} styleOptions.fill - Style options for body the geometry
2699
+ * @param {Object} [styleOptions.stroke] - Style options for the contour of
2700
+ * the geometry
2701
+ * @param {number[]} styleOptions.stroke.color - RGBA color of the contour
2702
+ * @param {number} styleOptions.stroke.width - Width of the contour
2703
+ * @param {Object} [styleOptions.fill] - Style options for the body of the
2704
+ * geometry
2611
2705
  * @param {number[]} styleOptions.fill.color - RGBA color of the body
2612
- *
2613
2706
  */
2614
2707
  setROIStyle (uid, styleOptions = {}) {
2615
2708
  this[_features].forEach((feature) => {
@@ -2775,7 +2868,9 @@ class VolumeImageViewer {
2775
2868
 
2776
2869
  const numberOfAnnotations = Number(metadataItem.NumberOfAnnotations)
2777
2870
  const graphicType = metadataItem.GraphicType
2778
- const coordinateDimensionality = _getCoordinateDimensionality(metadataItem)
2871
+ const coordinateDimensionality = _getCoordinateDimensionality(
2872
+ metadataItem
2873
+ )
2779
2874
  const commonZCoordinate = _getCommonZCoordinate(metadataItem)
2780
2875
 
2781
2876
  const features = this.getFeatures()
@@ -2804,10 +2899,12 @@ class VolumeImageViewer {
2804
2899
  i,
2805
2900
  numberOfAnnotations
2806
2901
  )
2902
+ const coordinates = _scoord3dCoordinates2geometryCoordinates(
2903
+ point,
2904
+ pyramid
2905
+ )
2807
2906
  const feature = new Feature({
2808
- geometry: new PointGeometry(
2809
- _scoord3dCoordinates2geometryCoordinates(point, pyramid)
2810
- )
2907
+ geometry: new PointGeometry(coordinates)
2811
2908
  })
2812
2909
  const properties = {}
2813
2910
  measurements.forEach(item => {
@@ -2858,7 +2955,7 @@ class VolumeImageViewer {
2858
2955
  const container = this[_map].getTargetElement()
2859
2956
  publish(container, EVENT.LOADING_ENDED)
2860
2957
  })
2861
- source.on('featureserror', (event) => {
2958
+ source.on('featuresloaderror', (event) => {
2862
2959
  const container = this[_map].getTargetElement()
2863
2960
  publish(container, EVENT.LOADING_ENDED)
2864
2961
  })
@@ -2944,112 +3041,6 @@ class VolumeImageViewer {
2944
3041
  annotationGroup.layer.setVisible(true)
2945
3042
  }
2946
3043
 
2947
- _retrieveAnnotationGroupBulkdata (annotationGroupUID) {
2948
- if (!(annotationGroupUID in this[_annotationGroups])) {
2949
- throw new Error(
2950
- 'Cannot retrieve bulkdata of annotation group. ' +
2951
- `Could not find annotation group "${annotationGroupUID}".`
2952
- )
2953
- }
2954
- const annotationGroup = this[_annotationGroups][annotationGroupUID]
2955
- console.log(
2956
- `retrieve bulkdata for annotation group "${annotationGroupUID}"`
2957
- )
2958
- const container = this[_map].getTargetElement()
2959
- if (container == null) {
2960
- throw new Error(
2961
- 'Cannot retrieve bulkdata of annotation group. ' +
2962
- 'Viewport has not been rendered. Call render() first.'
2963
- )
2964
- }
2965
- publish(container, EVENT.LOADING_STARTED)
2966
-
2967
- const index = annotationGroup.annotationGroup.number - 1
2968
- const metadataItem = annotationGroup.metadata.AnnotationGroupSequence[index]
2969
- /**
2970
- * Bulkdata may not be available, since it's possible that all information
2971
- * has been included into the metadata by value as InlineBinary. It must
2972
- * only be provided if information has been included by reference as
2973
- * BulkDataURI.
2974
- */
2975
- const bulkdataReferences = annotationGroup.metadata.bulkdataReferences
2976
- let bulkdataItem
2977
- if (bulkdataReferences.AnnotationGroupSequence != null) {
2978
- bulkdataItem = bulkdataReferences.AnnotationGroupSequence[index]
2979
- }
2980
-
2981
- const numberOfAnnotations = Number(metadataItem.NumberOfAnnotations)
2982
- const graphicType = metadataItem.GraphicType
2983
- const coordinateDimensionality = _getCoordinateDimensionality(metadataItem)
2984
- const commonZCoordinate = _getCommonZCoordinate(metadataItem)
2985
-
2986
- const source = annotationGroup.layer.getSource()
2987
- const features = source.getFeatures()
2988
-
2989
- const client = this[_options].client
2990
- const promises = [
2991
- _fetchGraphicData({ metadataItem, bulkdataItem, client }),
2992
- _fetchGraphicIndex({ metadataItem, bulkdataItem, client }),
2993
- _fetchMeasurements({ metadataItem, bulkdataItem, client })
2994
- ]
2995
- Promise.all(promises).then(retrievedBulkdata => {
2996
- const graphicData = retrievedBulkdata[0]
2997
- const graphicIndex = retrievedBulkdata[1]
2998
- const measurements = retrievedBulkdata[2]
2999
-
3000
- for (let i = 0; i < numberOfAnnotations; i++) {
3001
- const point = _getCentroid(
3002
- graphicType,
3003
- graphicData,
3004
- graphicIndex,
3005
- coordinateDimensionality,
3006
- commonZCoordinate,
3007
- i,
3008
- numberOfAnnotations
3009
- )
3010
- const feature = new Feature({
3011
- geometry: new PointGeometry(
3012
- _scoord3dCoordinates2geometryCoordinates(
3013
- point,
3014
- this[_pyramid].metadata
3015
- )
3016
- )
3017
- })
3018
- const properties = {}
3019
- measurements.forEach(item => {
3020
- const name = item.name
3021
- const key = `${name.CodingSchemeDesignator}${name.CodeValue}`
3022
- const value = item.values[i]
3023
- properties[key] = value
3024
- })
3025
- feature.setProperties(properties)
3026
- feature.setId(i + 1)
3027
- features.push(feature)
3028
- }
3029
-
3030
- console.log(
3031
- `add n=${features.length} annotations ` +
3032
- `for annotation group "${annotationGroupUID}"`
3033
- )
3034
- source.addFeatures(features)
3035
- const properties = {}
3036
- measurements.forEach(item => {
3037
- const name = item.name
3038
- const key = `${name.CodingSchemeDesignator}${name.CodeValue}`
3039
- const value = quantileSeq(
3040
- [...item.values],
3041
- [0, 0.015, 0.25, 0.5, 0.75, 0.95, 1]
3042
- )
3043
- properties[key] = value
3044
- })
3045
- source.setProperties(properties)
3046
- publish(container, EVENT.LOADING_ENDED)
3047
- }).catch(error => {
3048
- console.error(error)
3049
- publish(container, EVENT.LOADING_ENDED)
3050
- })
3051
- }
3052
-
3053
3044
  /**
3054
3045
  * Hide an annotation group.
3055
3046
  *
@@ -3380,7 +3371,7 @@ class VolumeImageViewer {
3380
3371
  extent: this[_pyramid].extent,
3381
3372
  visible: false,
3382
3373
  opacity: 0.9,
3383
- preload: 0,
3374
+ preload: this[_options].preload ? 1 : 0,
3384
3375
  transition: 0,
3385
3376
  style: _getColorPaletteStyleForTileLayer({
3386
3377
  windowCenter,
@@ -3431,8 +3422,8 @@ class VolumeImageViewer {
3431
3422
  * Show a segment.
3432
3423
  *
3433
3424
  * @param {string} segmentUID - Unique tracking identifier of a segment
3434
- * @param {Object} styleOptions
3435
- * @param {number} styleOptions.opacity - Opacity
3425
+ * @param {Object} [styleOptions]
3426
+ * @param {number} [styleOptions.opacity] - Opacity
3436
3427
  */
3437
3428
  showSegment (segmentUID, styleOptions = {}) {
3438
3429
  if (!(segmentUID in this[_segments])) {
@@ -3485,7 +3476,7 @@ class VolumeImageViewer {
3485
3476
  *
3486
3477
  * @param {string} segmentUID - Unique tracking identifier of segment
3487
3478
  * @param {Object} styleOptions - Style options
3488
- * @param {number} styleOptions.opacity - Opacity
3479
+ * @param {number} [styleOptions.opacity] - Opacity
3489
3480
  */
3490
3481
  setSegmentStyle (segmentUID, styleOptions = {}) {
3491
3482
  if (!(segmentUID in this[_segments])) {
@@ -3600,7 +3591,7 @@ class VolumeImageViewer {
3600
3591
  /**
3601
3592
  * Add parameter mappings.
3602
3593
  *
3603
- * @param {ParametricMap[]} metadata - Metadata of one or more DICOM Parametric Map instances
3594
+ * @param {metadata.ParametricMap[]} metadata - Metadata of one or more DICOM Parametric Map instances
3604
3595
  */
3605
3596
  addParameterMappings (metadata) {
3606
3597
  if (metadata.length === 0) {
@@ -3811,7 +3802,7 @@ class VolumeImageViewer {
3811
3802
  projection: this[_projection],
3812
3803
  visible: false,
3813
3804
  opacity: 1,
3814
- preload: 1,
3805
+ preload: this[_options].preload ? 1 : 0,
3815
3806
  transition: 0,
3816
3807
  style: _getColorPaletteStyleForTileLayer({
3817
3808
  windowCenter,
@@ -3861,9 +3852,9 @@ class VolumeImageViewer {
3861
3852
  * Show a parameter mapping.
3862
3853
  *
3863
3854
  * @param {string} mappingUID - Unique tracking identifier of a mapping
3864
- * @param {Object} styleOptions
3865
- * @param {number} styleOptions.opacity - Opacity
3866
- * @param {number} styleOptions.limitValues - Opacity
3855
+ * @param {Object} [styleOptions]
3856
+ * @param {number} [styleOptions.opacity] - Opacity
3857
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
3867
3858
  */
3868
3859
  showParameterMapping (mappingUID, styleOptions = {}) {
3869
3860
  if (!(mappingUID in this[_mappings])) {
@@ -3916,7 +3907,8 @@ class VolumeImageViewer {
3916
3907
  *
3917
3908
  * @param {string} mappingUID - Unique tracking identifier of mapping
3918
3909
  * @param {Object} styleOptions
3919
- * @param {number} styleOptions.opacity - Opacity
3910
+ * @param {number} [styleOptions.opacity] - Opacity
3911
+ * @param {number[]} [styleOptions.limitValues] - Upper and lower windowing
3920
3912
  */
3921
3913
  setParameterMappingStyle (mappingUID, styleOptions = {}) {
3922
3914
  if (!(mappingUID in this[_mappings])) {
@@ -4304,7 +4296,7 @@ export { LabelImageViewer, OverviewImageViewer, VolumeImageViewer }
4304
4296
  <br class="clear">
4305
4297
 
4306
4298
  <footer>
4307
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Sat Mar 12 2022 12:50:08 GMT-0500 (Eastern Standard Time)
4299
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Mon May 16 2022 17:56:50 GMT-0400 (Eastern Daylight Time)
4308
4300
  </footer>
4309
4301
 
4310
4302
  <script> prettyPrint(); </script>