@cornerstonejs/tools 4.22.13 → 5.0.0

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 (225) hide show
  1. package/dist/esm/config.d.ts +4 -0
  2. package/dist/esm/drawingSvg/drawPath.d.ts +3 -0
  3. package/dist/esm/drawingSvg/drawPath.js +4 -1
  4. package/dist/esm/eventListeners/keyboard/keyDownListener.js +2 -2
  5. package/dist/esm/eventListeners/mouse/getMouseEventPoints.d.ts +1 -1
  6. package/dist/esm/eventListeners/mouse/getMouseEventPoints.js +19 -1
  7. package/dist/esm/eventListeners/mouse/mouseDoubleClickListener.js +8 -1
  8. package/dist/esm/eventListeners/mouse/mouseDownListener.js +37 -5
  9. package/dist/esm/eventListeners/mouse/mouseMoveListener.js +3 -0
  10. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +60 -92
  11. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +49 -21
  12. package/dist/esm/eventListeners/segmentation/labelmap/performStackLabelmapUpdate.js +7 -13
  13. package/dist/esm/eventListeners/segmentation/labelmap/performVolumeLabelmapUpdate.js +44 -18
  14. package/dist/esm/eventListeners/touch/getTouchEventPoints.js +27 -4
  15. package/dist/esm/eventListeners/touch/touchStartListener.js +27 -9
  16. package/dist/esm/eventListeners/wheel/wheelListener.js +5 -1
  17. package/dist/esm/init.js +2 -0
  18. package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +10 -4
  19. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +23 -20
  20. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.d.ts +12 -0
  21. package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.js +7 -0
  22. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -11
  23. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +28 -166
  24. package/dist/esm/stateManagement/segmentation/addColorLUT.js +7 -1
  25. package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.js +16 -1
  26. package/dist/esm/stateManagement/segmentation/helpers/clearSegmentValue.js +9 -7
  27. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.d.ts +1 -1
  28. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.js +3 -2
  29. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.d.ts +5 -0
  30. package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.js +58 -0
  31. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.d.ts +52 -0
  32. package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.js +246 -0
  33. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.d.ts +1 -0
  34. package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.js +1 -0
  35. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +11 -1
  36. package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -3
  37. package/dist/esm/stateManagement/segmentation/labelmapModel/index.d.ts +9 -0
  38. package/dist/esm/stateManagement/segmentation/labelmapModel/index.js +7 -0
  39. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.d.ts +54 -0
  40. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.js +224 -0
  41. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.d.ts +6 -0
  42. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.js +39 -0
  43. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.d.ts +23 -0
  44. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.js +269 -0
  45. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.d.ts +15 -0
  46. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.js +160 -0
  47. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.d.ts +4 -0
  48. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.js +42 -0
  49. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.d.ts +11 -0
  50. package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.js +73 -0
  51. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.d.ts +17 -0
  52. package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.js +75 -0
  53. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.d.ts +5 -0
  54. package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.js +106 -0
  55. package/dist/esm/stateManagement/segmentation/models/SegmentModel.d.ts +11 -0
  56. package/dist/esm/stateManagement/segmentation/models/SegmentModel.js +19 -0
  57. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.d.ts +12 -0
  58. package/dist/esm/stateManagement/segmentation/models/SegmentationModel.js +23 -0
  59. package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +6 -10
  60. package/dist/esm/stateManagement/segmentation/segmentIndex.js +24 -0
  61. package/dist/esm/stateManagement/segmentation/segmentationEventManager.js +2 -9
  62. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
  63. package/dist/esm/stateManagement/segmentation/segmentationState.js +4 -1
  64. package/dist/esm/store/state.js +2 -1
  65. package/dist/esm/synchronizers/callbacks/imageSliceSyncCallback.js +12 -3
  66. package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +5 -2
  67. package/dist/esm/synchronizers/callbacks/zoomPanSyncCallback.js +51 -3
  68. package/dist/esm/tools/AdvancedMagnifyTool.js +1 -1
  69. package/dist/esm/tools/CrosshairsTool.js +5 -5
  70. package/dist/esm/tools/OrientationControllerTool.js +1 -1
  71. package/dist/esm/tools/OrientationMarkerTool.js +4 -4
  72. package/dist/esm/tools/PanTool.js +26 -3
  73. package/dist/esm/tools/PlanarRotateTool.js +19 -4
  74. package/dist/esm/tools/ReferenceCursors.js +7 -1
  75. package/dist/esm/tools/SculptorTool/CircleSculptCursor.js +1 -1
  76. package/dist/esm/tools/TrackballRotateTool.js +3 -2
  77. package/dist/esm/tools/VolumeCroppingTool.js +3 -2
  78. package/dist/esm/tools/WindowLevelTool.d.ts +2 -1
  79. package/dist/esm/tools/WindowLevelTool.js +48 -4
  80. package/dist/esm/tools/ZoomTool.d.ts +8 -0
  81. package/dist/esm/tools/ZoomTool.js +92 -11
  82. package/dist/esm/tools/annotation/AngleTool.js +33 -31
  83. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +30 -28
  84. package/dist/esm/tools/annotation/BidirectionalTool.js +51 -49
  85. package/dist/esm/tools/annotation/CircleROITool.js +49 -44
  86. package/dist/esm/tools/annotation/CobbAngleTool.js +1 -1
  87. package/dist/esm/tools/annotation/DragProbeTool.js +1 -1
  88. package/dist/esm/tools/annotation/ETDRSGridTool.js +1 -1
  89. package/dist/esm/tools/annotation/EllipticalROITool.js +42 -37
  90. package/dist/esm/tools/annotation/HeightTool.js +1 -1
  91. package/dist/esm/tools/annotation/KeyImageTool.js +11 -11
  92. package/dist/esm/tools/annotation/LabelTool.js +37 -35
  93. package/dist/esm/tools/annotation/LengthTool.js +35 -33
  94. package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +6 -4
  95. package/dist/esm/tools/annotation/LivewireContourTool.js +1 -1
  96. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +6 -4
  97. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +1 -1
  98. package/dist/esm/tools/annotation/ProbeTool.js +51 -46
  99. package/dist/esm/tools/annotation/RectangleROITool.js +42 -37
  100. package/dist/esm/tools/annotation/RegionSegmentPlusTool.js +1 -1
  101. package/dist/esm/tools/annotation/RegionSegmentTool.js +1 -1
  102. package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +1 -1
  103. package/dist/esm/tools/annotation/SplineROITool.js +51 -49
  104. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +1 -1
  105. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +57 -55
  106. package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
  107. package/dist/esm/tools/base/AnnotationDisplayTool.js +9 -6
  108. package/dist/esm/tools/base/AnnotationTool.js +2 -1
  109. package/dist/esm/tools/base/BaseTool.js +16 -10
  110. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -1
  111. package/dist/esm/tools/base/GrowCutBaseTool.js +2 -2
  112. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -4
  113. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +15 -85
  114. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.d.ts +5 -0
  115. package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.js +191 -0
  116. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +4 -3
  117. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +48 -209
  118. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.d.ts +3 -0
  119. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.js +51 -0
  120. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.d.ts +4 -0
  121. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.js +3 -0
  122. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.d.ts +14 -0
  123. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +143 -0
  124. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.d.ts +40 -0
  125. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.js +79 -0
  126. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.d.ts +3 -0
  127. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.js +18 -0
  128. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.d.ts +9 -0
  129. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.js +56 -0
  130. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.d.ts +11 -0
  131. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.js +35 -0
  132. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.d.ts +48 -0
  133. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.js +0 -0
  134. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.d.ts +13 -0
  135. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.js +34 -0
  136. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.d.ts +2 -0
  137. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.js +1 -0
  138. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.d.ts +8 -0
  139. package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.js +18 -0
  140. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js +2 -5
  141. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.d.ts +3 -0
  142. package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.js +16 -0
  143. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.d.ts +2 -0
  144. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +135 -0
  145. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.d.ts +16 -0
  146. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.js +267 -0
  147. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.d.ts +27 -0
  148. package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.js +185 -0
  149. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.d.ts +1 -0
  150. package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.js +16 -0
  151. package/dist/esm/tools/segmentation/BrushTool.d.ts +9 -2
  152. package/dist/esm/tools/segmentation/BrushTool.js +109 -25
  153. package/dist/esm/tools/segmentation/CircleScissorsTool.js +13 -6
  154. package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +2 -3
  155. package/dist/esm/tools/segmentation/LabelmapBaseTool.js +77 -38
  156. package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -3
  157. package/dist/esm/tools/segmentation/PaintFillTool.js +11 -4
  158. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +2 -0
  159. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +16 -8
  160. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +13 -6
  161. package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +63 -61
  162. package/dist/esm/tools/segmentation/SegmentSelectTool.js +4 -4
  163. package/dist/esm/tools/segmentation/SphereScissorsTool.js +5 -1
  164. package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +7 -0
  165. package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +47 -24
  166. package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +49 -15
  167. package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +2 -2
  168. package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +5 -1
  169. package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +2 -2
  170. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
  171. package/dist/esm/tools/segmentation/strategies/compositions/setValue.js +14 -6
  172. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.d.ts +4 -0
  173. package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.js +23 -0
  174. package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +1 -1
  175. package/dist/esm/tools/segmentation/strategies/utils/handleUseSegmentCenterIndex.js +12 -11
  176. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.d.ts +4 -0
  177. package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.js +41 -0
  178. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.d.ts +3 -0
  179. package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.js +31 -0
  180. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.d.ts +3 -0
  181. package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.js +38 -0
  182. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.d.ts +19 -0
  183. package/dist/esm/tools/segmentation/utils/LazyBrushEditController.js +55 -0
  184. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.d.ts +3 -0
  185. package/dist/esm/tools/segmentation/utils/lazyBrushPreview.js +34 -0
  186. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.d.ts +3 -0
  187. package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.js +42 -0
  188. package/dist/esm/types/LabelmapToolOperationData.d.ts +5 -0
  189. package/dist/esm/types/LabelmapTypes.d.ts +29 -6
  190. package/dist/esm/types/SegmentationStateTypes.d.ts +4 -0
  191. package/dist/esm/utilities/calibrateImageSpacing.js +17 -2
  192. package/dist/esm/utilities/contours/AnnotationToPointData.js +1 -1
  193. package/dist/esm/utilities/getSphereBoundsInfo.js +5 -1
  194. package/dist/esm/utilities/getViewportICamera.d.ts +4 -0
  195. package/dist/esm/utilities/getViewportICamera.js +23 -0
  196. package/dist/esm/utilities/getViewportsForAnnotation.js +5 -1
  197. package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +9 -7
  198. package/dist/esm/utilities/pointInSurroundingSphereCallback.js +8 -1
  199. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +121 -118
  200. package/dist/esm/utilities/segmentation/SegmentStatsCalculator.js +5 -4
  201. package/dist/esm/utilities/segmentation/VolumetricCalculator.js +1 -1
  202. package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js +1 -1
  203. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentation.js +1 -1
  204. package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentationVolume.js +11 -2
  205. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +36 -17
  206. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +42 -25
  207. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -30
  208. package/dist/esm/utilities/segmentation/index.d.ts +2 -1
  209. package/dist/esm/utilities/segmentation/index.js +2 -1
  210. package/dist/esm/utilities/segmentation/utilsForWorker.js +2 -2
  211. package/dist/esm/utilities/segmentation/validateLabelmap.js +1 -1
  212. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +0 -1
  213. package/dist/esm/utilities/touch/index.js +3 -2
  214. package/dist/esm/utilities/viewportCapabilities.d.ts +16 -0
  215. package/dist/esm/utilities/viewportCapabilities.js +18 -0
  216. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.d.ts +1 -1
  217. package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.js +12 -4
  218. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.d.ts +1 -1
  219. package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.js +11 -4
  220. package/dist/esm/utilities/viewportFilters/getViewportIdsWithToolToRender.js +1 -1
  221. package/dist/esm/utilities/viewportPresentation.d.ts +3 -0
  222. package/dist/esm/utilities/viewportPresentation.js +26 -0
  223. package/dist/esm/version.d.ts +1 -1
  224. package/dist/esm/version.js +1 -1
  225. package/package.json +10 -10
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  import { utilities as csUtils } from '@cornerstonejs/core';
2
3
  import { state as annotationState } from '../../../stateManagement/annotation';
3
4
  import getInterpolationDataCollection from '../../contours/interpolation/getInterpolationDataCollection';
@@ -11,8 +12,7 @@ const ChangeTypesForInterpolation = [
11
12
  ChangeTypes.HandlesUpdated,
12
13
  ChangeTypes.InterpolationUpdated,
13
14
  ];
14
- export default class InterpolationManager {
15
- static { this.toolNames = []; }
15
+ class InterpolationManager {
16
16
  static addTool(toolName) {
17
17
  if (!this.toolNames.includes(toolName)) {
18
18
  this.toolNames.push(toolName);
@@ -25,7 +25,7 @@ export default class InterpolationManager {
25
25
  }
26
26
  static acceptAutoGenerated(annotationGroupSelector, selector = {}) {
27
27
  const { toolNames, segmentationId, segmentIndex, sliceIndex } = selector;
28
- for (const toolName of toolNames || InterpolationManager.toolNames) {
28
+ for (const toolName of toolNames || _a.toolNames) {
29
29
  const annotations = annotationState.getAnnotations(toolName, annotationGroupSelector);
30
30
  if (!annotations?.length) {
31
31
  continue;
@@ -55,124 +55,127 @@ export default class InterpolationManager {
55
55
  }
56
56
  }
57
57
  }
58
- static { this.handleAnnotationCompleted = (evt) => {
59
- const annotation = evt.detail.annotation;
60
- if (!annotation?.metadata) {
61
- return;
62
- }
63
- const { toolName, originalToolName } = annotation.metadata;
64
- if (!this.toolNames.includes(toolName) &&
65
- !this.toolNames.includes(originalToolName)) {
66
- return;
67
- }
68
- const viewport = getViewportForAnnotation(annotation);
69
- if (!viewport) {
70
- console.warn('Unable to find viewport for', annotation);
71
- return;
72
- }
73
- const sliceData = getSliceData(viewport);
74
- const viewportData = {
75
- viewport,
76
- sliceData,
77
- annotation,
78
- interpolationUID: annotation.interpolationUID,
79
- };
80
- const hasInterpolationUID = !!annotation.interpolationUID;
81
- annotation.autoGenerated = false;
82
- if (hasInterpolationUID) {
83
- deleteRelatedAnnotations(viewportData);
84
- interpolate(viewportData);
85
- return;
86
- }
87
- const filterData = [
88
- {
89
- key: 'segmentIndex',
90
- value: annotation.data.segmentation.segmentIndex,
91
- parentKey: (annotation) => annotation.data.segmentation,
92
- },
93
- {
94
- key: 'viewPlaneNormal',
95
- value: annotation.metadata.viewPlaneNormal,
96
- parentKey: (annotation) => annotation.metadata,
97
- },
98
- {
99
- key: 'viewUp',
100
- value: annotation.metadata.viewUp,
101
- parentKey: (annotation) => annotation.metadata,
102
- },
103
- ];
104
- let interpolationAnnotations = getInterpolationDataCollection(viewportData, filterData);
105
- const { sliceIndex } = annotation.metadata;
106
- const skipUIDs = new Set();
107
- interpolationAnnotations.forEach((interpolationAnnotation) => {
108
- if (interpolationAnnotation.interpolationCompleted ||
109
- interpolationAnnotation.metadata.sliceIndex === sliceIndex) {
110
- const { interpolationUID } = interpolationAnnotation;
111
- skipUIDs.add(interpolationUID);
112
- }
113
- });
114
- interpolationAnnotations = interpolationAnnotations.filter((interpolationAnnotation) => !skipUIDs.has(interpolationAnnotation.interpolationUID));
115
- annotation.interpolationUID =
116
- interpolationAnnotations[0]?.interpolationUID || uuidv4();
117
- viewportData.interpolationUID = annotation.interpolationUID;
118
- interpolate(viewportData);
119
- }; }
120
- static { this.handleAnnotationUpdate = (evt) => {
121
- const annotation = evt.detail.annotation;
122
- const { changeType = ChangeTypes.HandlesUpdated } = evt.detail;
123
- if (!annotation?.metadata) {
124
- return;
125
- }
126
- const { toolName, originalToolName } = annotation.metadata;
127
- if ((!this.toolNames.includes(toolName) &&
128
- !this.toolNames.includes(originalToolName)) ||
129
- !ChangeTypesForInterpolation.includes(changeType)) {
130
- return;
131
- }
132
- const viewport = getViewportForAnnotation(annotation);
133
- if (!viewport) {
134
- console.warn('Unable to find matching viewport for annotation interpolation', annotation);
135
- return;
136
- }
137
- if (annotation.autoGenerated) {
138
- addContourSegmentationAnnotation(annotation);
139
- annotation.autoGenerated = false;
140
- }
141
- const sliceData = getSliceData(viewport);
142
- const viewportData = {
143
- viewport,
144
- sliceData,
145
- annotation,
146
- interpolationUID: annotation.interpolationUID,
147
- isInterpolationUpdate: changeType === ChangeTypes.InterpolationUpdated,
148
- };
58
+ }
59
+ _a = InterpolationManager;
60
+ InterpolationManager.toolNames = [];
61
+ InterpolationManager.handleAnnotationCompleted = (evt) => {
62
+ const annotation = evt.detail.annotation;
63
+ if (!annotation?.metadata) {
64
+ return;
65
+ }
66
+ const { toolName, originalToolName } = annotation.metadata;
67
+ if (!_a.toolNames.includes(toolName) &&
68
+ !_a.toolNames.includes(originalToolName)) {
69
+ return;
70
+ }
71
+ const viewport = getViewportForAnnotation(annotation);
72
+ if (!viewport) {
73
+ console.warn('Unable to find viewport for', annotation);
74
+ return;
75
+ }
76
+ const sliceData = getSliceData(viewport);
77
+ const viewportData = {
78
+ viewport,
79
+ sliceData,
80
+ annotation,
81
+ interpolationUID: annotation.interpolationUID,
82
+ };
83
+ const hasInterpolationUID = !!annotation.interpolationUID;
84
+ annotation.autoGenerated = false;
85
+ if (hasInterpolationUID) {
86
+ deleteRelatedAnnotations(viewportData);
149
87
  interpolate(viewportData);
150
- }; }
151
- static { this.handleAnnotationDelete = (evt) => {
152
- const annotation = evt.detail.annotation;
153
- if (!annotation?.metadata) {
154
- return;
155
- }
156
- const { toolName } = annotation.metadata;
157
- if (!this.toolNames.includes(toolName) || annotation.autoGenerated) {
158
- return;
159
- }
160
- const viewport = getViewportForAnnotation(annotation);
161
- if (!viewport) {
162
- console.warn("No viewport, can't delete interpolated results", annotation);
163
- return;
88
+ return;
89
+ }
90
+ const filterData = [
91
+ {
92
+ key: 'segmentIndex',
93
+ value: annotation.data.segmentation.segmentIndex,
94
+ parentKey: (annotation) => annotation.data.segmentation,
95
+ },
96
+ {
97
+ key: 'viewPlaneNormal',
98
+ value: annotation.metadata.viewPlaneNormal,
99
+ parentKey: (annotation) => annotation.metadata,
100
+ },
101
+ {
102
+ key: 'viewUp',
103
+ value: annotation.metadata.viewUp,
104
+ parentKey: (annotation) => annotation.metadata,
105
+ },
106
+ ];
107
+ let interpolationAnnotations = getInterpolationDataCollection(viewportData, filterData);
108
+ const { sliceIndex } = annotation.metadata;
109
+ const skipUIDs = new Set();
110
+ interpolationAnnotations.forEach((interpolationAnnotation) => {
111
+ if (interpolationAnnotation.interpolationCompleted ||
112
+ interpolationAnnotation.metadata.sliceIndex === sliceIndex) {
113
+ const { interpolationUID } = interpolationAnnotation;
114
+ skipUIDs.add(interpolationUID);
164
115
  }
165
- const sliceData = getSliceData(viewport);
166
- const viewportData = {
167
- viewport,
168
- sliceData,
169
- annotation,
170
- interpolationUID: annotation.interpolationUID,
171
- };
116
+ });
117
+ interpolationAnnotations = interpolationAnnotations.filter((interpolationAnnotation) => !skipUIDs.has(interpolationAnnotation.interpolationUID));
118
+ annotation.interpolationUID =
119
+ interpolationAnnotations[0]?.interpolationUID || uuidv4();
120
+ viewportData.interpolationUID = annotation.interpolationUID;
121
+ interpolate(viewportData);
122
+ };
123
+ InterpolationManager.handleAnnotationUpdate = (evt) => {
124
+ const annotation = evt.detail.annotation;
125
+ const { changeType = ChangeTypes.HandlesUpdated } = evt.detail;
126
+ if (!annotation?.metadata) {
127
+ return;
128
+ }
129
+ const { toolName, originalToolName } = annotation.metadata;
130
+ if ((!_a.toolNames.includes(toolName) &&
131
+ !_a.toolNames.includes(originalToolName)) ||
132
+ !ChangeTypesForInterpolation.includes(changeType)) {
133
+ return;
134
+ }
135
+ const viewport = getViewportForAnnotation(annotation);
136
+ if (!viewport) {
137
+ console.warn('Unable to find matching viewport for annotation interpolation', annotation);
138
+ return;
139
+ }
140
+ if (annotation.autoGenerated) {
141
+ addContourSegmentationAnnotation(annotation);
172
142
  annotation.autoGenerated = false;
173
- deleteRelatedAnnotations(viewportData);
174
- }; }
175
- }
143
+ }
144
+ const sliceData = getSliceData(viewport);
145
+ const viewportData = {
146
+ viewport,
147
+ sliceData,
148
+ annotation,
149
+ interpolationUID: annotation.interpolationUID,
150
+ isInterpolationUpdate: changeType === ChangeTypes.InterpolationUpdated,
151
+ };
152
+ interpolate(viewportData);
153
+ };
154
+ InterpolationManager.handleAnnotationDelete = (evt) => {
155
+ const annotation = evt.detail.annotation;
156
+ if (!annotation?.metadata) {
157
+ return;
158
+ }
159
+ const { toolName } = annotation.metadata;
160
+ if (!_a.toolNames.includes(toolName) || annotation.autoGenerated) {
161
+ return;
162
+ }
163
+ const viewport = getViewportForAnnotation(annotation);
164
+ if (!viewport) {
165
+ console.warn("No viewport, can't delete interpolated results", annotation);
166
+ return;
167
+ }
168
+ const sliceData = getSliceData(viewport);
169
+ const viewportData = {
170
+ viewport,
171
+ sliceData,
172
+ annotation,
173
+ interpolationUID: annotation.interpolationUID,
174
+ };
175
+ annotation.autoGenerated = false;
176
+ deleteRelatedAnnotations(viewportData);
177
+ };
178
+ export default InterpolationManager;
176
179
  function getSliceData(viewport) {
177
180
  const sliceData = {
178
181
  numberOfSlices: viewport.getNumberOfSlices(),
@@ -1,8 +1,5 @@
1
1
  import { InstanceVolumetricCalculator } from './VolumetricCalculator';
2
- export default class SegmentStatsCalculator {
3
- static { this.calculators = new Map(); }
4
- static { this.indices = []; }
5
- static { this.mode = 'collective'; }
2
+ class SegmentStatsCalculator {
6
3
  static statsInit(options) {
7
4
  const { storePointData, indices, mode } = options;
8
5
  this.mode = mode;
@@ -42,3 +39,7 @@ export default class SegmentStatsCalculator {
42
39
  return calculator.getStatistics(options);
43
40
  }
44
41
  }
42
+ SegmentStatsCalculator.calculators = new Map();
43
+ SegmentStatsCalculator.indices = [];
44
+ SegmentStatsCalculator.mode = 'collective';
45
+ export default SegmentStatsCalculator;
@@ -59,7 +59,6 @@ function volumetricGetStatistics(state, stats, options) {
59
59
  return stats;
60
60
  }
61
61
  export class VolumetricCalculator extends BasicStatsCalculator {
62
- static { this.volumetricState = createVolumetricState(); }
63
62
  static statsInit(options) {
64
63
  super.statsInit(options);
65
64
  this.volumetricState = createVolumetricState();
@@ -79,6 +78,7 @@ export class VolumetricCalculator extends BasicStatsCalculator {
79
78
  return volumetricGetStatistics(this.volumetricState, stats, optionsWithUnit);
80
79
  }
81
80
  }
81
+ VolumetricCalculator.volumetricState = createVolumetricState();
82
82
  export class InstanceVolumetricCalculator extends InstanceBasicStatsCalculator {
83
83
  constructor(options) {
84
84
  super(options);
@@ -15,7 +15,7 @@ export default async function createLabelmapVolumeForViewport(input) {
15
15
  segmentationId = `${uid}-based-segmentation-${options?.volumeId ?? csUtils.uuidv4().slice(0, 8)}`;
16
16
  }
17
17
  if (options) {
18
- const properties = structuredClone(options);
18
+ const properties = csUtils.deepClone(options);
19
19
  await volumeLoader.createLocalVolume(segmentationId, properties);
20
20
  }
21
21
  else {
@@ -17,7 +17,7 @@ export function getReferenceVolumeForSegmentation(segmentationId) {
17
17
  }
18
18
  referenceImageIds = imageIds.map((imageId) => cache.getImage(imageId).referencedImageId);
19
19
  }
20
- else if ('volumeId' in labelmap) {
20
+ else if (labelmap.volumeId) {
21
21
  const { volumeId, referencedVolumeId } = labelmap;
22
22
  if (referencedVolumeId) {
23
23
  const refVolume = cache.getVolume(referencedVolumeId);
@@ -11,9 +11,18 @@ export function getReferenceVolumeForSegmentationVolume(segmentationVolumeId) {
11
11
  }
12
12
  else {
13
13
  const imageIds = segmentationVolume.imageIds;
14
- const image = cache.getImage(imageIds[0]);
14
+ const segmentationImageId = imageIds?.[0];
15
+ if (!segmentationImageId) {
16
+ return null;
17
+ }
18
+ const image = cache.getImage(segmentationImageId);
19
+ if (!image) {
20
+ return null;
21
+ }
15
22
  const referencedImageId = image.referencedImageId;
16
- let volumeInfo = cache.getVolumeContainingImageId(referencedImageId);
23
+ let volumeInfo = referencedImageId
24
+ ? cache.getVolumeContainingImageId(referencedImageId)
25
+ : undefined;
17
26
  if (!volumeInfo?.volume) {
18
27
  volumeInfo = cache.getVolumeContainingImageId(image.imageId);
19
28
  }
@@ -1,29 +1,41 @@
1
1
  import { BaseVolumeViewport, cache, utilities } from '@cornerstonejs/core';
2
2
  import { getSegmentation, getCurrentLabelmapImageIdForViewport, } from '../../stateManagement/segmentation/segmentationState';
3
3
  import { getLabelmapActorEntry } from '../../stateManagement/segmentation/helpers';
4
+ import getViewportLabelmapRenderMode from '../../stateManagement/segmentation/helpers/getViewportLabelmapRenderMode';
5
+ import { getLabelmaps, getOrCreateLabelmapVolume, getSegmentIndexForLabelValue, } from '../../stateManagement/segmentation/helpers/labelmapSegmentationState';
4
6
  export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { viewport, searchRadius }) {
5
7
  const segmentation = getSegmentation(segmentationId);
6
- const labelmapData = segmentation.representationData.Labelmap;
7
- if (viewport instanceof BaseVolumeViewport) {
8
- const { volumeId } = labelmapData;
9
- const segmentationVolume = cache.getVolume(volumeId);
10
- if (!segmentationVolume) {
11
- return;
8
+ const viewportRenderMode = viewport
9
+ ? getViewportLabelmapRenderMode(viewport)
10
+ : 'unsupported';
11
+ if (viewportRenderMode === 'volume' ||
12
+ viewport instanceof BaseVolumeViewport) {
13
+ for (const layer of getLabelmaps(segmentation)) {
14
+ const segmentationVolume = getOrCreateLabelmapVolume(layer);
15
+ if (!segmentationVolume) {
16
+ continue;
17
+ }
18
+ const voxelManager = segmentationVolume.voxelManager;
19
+ const imageData = segmentationVolume.imageData;
20
+ const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
21
+ const labelValue = voxelManager.getAtIJK(indexIJK[0], indexIJK[1], indexIJK[2]);
22
+ const canvasPoint = viewport.worldToCanvas(worldPoint);
23
+ const onEdge = isSegmentOnEdgeCanvas(canvasPoint, labelValue, viewport, imageData, searchRadius);
24
+ if (onEdge && labelValue) {
25
+ return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
26
+ }
12
27
  }
13
- const voxelManager = segmentationVolume.voxelManager;
14
- const imageData = segmentationVolume.imageData;
15
- const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
16
- const segmentIndex = voxelManager.getAtIJK(indexIJK[0], indexIJK[1], indexIJK[2]);
17
- const canvasPoint = viewport.worldToCanvas(worldPoint);
18
- const onEdge = isSegmentOnEdgeCanvas(canvasPoint, segmentIndex, viewport, imageData, searchRadius);
19
- return onEdge ? segmentIndex : undefined;
28
+ return;
20
29
  }
21
30
  const segmentationImageId = getCurrentLabelmapImageIdForViewport(viewport.id, segmentationId);
31
+ if (!segmentationImageId) {
32
+ return;
33
+ }
22
34
  const image = cache.getImage(segmentationImageId);
23
35
  if (!image) {
24
36
  return;
25
37
  }
26
- const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentationId);
38
+ const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentationId, segmentationImageId);
27
39
  const imageData = segmentationActorEntry?.actor.getMapper().getInputData();
28
40
  const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
29
41
  const dimensions = imageData.getDimensions();
@@ -32,9 +44,16 @@ export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { vi
32
44
  dimensions,
33
45
  scalarData: imageData.getPointData().getScalars().getData(),
34
46
  }));
35
- const segmentIndex = voxelManager.getAtIJKPoint(indexIJK);
36
- const onEdge = isSegmentOnEdgeIJK(indexIJK, dimensions, voxelManager, segmentIndex);
37
- return onEdge ? segmentIndex : undefined;
47
+ const labelValue = voxelManager.getAtIJKPoint(indexIJK);
48
+ const onEdge = isSegmentOnEdgeIJK(indexIJK, dimensions, voxelManager, labelValue);
49
+ if (!onEdge || !labelValue) {
50
+ return;
51
+ }
52
+ const layer = getLabelmaps(segmentation).find((candidateLayer) => candidateLayer.imageIds?.includes(segmentationImageId));
53
+ if (!layer) {
54
+ return labelValue;
55
+ }
56
+ return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
38
57
  }
39
58
  function isSegmentOnEdge(getNeighborIndex, segmentIndex, searchRadius = 1) {
40
59
  const neighborRange = Array.from({ length: 2 * searchRadius + 1 }, (_, i) => i - searchRadius);
@@ -4,6 +4,8 @@ import { getSegmentation, getCurrentLabelmapImageIdsForViewport, } from '../../s
4
4
  import { getAnnotation } from '../../stateManagement';
5
5
  import { isPointInsidePolyline3D } from '../math/polyline';
6
6
  import { getLabelmapActorEntry } from '../../stateManagement/segmentation/helpers/getSegmentationActor';
7
+ import getViewportLabelmapRenderMode from '../../stateManagement/segmentation/helpers/getViewportLabelmapRenderMode';
8
+ import { getLabelmaps, getOrCreateLabelmapVolume, getSegmentIndexForLabelValue, } from '../../stateManagement/segmentation/helpers/labelmapSegmentationState';
7
9
  export function getSegmentIndexAtWorldPoint(segmentationId, worldPoint, options = {}) {
8
10
  const segmentation = getSegmentation(segmentationId);
9
11
  const representationData = segmentation.representationData;
@@ -21,37 +23,52 @@ export function getSegmentIndexAtWorldPoint(segmentationId, worldPoint, options
21
23
  }
22
24
  }
23
25
  export function getSegmentIndexAtWorldForLabelmap(segmentation, worldPoint, { viewport }) {
24
- const labelmapData = segmentation.representationData.Labelmap;
25
- if (viewport instanceof BaseVolumeViewport) {
26
- const { volumeId } = labelmapData;
27
- const segmentationVolume = cache.getVolume(volumeId);
28
- if (!segmentationVolume) {
29
- return;
26
+ const viewportRenderMode = viewport
27
+ ? getViewportLabelmapRenderMode(viewport)
28
+ : 'unsupported';
29
+ if (viewportRenderMode === 'volume' ||
30
+ viewport instanceof BaseVolumeViewport) {
31
+ for (const layer of getLabelmaps(segmentation)) {
32
+ const segmentationVolume = getOrCreateLabelmapVolume(layer);
33
+ if (!segmentationVolume) {
34
+ continue;
35
+ }
36
+ const labelValue = segmentationVolume.imageData.getScalarValueFromWorld(worldPoint);
37
+ if (!labelValue) {
38
+ continue;
39
+ }
40
+ return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
30
41
  }
31
- const segmentIndex = segmentationVolume.imageData.getScalarValueFromWorld(worldPoint);
32
- return segmentIndex;
42
+ return;
33
43
  }
34
44
  const segmentationImageIds = getCurrentLabelmapImageIdsForViewport(viewport.id, segmentation.segmentationId);
35
- if (segmentationImageIds.length > 1) {
36
- console.warn('Segment selection for labelmaps with multiple imageIds in stack viewports is not supported yet.');
45
+ if (!segmentationImageIds?.length) {
37
46
  return;
38
47
  }
39
- const segmentationImageId = segmentationImageIds[0];
40
- const image = cache.getImage(segmentationImageId);
41
- if (!image) {
42
- return;
48
+ for (const segmentationImageId of segmentationImageIds) {
49
+ const image = cache.getImage(segmentationImageId);
50
+ if (!image) {
51
+ continue;
52
+ }
53
+ const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentation.segmentationId, segmentationImageId);
54
+ const imageData = segmentationActorEntry?.actor.getMapper().getInputData();
55
+ const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
56
+ const dimensions = imageData.getDimensions();
57
+ const voxelManager = (imageData.voxelManager ||
58
+ utilities.VoxelManager.createScalarVolumeVoxelManager({
59
+ dimensions,
60
+ scalarData: imageData.getPointData().getScalars().getData(),
61
+ }));
62
+ const labelValue = voxelManager.getAtIJKPoint(indexIJK);
63
+ if (!labelValue) {
64
+ continue;
65
+ }
66
+ const layer = getLabelmaps(segmentation).find((candidateLayer) => candidateLayer.imageIds?.includes(segmentationImageId));
67
+ if (!layer) {
68
+ return labelValue;
69
+ }
70
+ return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
43
71
  }
44
- const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentation.segmentationId);
45
- const imageData = segmentationActorEntry?.actor.getMapper().getInputData();
46
- const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
47
- const dimensions = imageData.getDimensions();
48
- const voxelManager = (imageData.voxelManager ||
49
- utilities.VoxelManager.createScalarVolumeVoxelManager({
50
- dimensions,
51
- scalarData: imageData.getPointData().getScalars().getData(),
52
- }));
53
- const segmentIndex = voxelManager.getAtIJKPoint(indexIJK);
54
- return segmentIndex;
55
72
  }
56
73
  export function getSegmentIndexAtWorldForContour(segmentation, worldPoint, { viewport }) {
57
74
  const contourData = segmentation.representationData.Contour;
@@ -13,7 +13,7 @@ function getUniqueSegmentIndices(segmentationId) {
13
13
  }
14
14
  let indices;
15
15
  if (segmentation.representationData.Labelmap) {
16
- indices = handleLabelmapSegmentation(segmentation, segmentationId);
16
+ indices = handleLabelmapSegmentation(segmentation);
17
17
  }
18
18
  else if (segmentation.representationData.Contour) {
19
19
  indices = handleContourSegmentation(segmentation);
@@ -27,38 +27,11 @@ function getUniqueSegmentIndices(segmentationId) {
27
27
  setCachedSegmentIndices(segmentationId, indices);
28
28
  return indices;
29
29
  }
30
- function handleLabelmapSegmentation(segmentation, segmentationId) {
31
- const labelmapData = segmentation.representationData[SegmentationRepresentations.Labelmap];
32
- const keySet = new Set();
33
- if (labelmapData.imageIds) {
34
- addImageSegmentIndices(keySet, labelmapData.imageIds);
35
- }
36
- else {
37
- addVolumeSegmentIndices(keySet, segmentationId);
38
- }
39
- return Array.from(keySet)
30
+ function handleLabelmapSegmentation(segmentation) {
31
+ return Object.keys(segmentation.segments)
40
32
  .map(Number)
41
33
  .sort((a, b) => a - b);
42
34
  }
43
- function addVolumeSegmentIndices(keySet, segmentationId) {
44
- const volume = cache.getVolume(segmentationId);
45
- volume.voxelManager.forEach(({ value }) => {
46
- if (value !== 0) {
47
- keySet.add(value);
48
- }
49
- });
50
- }
51
- function addImageSegmentIndices(keySet, imageIds) {
52
- imageIds.forEach((segmentationImageId) => {
53
- const image = cache.getImage(segmentationImageId);
54
- const scalarData = image.voxelManager.getScalarData();
55
- scalarData.forEach((segmentIndex) => {
56
- if (segmentIndex !== 0) {
57
- keySet.add(segmentIndex);
58
- }
59
- });
60
- });
61
- }
62
35
  function handleContourSegmentation(segmentation) {
63
36
  const { annotationUIDsMap, geometryIds } = segmentation.representationData.Contour || {};
64
37
  if (!geometryIds) {
@@ -28,6 +28,7 @@ import * as validateLabelmap from './validateLabelmap';
28
28
  import { computeStackLabelmapFromVolume } from '../../stateManagement/segmentation/helpers/computeStackLabelmapFromVolume';
29
29
  import { computeVolumeLabelmapFromStack } from '../../stateManagement/segmentation/helpers/computeVolumeLabelmapFromStack';
30
30
  import { getReferenceVolumeForSegmentationVolume } from './getReferenceVolumeForSegmentationVolume';
31
+ import { getReferenceVolumeForSegmentation } from './getReferenceVolumeForSegmentation';
31
32
  import { getSegmentLargestBidirectional } from './getSegmentLargestBidirectional';
32
33
  import { computeMetabolicStats } from './computeMetabolicStats';
33
- export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getSegmentLargestBidirectional, computeMetabolicStats, };
34
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getReferenceVolumeForSegmentation, getSegmentLargestBidirectional, computeMetabolicStats, };
@@ -28,6 +28,7 @@ import * as validateLabelmap from './validateLabelmap';
28
28
  import { computeStackLabelmapFromVolume } from '../../stateManagement/segmentation/helpers/computeStackLabelmapFromVolume';
29
29
  import { computeVolumeLabelmapFromStack } from '../../stateManagement/segmentation/helpers/computeVolumeLabelmapFromStack';
30
30
  import { getReferenceVolumeForSegmentationVolume } from './getReferenceVolumeForSegmentationVolume';
31
+ import { getReferenceVolumeForSegmentation } from './getReferenceVolumeForSegmentation';
31
32
  import { getSegmentLargestBidirectional } from './getSegmentLargestBidirectional';
32
33
  import { computeMetabolicStats } from './computeMetabolicStats';
33
- export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getSegmentLargestBidirectional, computeMetabolicStats, };
34
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getReferenceVolumeForSegmentation, getSegmentLargestBidirectional, computeMetabolicStats, };
@@ -29,8 +29,8 @@ export const getSegmentationDataForWorker = (segmentationId, segmentIndices) =>
29
29
  volumeId: segVolumeId,
30
30
  imageIds: segImageIds,
31
31
  };
32
- let reconstructableVolume = false;
33
- if (segImageIds) {
32
+ let reconstructableVolume = Boolean(segVolumeId);
33
+ if (!reconstructableVolume && segImageIds) {
34
34
  const refImageIds = segImageIds.map((imageId) => {
35
35
  const image = cache.getImage(imageId);
36
36
  return image.referencedImageId;
@@ -1,6 +1,6 @@
1
1
  import { cache } from '@cornerstonejs/core';
2
2
  function validateRepresentationData(segmentationRepresentationData) {
3
- if ('volumeId' in segmentationRepresentationData) {
3
+ if (segmentationRepresentationData.volumeId) {
4
4
  segmentationRepresentationData =
5
5
  segmentationRepresentationData;
6
6
  const cachedVolume = cache.getVolume(segmentationRepresentationData.volumeId);
@@ -58,7 +58,6 @@ function prefetch(element) {
58
58
  let nextImageIdIndex;
59
59
  const preventCache = false;
60
60
  function doneCallback(imageId) {
61
- console.log('prefetch done: %s', imageId);
62
61
  const imageIdIndex = stack.imageIds.indexOf(imageId);
63
62
  removeFromList(imageIdIndex);
64
63
  if (stackPrefetch.indicesToRequest.length === 0) {
@@ -1,3 +1,4 @@
1
+ import { utilities } from '@cornerstonejs/core';
1
2
  function getDeltaPoints(currentPoints, lastPoints) {
2
3
  const curr = getMeanPoints(currentPoints);
3
4
  const last = getMeanPoints(lastPoints);
@@ -32,10 +33,10 @@ function getDeltaDistanceBetweenIPoints(currentPoints, lastPoints) {
32
33
  return deltaDistance;
33
34
  }
34
35
  function copyPointsList(points) {
35
- return JSON.parse(JSON.stringify(points));
36
+ return utilities.deepClone(points);
36
37
  }
37
38
  function copyPoints(points) {
38
- return JSON.parse(JSON.stringify(points));
39
+ return utilities.deepClone(points);
39
40
  }
40
41
  function getMeanPoints(points) {
41
42
  return points.reduce((prev, curr) => {
@@ -0,0 +1,16 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export type ImageSliceViewport = Types.IViewport & {
3
+ getCurrentImageId(): string | undefined;
4
+ getCurrentImageIdIndex(): number;
5
+ getImageIds(): string[];
6
+ hasImageURI(imageURI: string): boolean;
7
+ };
8
+ export type StackCompatibilityViewport = ImageSliceViewport & {
9
+ setStack(imageIds: string[], currentImageIdIndex?: number): Promise<string> | string;
10
+ };
11
+ export type StackCalibrationViewport = ImageSliceViewport & {
12
+ calibrateSpacing(imageId: string): void;
13
+ };
14
+ export declare function viewportSupportsImageSlices(viewport: unknown): viewport is ImageSliceViewport;
15
+ export declare function viewportSupportsStackCompatibility(viewport: unknown): viewport is StackCompatibilityViewport;
16
+ export declare function viewportSupportsStackCalibration(viewport: unknown): viewport is StackCalibrationViewport;