@cornerstonejs/tools 1.41.0 → 1.42.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 (280) hide show
  1. package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
  2. package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
  3. package/dist/cjs/eventListeners/segmentation/imageChangeEventListener.js +18 -5
  4. package/dist/cjs/eventListeners/segmentation/imageChangeEventListener.js.map +1 -1
  5. package/dist/cjs/stateManagement/annotation/annotationState.js +3 -0
  6. package/dist/cjs/stateManagement/annotation/annotationState.js.map +1 -1
  7. package/dist/cjs/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +10 -0
  8. package/dist/cjs/stateManagement/segmentation/convertStackToVolumeSegmentation.js +65 -0
  9. package/dist/cjs/stateManagement/segmentation/convertStackToVolumeSegmentation.js.map +1 -0
  10. package/dist/cjs/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +8 -0
  11. package/dist/cjs/stateManagement/segmentation/convertVolumeToStackSegmentation.js +92 -0
  12. package/dist/cjs/stateManagement/segmentation/convertVolumeToStackSegmentation.js.map +1 -0
  13. package/dist/cjs/stateManagement/segmentation/index.d.ts +3 -1
  14. package/dist/cjs/stateManagement/segmentation/index.js +5 -1
  15. package/dist/cjs/stateManagement/segmentation/index.js.map +1 -1
  16. package/dist/cjs/stateManagement/segmentation/segmentationState.d.ts +2 -1
  17. package/dist/cjs/stateManagement/segmentation/segmentationState.js +8 -1
  18. package/dist/cjs/stateManagement/segmentation/segmentationState.js.map +1 -1
  19. package/dist/cjs/store/ToolGroupManager/ToolGroup.js +3 -0
  20. package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
  21. package/dist/cjs/tools/annotation/AngleTool.js +2 -2
  22. package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
  23. package/dist/cjs/tools/annotation/BidirectionalTool.js +8 -7
  24. package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
  25. package/dist/cjs/tools/annotation/CircleROITool.js +8 -8
  26. package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
  27. package/dist/cjs/tools/annotation/EllipticalROITool.js +7 -7
  28. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  29. package/dist/cjs/tools/annotation/LengthTool.js +2 -2
  30. package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
  31. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +5 -5
  32. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  33. package/dist/cjs/tools/annotation/ProbeTool.js +3 -3
  34. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  35. package/dist/cjs/tools/annotation/RectangleROITool.js +7 -7
  36. package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
  37. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +10 -0
  38. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  39. package/dist/cjs/tools/segmentation/BrushTool.js +8 -4
  40. package/dist/cjs/tools/segmentation/BrushTool.js.map +1 -1
  41. package/dist/cjs/tools/segmentation/strategies/fillCircle.js +4 -6
  42. package/dist/cjs/tools/segmentation/strategies/fillCircle.js.map +1 -1
  43. package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.d.ts +1 -1
  44. package/dist/cjs/tools/segmentation/strategies/utils/isWithinThreshold.js.map +1 -1
  45. package/dist/cjs/types/index.d.ts +2 -1
  46. package/dist/cjs/utilities/contours/AnnotationToPointData.d.ts +11 -0
  47. package/dist/cjs/utilities/contours/AnnotationToPointData.js +44 -0
  48. package/dist/cjs/utilities/contours/AnnotationToPointData.js.map +1 -0
  49. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.d.ts +6 -0
  50. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js +43 -0
  51. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
  52. package/dist/cjs/utilities/contours/contourFinder.d.ts +7 -0
  53. package/dist/cjs/utilities/contours/contourFinder.js +68 -0
  54. package/dist/cjs/utilities/contours/contourFinder.js.map +1 -0
  55. package/dist/cjs/utilities/contours/detectContourHoles.d.ts +5 -0
  56. package/dist/cjs/utilities/contours/detectContourHoles.js +78 -0
  57. package/dist/cjs/utilities/contours/detectContourHoles.js.map +1 -0
  58. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.d.ts +4 -0
  59. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js +124 -0
  60. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
  61. package/dist/cjs/utilities/contours/index.d.ts +6 -0
  62. package/dist/cjs/utilities/contours/index.js +17 -0
  63. package/dist/cjs/utilities/contours/index.js.map +1 -0
  64. package/dist/cjs/utilities/contours/mergePoints.d.ts +8 -0
  65. package/dist/cjs/utilities/contours/mergePoints.js +77 -0
  66. package/dist/cjs/utilities/contours/mergePoints.js.map +1 -0
  67. package/dist/cjs/utilities/index.d.ts +4 -2
  68. package/dist/cjs/utilities/index.js +8 -5
  69. package/dist/cjs/utilities/index.js.map +1 -1
  70. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +1 -0
  71. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js +31 -0
  72. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
  73. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.d.ts +14 -0
  74. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js +43 -0
  75. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
  76. package/dist/cjs/utilities/segmentation/createImageIdReferenceMap.d.ts +2 -0
  77. package/dist/cjs/utilities/segmentation/createImageIdReferenceMap.js +11 -0
  78. package/dist/cjs/utilities/segmentation/createImageIdReferenceMap.js.map +1 -0
  79. package/dist/cjs/utilities/segmentation/findLargestBidirectional.d.ts +1 -0
  80. package/dist/cjs/utilities/segmentation/findLargestBidirectional.js +94 -0
  81. package/dist/cjs/utilities/segmentation/findLargestBidirectional.js.map +1 -0
  82. package/dist/cjs/utilities/segmentation/index.d.ts +5 -1
  83. package/dist/cjs/utilities/segmentation/index.js +9 -1
  84. package/dist/cjs/utilities/segmentation/index.js.map +1 -1
  85. package/dist/cjs/utilities/segmentation/isLineInSegment.d.ts +9 -0
  86. package/dist/cjs/utilities/segmentation/isLineInSegment.js +55 -0
  87. package/dist/cjs/utilities/segmentation/isLineInSegment.js.map +1 -0
  88. package/dist/cjs/utilities/segmentation/segmentContourAction.d.ts +17 -0
  89. package/dist/cjs/utilities/segmentation/segmentContourAction.js +122 -0
  90. package/dist/cjs/utilities/segmentation/segmentContourAction.js.map +1 -0
  91. package/dist/cjs/utilities/segmentation/thresholdSegmentationByRange.js.map +1 -1
  92. package/dist/cjs/utilities/segmentation/triggerSegmentationRender.js +8 -4
  93. package/dist/cjs/utilities/segmentation/triggerSegmentationRender.js.map +1 -1
  94. package/dist/cjs/utilities/stackPrefetch/stackContextPrefetch.js +2 -5
  95. package/dist/cjs/utilities/stackPrefetch/stackContextPrefetch.js.map +1 -1
  96. package/dist/cjs/utilities/stackPrefetch/stackPrefetchUtils.js +2 -1
  97. package/dist/cjs/utilities/stackPrefetch/stackPrefetchUtils.js.map +1 -1
  98. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
  99. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
  100. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +18 -5
  101. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js.map +1 -1
  102. package/dist/esm/stateManagement/annotation/annotationState.js +3 -0
  103. package/dist/esm/stateManagement/annotation/annotationState.js.map +1 -1
  104. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js +47 -0
  105. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js.map +1 -0
  106. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +72 -0
  107. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js.map +1 -0
  108. package/dist/esm/stateManagement/segmentation/index.js +3 -1
  109. package/dist/esm/stateManagement/segmentation/index.js.map +1 -1
  110. package/dist/esm/stateManagement/segmentation/segmentationState.js +7 -1
  111. package/dist/esm/stateManagement/segmentation/segmentationState.js.map +1 -1
  112. package/dist/esm/store/ToolGroupManager/ToolGroup.js +3 -0
  113. package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
  114. package/dist/esm/tools/annotation/AngleTool.js +1 -1
  115. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  116. package/dist/esm/tools/annotation/BidirectionalTool.js +8 -7
  117. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  118. package/dist/esm/tools/annotation/CircleROITool.js +1 -1
  119. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  120. package/dist/esm/tools/annotation/EllipticalROITool.js +1 -1
  121. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  122. package/dist/esm/tools/annotation/LengthTool.js +1 -1
  123. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  124. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +1 -1
  125. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  126. package/dist/esm/tools/annotation/ProbeTool.js +1 -1
  127. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  128. package/dist/esm/tools/annotation/RectangleROITool.js +1 -1
  129. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  130. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +11 -1
  131. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  132. package/dist/esm/tools/segmentation/BrushTool.js +8 -4
  133. package/dist/esm/tools/segmentation/BrushTool.js.map +1 -1
  134. package/dist/esm/tools/segmentation/strategies/fillCircle.js +4 -6
  135. package/dist/esm/tools/segmentation/strategies/fillCircle.js.map +1 -1
  136. package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.js.map +1 -1
  137. package/dist/esm/utilities/contours/AnnotationToPointData.js +39 -0
  138. package/dist/esm/utilities/contours/AnnotationToPointData.js.map +1 -0
  139. package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js +41 -0
  140. package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
  141. package/dist/esm/utilities/contours/contourFinder.js +63 -0
  142. package/dist/esm/utilities/contours/contourFinder.js.map +1 -0
  143. package/dist/esm/utilities/contours/detectContourHoles.js +74 -0
  144. package/dist/esm/utilities/contours/detectContourHoles.js.map +1 -0
  145. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +117 -0
  146. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
  147. package/dist/esm/utilities/contours/index.js +7 -0
  148. package/dist/esm/utilities/contours/index.js.map +1 -0
  149. package/dist/esm/utilities/contours/mergePoints.js +73 -0
  150. package/dist/esm/utilities/contours/mergePoints.js.map +1 -0
  151. package/dist/esm/utilities/index.js +4 -2
  152. package/dist/esm/utilities/index.js.map +1 -1
  153. package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js +25 -0
  154. package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
  155. package/dist/esm/utilities/segmentation/createBidirectionalToolData.js +40 -0
  156. package/dist/esm/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
  157. package/dist/esm/utilities/segmentation/createImageIdReferenceMap.js +8 -0
  158. package/dist/esm/utilities/segmentation/createImageIdReferenceMap.js.map +1 -0
  159. package/dist/esm/utilities/segmentation/findLargestBidirectional.js +96 -0
  160. package/dist/esm/utilities/segmentation/findLargestBidirectional.js.map +1 -0
  161. package/dist/esm/utilities/segmentation/index.js +5 -1
  162. package/dist/esm/utilities/segmentation/index.js.map +1 -1
  163. package/dist/esm/utilities/segmentation/isLineInSegment.js +50 -0
  164. package/dist/esm/utilities/segmentation/isLineInSegment.js.map +1 -0
  165. package/dist/esm/utilities/segmentation/segmentContourAction.js +98 -0
  166. package/dist/esm/utilities/segmentation/segmentContourAction.js.map +1 -0
  167. package/dist/esm/utilities/segmentation/thresholdSegmentationByRange.js.map +1 -1
  168. package/dist/esm/utilities/segmentation/triggerSegmentationRender.js +8 -4
  169. package/dist/esm/utilities/segmentation/triggerSegmentationRender.js.map +1 -1
  170. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js +1 -1
  171. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js.map +1 -1
  172. package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.js +2 -1
  173. package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.js.map +1 -1
  174. package/dist/types/eventDispatchers/keyboardEventHandlers/keyDown.d.ts.map +1 -1
  175. package/dist/types/eventListeners/segmentation/imageChangeEventListener.d.ts.map +1 -1
  176. package/dist/types/stateManagement/annotation/annotationState.d.ts.map +1 -1
  177. package/dist/types/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +11 -0
  178. package/dist/types/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts.map +1 -0
  179. package/dist/types/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +9 -0
  180. package/dist/types/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts.map +1 -0
  181. package/dist/types/stateManagement/segmentation/index.d.ts +3 -1
  182. package/dist/types/stateManagement/segmentation/index.d.ts.map +1 -1
  183. package/dist/types/stateManagement/segmentation/segmentationState.d.ts +2 -1
  184. package/dist/types/stateManagement/segmentation/segmentationState.d.ts.map +1 -1
  185. package/dist/types/store/ToolGroupManager/ToolGroup.d.ts.map +1 -1
  186. package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
  187. package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
  188. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
  189. package/dist/types/tools/displayTools/Labelmap/labelmapDisplay.d.ts.map +1 -1
  190. package/dist/types/tools/segmentation/BrushTool.d.ts.map +1 -1
  191. package/dist/types/tools/segmentation/strategies/fillCircle.d.ts.map +1 -1
  192. package/dist/types/tools/segmentation/strategies/utils/isWithinThreshold.d.ts +1 -1
  193. package/dist/types/tools/segmentation/strategies/utils/isWithinThreshold.d.ts.map +1 -1
  194. package/dist/types/types/LabelmapTypes.d.ts.map +1 -1
  195. package/dist/types/types/index.d.ts +2 -1
  196. package/dist/types/types/index.d.ts.map +1 -1
  197. package/dist/types/utilities/contours/AnnotationToPointData.d.ts +12 -0
  198. package/dist/types/utilities/contours/AnnotationToPointData.d.ts.map +1 -0
  199. package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts +7 -0
  200. package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts.map +1 -0
  201. package/dist/types/utilities/contours/contourFinder.d.ts +8 -0
  202. package/dist/types/utilities/contours/contourFinder.d.ts.map +1 -0
  203. package/dist/types/utilities/contours/detectContourHoles.d.ts +6 -0
  204. package/dist/types/utilities/contours/detectContourHoles.d.ts.map +1 -0
  205. package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts +5 -0
  206. package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts.map +1 -0
  207. package/dist/types/utilities/contours/index.d.ts +7 -0
  208. package/dist/types/utilities/contours/index.d.ts.map +1 -0
  209. package/dist/types/utilities/contours/mergePoints.d.ts +9 -0
  210. package/dist/types/utilities/contours/mergePoints.d.ts.map +1 -0
  211. package/dist/types/utilities/index.d.ts +4 -2
  212. package/dist/types/utilities/index.d.ts.map +1 -1
  213. package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +2 -0
  214. package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts.map +1 -0
  215. package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts +15 -0
  216. package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts.map +1 -0
  217. package/dist/types/utilities/segmentation/createImageIdReferenceMap.d.ts +3 -0
  218. package/dist/types/utilities/segmentation/createImageIdReferenceMap.d.ts.map +1 -0
  219. package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts +2 -0
  220. package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts.map +1 -0
  221. package/dist/types/utilities/segmentation/index.d.ts +5 -1
  222. package/dist/types/utilities/segmentation/index.d.ts.map +1 -1
  223. package/dist/types/utilities/segmentation/isLineInSegment.d.ts +10 -0
  224. package/dist/types/utilities/segmentation/isLineInSegment.d.ts.map +1 -0
  225. package/dist/types/utilities/segmentation/segmentContourAction.d.ts +18 -0
  226. package/dist/types/utilities/segmentation/segmentContourAction.d.ts.map +1 -0
  227. package/dist/types/utilities/segmentation/triggerSegmentationRender.d.ts.map +1 -1
  228. package/dist/types/utilities/stackPrefetch/stackPrefetchUtils.d.ts.map +1 -1
  229. package/dist/umd/index.js +1 -1
  230. package/dist/umd/index.js.map +1 -1
  231. package/package.json +3 -3
  232. package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +7 -1
  233. package/src/eventListeners/segmentation/imageChangeEventListener.ts +42 -6
  234. package/src/stateManagement/annotation/annotationState.ts +3 -0
  235. package/src/stateManagement/segmentation/convertStackToVolumeSegmentation.ts +98 -0
  236. package/src/stateManagement/segmentation/convertVolumeToStackSegmentation.ts +153 -0
  237. package/src/stateManagement/segmentation/index.ts +4 -0
  238. package/src/stateManagement/segmentation/segmentationState.ts +17 -0
  239. package/src/store/ToolGroupManager/ToolGroup.ts +4 -0
  240. package/src/tools/annotation/AngleTool.ts +1 -2
  241. package/src/tools/annotation/BidirectionalTool.ts +10 -6
  242. package/src/tools/annotation/CircleROITool.ts +1 -1
  243. package/src/tools/annotation/EllipticalROITool.ts +1 -1
  244. package/src/tools/annotation/LengthTool.ts +1 -1
  245. package/src/tools/annotation/PlanarFreehandROITool.ts +1 -2
  246. package/src/tools/annotation/ProbeTool.ts +1 -1
  247. package/src/tools/annotation/RectangleROITool.ts +1 -1
  248. package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +16 -2
  249. package/src/tools/segmentation/BrushTool.ts +11 -7
  250. package/src/tools/segmentation/strategies/fillCircle.ts +4 -7
  251. package/src/tools/segmentation/strategies/utils/isWithinThreshold.ts +1 -1
  252. package/src/types/LabelmapTypes.ts +2 -5
  253. package/src/types/index.ts +2 -0
  254. package/src/utilities/contours/AnnotationToPointData.ts +61 -0
  255. package/src/utilities/contours/RectangleROIStartEndThreshold.ts +60 -0
  256. package/src/utilities/contours/contourFinder.ts +78 -0
  257. package/src/utilities/contours/detectContourHoles.ts +147 -0
  258. package/src/utilities/contours/generateContourSetsFromLabelmap.ts +160 -0
  259. package/src/utilities/contours/index.ts +14 -0
  260. package/src/utilities/contours/mergePoints.ts +108 -0
  261. package/src/utilities/index.ts +6 -1
  262. package/src/utilities/segmentation/contourAndFindLargestBidirectional.ts +46 -0
  263. package/src/utilities/segmentation/createBidirectionalToolData.ts +68 -0
  264. package/src/utilities/segmentation/createImageIdReferenceMap.ts +23 -0
  265. package/src/utilities/segmentation/findLargestBidirectional.ts +159 -0
  266. package/src/utilities/segmentation/index.ts +8 -0
  267. package/src/utilities/segmentation/isLineInSegment.ts +84 -0
  268. package/src/utilities/segmentation/segmentContourAction.ts +169 -0
  269. package/src/utilities/segmentation/thresholdSegmentationByRange.ts +2 -2
  270. package/src/utilities/segmentation/triggerSegmentationRender.ts +15 -10
  271. package/src/utilities/stackPrefetch/stackContextPrefetch.ts +1 -1
  272. package/src/utilities/stackPrefetch/stackPrefetchUtils.ts +5 -1
  273. package/dist/cjs/utilities/roundNumber.d.ts +0 -2
  274. package/dist/cjs/utilities/roundNumber.js +0 -30
  275. package/dist/cjs/utilities/roundNumber.js.map +0 -1
  276. package/dist/esm/utilities/roundNumber.js +0 -28
  277. package/dist/esm/utilities/roundNumber.js.map +0 -1
  278. package/dist/types/utilities/roundNumber.d.ts +0 -3
  279. package/dist/types/utilities/roundNumber.d.ts.map +0 -1
  280. package/src/utilities/roundNumber.ts +0 -44
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.41.0",
3
+ "version": "1.42.1",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.41.0",
32
+ "@cornerstonejs/core": "^1.42.1",
33
33
  "comlink": "^4.4.1",
34
34
  "lodash.clonedeep": "4.5.0",
35
35
  "lodash.get": "^4.4.2"
@@ -53,5 +53,5 @@
53
53
  "type": "individual",
54
54
  "url": "https://ohif.org/donate"
55
55
  },
56
- "gitHead": "a151cd133119685c23a9aa7b739e5b7a55312bd1"
56
+ "gitHead": "14a1bff3ba983b6664529e8e829a655cc4ffda89"
57
57
  }
@@ -34,7 +34,13 @@ export default function keyDown(evt: KeyDownEventType): void {
34
34
  if (activeToolsWithEventBinding?.size) {
35
35
  const { element } = evt.detail;
36
36
  for (const [key, value] of [...activeToolsWithEventBinding.entries()]) {
37
- key[value.method](element);
37
+ // Calls the method that implements the action, which can be a string
38
+ // in which case it belongs to the tool instance, or a function
39
+ // Call it on the tool instance, with the element and configuration value
40
+ // so that the method can depend on the specific configuration in use.
41
+ const method =
42
+ typeof value.method === 'function' ? value.method : key[value.method];
43
+ method.call(key, element, value);
38
44
  }
39
45
  }
40
46
  }
@@ -1,3 +1,5 @@
1
+ import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
2
+ import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
1
3
  import {
2
4
  StackViewport,
3
5
  getEnabledElement,
@@ -6,15 +8,12 @@ import {
6
8
  cache,
7
9
  utilities,
8
10
  Types,
9
- metaData,
10
11
  } from '@cornerstonejs/core';
11
12
  import { getToolGroupForViewport } from '../../store/ToolGroupManager';
12
13
  import Representations from '../../enums/SegmentationRepresentations';
13
14
  import * as SegmentationState from '../../stateManagement/segmentation/segmentationState';
14
15
  import { LabelmapSegmentationDataStack } from '../../types/LabelmapTypes';
15
16
  import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
16
- import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
17
- import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
18
17
  import triggerSegmentationRender from '../../utilities/segmentation/triggerSegmentationRender';
19
18
 
20
19
  const enable = function (element: HTMLDivElement): void {
@@ -118,6 +117,26 @@ function _imageChangeEventListener(evt) {
118
117
  const currentImageId = viewport.getCurrentImageId();
119
118
  const actors = viewport.getActors();
120
119
 
120
+ const segmentationFound = actors.find((actor) => {
121
+ if (!representationList.includes(actor.uid)) {
122
+ return false;
123
+ }
124
+
125
+ return true;
126
+ });
127
+
128
+ if (!segmentationFound) {
129
+ // If the segmentation is not found, it could be because of some special cases
130
+ // where we are in the process of updating the volume conversion to a stack while
131
+ // the data is still coming in. In such situations, we should trigger the render
132
+ // to ensure that the segmentation actors are created, even if the data arrives late.
133
+ triggerSegmentationRender(toolGroup.id);
134
+
135
+ // we should return here, since there is no segmentation actor to update
136
+ // we will hit this function later on after the actor is created
137
+ return;
138
+ }
139
+
121
140
  actors.forEach((actor) => {
122
141
  if (!representationList.includes(actor.uid)) {
123
142
  return;
@@ -148,10 +167,27 @@ function _imageChangeEventListener(evt) {
148
167
 
149
168
  const derivedImage = cache.getImage(derivedImageId);
150
169
 
151
- const { origin, dimensions, spacing, direction } =
170
+ const { dimensions, spacing, direction } =
152
171
  viewport.getImageDataMetadata(derivedImage);
153
172
 
154
- segmentationImageData.setOrigin(origin);
173
+ const currentImage = cache.getImage(currentImageId);
174
+ const { origin: currentOrigin } =
175
+ viewport.getImageDataMetadata(currentImage);
176
+
177
+ // IMPORTANT: We need to make sure that the origin of the segmentation
178
+ // is the same as the current image origin. This is because due to some
179
+ // floating point precision issues, when coming from volume to stack
180
+ // the origin of the segmentation can be slightly different from the
181
+ // current image origin. This can cause the segmentation to be rendered
182
+ // in the wrong location.
183
+ // Todo: This will not work for segmentations that are not in the same frame
184
+ // of reference or derived from the same image. This can happen when we have
185
+ // a segmentation that happens to exist in the same space as the image but is
186
+ // not derived from it. We need to find a way to handle this case, but don't think
187
+ // it makes sense to do it for the stack viewport, as the volume viewport is designed to handle this case.
188
+ const originToUse = currentOrigin;
189
+
190
+ segmentationImageData.setOrigin(originToUse);
155
191
  segmentationImageData.modified();
156
192
 
157
193
  if (
@@ -180,7 +216,7 @@ function _imageChangeEventListener(evt) {
180
216
  imageData.setDimensions(dimensions[0], dimensions[1], 1);
181
217
  imageData.setSpacing(spacing);
182
218
  imageData.setDirection(direction);
183
- imageData.setOrigin(origin);
219
+ imageData.setOrigin(originToUse);
184
220
  imageData.getPointData().setScalars(scalarArray);
185
221
 
186
222
  imageActor.getMapper().setInputData(imageData);
@@ -126,6 +126,9 @@ function getNumberOfAnnotations(
126
126
  * @param annotationUID - The unique identifier for the annotation.
127
127
  */
128
128
  function removeAnnotation(annotationUID: string): void {
129
+ if (!annotationUID) {
130
+ return;
131
+ }
129
132
  const manager = getAnnotationManager();
130
133
  const annotation = manager.getAnnotation(annotationUID);
131
134
 
@@ -0,0 +1,98 @@
1
+ import {
2
+ volumeLoader,
3
+ utilities as csUtils,
4
+ eventTarget,
5
+ } from '@cornerstonejs/core';
6
+ import { Events, SegmentationRepresentations } from '../../enums';
7
+ import addSegmentations from './addSegmentations';
8
+ import addSegmentationRepresentations from './addSegmentationRepresentations';
9
+ import { triggerSegmentationRender } from '../../utilities/segmentation';
10
+ import { getSegmentation, removeSegmentation } from './segmentationState';
11
+ import { LabelmapSegmentationDataStack } from '../../types/LabelmapTypes';
12
+ import { triggerSegmentationDataModified } from './triggerSegmentationEvents';
13
+
14
+ /**
15
+ * Converts a stack-based segmentation to a volume-based segmentation.
16
+ *
17
+ * @param params - The parameters for the conversion.
18
+ * @param params.segmentationId - The segmentationId to convert.
19
+ * @param [params.options] - The conversion options.
20
+ * @param params.options.toolGroupId - The new toolGroupId to use for the segmentation.
21
+ * @param [params.options.volumeId] - the new volumeId to use for the segmentation. If not provided, a new ID will be generated.
22
+ * @param [params.options.newSegmentationId] - the new segmentationId to use for the segmentation. If not provided, a new ID will be generated.
23
+ * @param [params.options.removeOriginal] - Whether or not to remove the original segmentation. Defaults to true.
24
+ *
25
+ * @returns A promise that resolves when the conversion is complete.
26
+ */
27
+ async function convertStackToVolumeSegmentation({
28
+ segmentationId,
29
+ options,
30
+ }: {
31
+ segmentationId: string;
32
+ options?: {
33
+ toolGroupId: string;
34
+ volumeId?: string;
35
+ newSegmentationId?: string;
36
+ removeOriginal?: boolean;
37
+ };
38
+ }): Promise<void> {
39
+ const segmentation = getSegmentation(segmentationId);
40
+ const { toolGroupId } = options;
41
+ const data = segmentation.representationData
42
+ .LABELMAP as LabelmapSegmentationDataStack;
43
+
44
+ const imageIdReferenceMap = data.imageIdReferenceMap;
45
+
46
+ // Get the imageIds from the imageIdReferenceMap
47
+ const segmentationImageIds = Array.from(imageIdReferenceMap.values());
48
+
49
+ const additionalDetails = {
50
+ imageIdReferenceMap,
51
+ };
52
+
53
+ // Since segmentations are already cached and are not
54
+ // loaded like volumes, we can create a volume out of their images
55
+ const volumeId = options?.volumeId;
56
+
57
+ await volumeLoader.createAndCacheVolumeFromImages(
58
+ volumeId,
59
+ segmentationImageIds,
60
+ {
61
+ additionalDetails,
62
+ }
63
+ );
64
+
65
+ const newSegmentationId = options?.newSegmentationId ?? csUtils.uuidv4();
66
+
67
+ if (options?.removeOriginal ?? true) {
68
+ removeSegmentation(segmentationId);
69
+ }
70
+
71
+ await addSegmentations([
72
+ {
73
+ segmentationId: newSegmentationId,
74
+ representation: {
75
+ type: SegmentationRepresentations.Labelmap,
76
+ data: {
77
+ volumeId,
78
+ },
79
+ },
80
+ },
81
+ ]);
82
+
83
+ await addSegmentationRepresentations(toolGroupId, [
84
+ {
85
+ segmentationId: newSegmentationId,
86
+ type: SegmentationRepresentations.Labelmap,
87
+ },
88
+ ]);
89
+
90
+ triggerSegmentationRender(toolGroupId);
91
+ // Note: It is crucial to trigger the data modified event. This ensures that the
92
+ // old texture is updated to the GPU, especially in scenarios where it may not be getting updated.
93
+ eventTarget.addEventListenerOnce(Events.SEGMENTATION_RENDERED, () =>
94
+ triggerSegmentationDataModified(newSegmentationId)
95
+ );
96
+ }
97
+
98
+ export { convertStackToVolumeSegmentation };
@@ -0,0 +1,153 @@
1
+ import {
2
+ Types,
3
+ cache,
4
+ utilities as csUtils,
5
+ eventTarget,
6
+ } from '@cornerstonejs/core';
7
+ import { Events, SegmentationRepresentations } from '../../enums';
8
+ import addSegmentations from './addSegmentations';
9
+ import addSegmentationRepresentations from './addSegmentationRepresentations';
10
+ import {
11
+ triggerSegmentationRender,
12
+ createImageIdReferenceMap,
13
+ } from '../../utilities/segmentation';
14
+ import { getSegmentation, removeSegmentation } from './segmentationState';
15
+ import { LabelmapSegmentationDataVolume } from '../../types/LabelmapTypes';
16
+ import { triggerSegmentationDataModified } from './triggerSegmentationEvents';
17
+
18
+ /**
19
+ * Converts a volume segmentation to a stack segmentation.
20
+ *
21
+ * @param params - The parameters for the conversion.
22
+ * @param params.segmentationId - The segmentationId to convert.
23
+ * @param [params.options] - The conversion options.
24
+ * @param params.options.toolGroupId - The new toolGroupId that the new segmentation will belong to.
25
+ * @param [params.options.newSegmentationId] - The new segmentationId to use for the segmentation. If not provided, a new ID will be generated.
26
+ * @param [params.options.removeOriginal] - Whether or not to remove the original segmentation. Defaults to true.
27
+ *
28
+ * @returns A promise that resolves when the conversion is complete.
29
+ */
30
+ export async function convertVolumeToStackSegmentation({
31
+ segmentationId,
32
+ options,
33
+ }: {
34
+ segmentationId: string;
35
+ options?: {
36
+ toolGroupId: string;
37
+ newSegmentationId?: string;
38
+ removeOriginal?: boolean;
39
+ };
40
+ }): Promise<void> {
41
+ const segmentation = getSegmentation(segmentationId);
42
+
43
+ const { toolGroupId } = options;
44
+ const data = segmentation.representationData
45
+ .LABELMAP as LabelmapSegmentationDataVolume;
46
+
47
+ const segmentationVolume = cache.getVolume(
48
+ data.volumeId
49
+ ) as Types.IImageVolume;
50
+
51
+ const imageIdReferenceMap =
52
+ _getImageIdReferenceMapForStackSegmentation(segmentationVolume);
53
+
54
+ const newSegmentationId = options?.newSegmentationId ?? csUtils.uuidv4();
55
+
56
+ if (options?.removeOriginal ?? true) {
57
+ removeSegmentation(segmentationId);
58
+ }
59
+
60
+ await addSegmentations([
61
+ {
62
+ segmentationId: newSegmentationId,
63
+ representation: {
64
+ type: SegmentationRepresentations.Labelmap,
65
+ data: {
66
+ imageIdReferenceMap,
67
+ },
68
+ },
69
+ },
70
+ ]);
71
+ // Add the segmentation representation to the toolgroup
72
+ await addSegmentationRepresentations(toolGroupId, [
73
+ {
74
+ segmentationId: newSegmentationId,
75
+ type: SegmentationRepresentations.Labelmap,
76
+ },
77
+ ]);
78
+
79
+ triggerSegmentationRender(toolGroupId);
80
+ // Note: It is crucial to trigger the data modified event. This ensures that the
81
+ // old texture is updated to the GPU, especially in scenarios where it may not be getting updated.
82
+ eventTarget.addEventListenerOnce(Events.SEGMENTATION_RENDERED, () =>
83
+ triggerSegmentationDataModified(newSegmentationId)
84
+ );
85
+ }
86
+
87
+ function _getImageIdReferenceMapForStackSegmentation(
88
+ segmentationVolume: Types.IImageVolume
89
+ ) {
90
+ // There might be or might not be segmentationImageIds, if it is a volume
91
+ // segmentation converted from stack segmentation, there will be segmentationImageIds
92
+ // otherwise, if it is empty volume segmentation derived from
93
+ // a volume that is not a stack, there will be no segmentationImageIds
94
+ const segmentationImageIds = segmentationVolume.imageIds;
95
+
96
+ if (segmentationVolume.additionalDetails?.imageIdReferenceMap) {
97
+ // this means the segmentation volume is derived from a stack segmentation
98
+ // and we can use the imageIdReferenceMap from the additionalDetails
99
+ return segmentationVolume.additionalDetails.imageIdReferenceMap;
100
+ } else if (
101
+ segmentationVolume.referencedImageIds?.length &&
102
+ !segmentationVolume.referencedImageIds[0].startsWith('derived')
103
+ ) {
104
+ // this means the segmentation volume is derived from a stack segmentation
105
+ // and we can use the referencedImageIds from the segmentationVolume
106
+ const referencedImageIds = segmentationVolume.referencedImageIds;
107
+
108
+ return createImageIdReferenceMap(referencedImageIds, segmentationImageIds);
109
+ } else {
110
+ // check if the segmentation volume is derived from another volume and
111
+ // whether if that volume has imageIds
112
+ const referencedVolumeId = segmentationVolume.referencedVolumeId;
113
+ const referencedVolume = cache.getVolume(referencedVolumeId);
114
+
115
+ if (!referencedVolume) {
116
+ throw new Error(
117
+ 'Cannot convert volumetric segmentation without referenced volume to stack segmentation yet'
118
+ );
119
+ }
120
+
121
+ if (!referencedVolume?.imageIds?.length) {
122
+ throw new Error(
123
+ 'Cannot convert volumetric segmentation without imageIds to stack segmentation yet'
124
+ );
125
+ }
126
+
127
+ if (referencedVolume.imageIds?.[0].startsWith('derived')) {
128
+ throw new Error(
129
+ `Cannot convert volume segmentation that is derived from another segmentation
130
+ to stack segmentation yet, include the additionalDetails.imageIdReferenceMap
131
+ in the volume segmentation in case you need it for the conversion`
132
+ );
133
+ }
134
+
135
+ // if the referenced volume has imageIds, and itself is not derived from
136
+ // another segmentation then we can use the imageIds from the referenced volume
137
+ const referencedImageIds = referencedVolume.imageIds;
138
+
139
+ let segmentationImageIdsToUse = segmentationVolume.imageIds;
140
+ if (!segmentationImageIdsToUse?.length) {
141
+ // If segmentation Ids don't exist it means that the segmentation is literally
142
+ // just a volume so we need to assume imageIds and decache it to the _imageCache
143
+ // so that it can be used for the conversion
144
+ segmentationImageIdsToUse =
145
+ segmentationVolume.convertToImageSlicesAndCache();
146
+ }
147
+
148
+ return createImageIdReferenceMap(
149
+ referencedImageIds,
150
+ segmentationImageIdsToUse
151
+ );
152
+ }
153
+ }
@@ -1,6 +1,8 @@
1
1
  import removeSegmentationsFromToolGroup from './removeSegmentationsFromToolGroup';
2
2
  import addSegmentations from './addSegmentations';
3
3
  import addSegmentationRepresentations from './addSegmentationRepresentations';
4
+ import { convertStackToVolumeSegmentation } from './convertStackToVolumeSegmentation';
5
+ import { convertVolumeToStackSegmentation } from './convertVolumeToStackSegmentation';
4
6
 
5
7
  import * as activeSegmentation from './activeSegmentation';
6
8
  import * as segmentLocking from './segmentLocking';
@@ -19,4 +21,6 @@ export {
19
21
  config,
20
22
  segmentIndex,
21
23
  triggerSegmentationEvents,
24
+ convertStackToVolumeSegmentation,
25
+ convertVolumeToStackSegmentation,
22
26
  };
@@ -368,6 +368,22 @@ function removeSegmentationRepresentation(
368
368
  );
369
369
  }
370
370
 
371
+ /**
372
+ * Removes all segmentation representations associated with a tool group.
373
+ * @param toolGroupId - The ID of the tool group.
374
+ */
375
+ function removeSegmentationRepresentations(toolGroupId: string): void {
376
+ const segmentationRepresentations =
377
+ getSegmentationRepresentations(toolGroupId) || [];
378
+
379
+ segmentationRepresentations.forEach((representation) => {
380
+ removeSegmentationRepresentation(
381
+ toolGroupId,
382
+ representation.segmentationRepresentationUID
383
+ );
384
+ });
385
+ }
386
+
371
387
  /**
372
388
  * Add a color LUT to the segmentation state manager
373
389
  * @param colorLUT - The color LUT array to add.
@@ -415,6 +431,7 @@ export {
415
431
  getSegmentationRepresentations,
416
432
  addSegmentationRepresentation,
417
433
  removeSegmentationRepresentation,
434
+ removeSegmentationRepresentations,
418
435
  // config
419
436
  getToolGroupSpecificConfig,
420
437
  setToolGroupSpecificConfig,
@@ -185,6 +185,10 @@ export default class ToolGroup implements IToolGroup {
185
185
  * @param renderingEngineId - The rendering engine to use.
186
186
  */
187
187
  public addViewport(viewportId: string, renderingEngineId?: string): void {
188
+ if (typeof viewportId !== 'string') {
189
+ throw new Error('viewportId must be defined and be a string');
190
+ }
191
+
188
192
  const renderingEngines = getRenderingEngines();
189
193
 
190
194
  if (!renderingEngineId && renderingEngines.length > 1) {
@@ -16,7 +16,7 @@ import {
16
16
  import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
17
17
  import * as lineSegment from '../../utilities/math/line';
18
18
  import angleBetweenLines from '../../utilities/math/angle/angleBetweenLines';
19
- import roundNumber from '../../utilities/roundNumber';
19
+ import { roundNumber } from '../../utilities';
20
20
 
21
21
  import {
22
22
  drawHandles as drawHandlesSvg,
@@ -25,7 +25,6 @@ import {
25
25
  } from '../../drawingSvg';
26
26
  import { state } from '../../store';
27
27
  import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
28
- import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
29
28
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
30
29
  import {
31
30
  AnnotationCompletedEventDetail,
@@ -11,7 +11,7 @@ import {
11
11
  getCalibratedLengthUnits,
12
12
  getCalibratedScale,
13
13
  } from '../../utilities/getCalibratedUnits';
14
- import roundNumber from '../../utilities/roundNumber';
14
+ import { roundNumber } from '../../utilities';
15
15
  import { AnnotationTool } from '../base';
16
16
  import throttle from '../../utilities/throttle';
17
17
  import {
@@ -1348,19 +1348,23 @@ class BidirectionalTool extends AnnotationTool {
1348
1348
  }
1349
1349
 
1350
1350
  function defaultGetTextLines(data, targetId): string[] {
1351
- const { cachedStats } = data;
1351
+ const { cachedStats, label } = data;
1352
1352
  const { length, width, unit } = cachedStats[targetId];
1353
1353
 
1354
+ const textLines = [];
1355
+ if (label) {
1356
+ textLines.push(label);
1357
+ }
1354
1358
  if (length === undefined) {
1355
- return;
1359
+ return textLines;
1356
1360
  }
1357
1361
 
1358
1362
  // spaceBetweenSlices & pixelSpacing &
1359
1363
  // magnitude in each direction? Otherwise, this is "px"?
1360
- const textLines = [
1364
+ textLines.push(
1361
1365
  `L: ${roundNumber(length)} ${unit}`,
1362
- `W: ${roundNumber(width)} ${unit}`,
1363
- ];
1366
+ `W: ${roundNumber(width)} ${unit}`
1367
+ );
1364
1368
 
1365
1369
  return textLines;
1366
1370
  }
@@ -15,7 +15,7 @@ import {
15
15
  getCalibratedScale,
16
16
  getCalibratedAspect,
17
17
  } from '../../utilities/getCalibratedUnits';
18
- import roundNumber from '../../utilities/roundNumber';
18
+ import { roundNumber } from '../../utilities';
19
19
  import throttle from '../../utilities/throttle';
20
20
  import {
21
21
  addAnnotation,
@@ -13,7 +13,7 @@ import {
13
13
  getCalibratedAreaUnits,
14
14
  getCalibratedScale,
15
15
  } from '../../utilities/getCalibratedUnits';
16
- import roundNumber from '../../utilities/roundNumber';
16
+ import { roundNumber } from '../../utilities';
17
17
  import throttle from '../../utilities/throttle';
18
18
  import {
19
19
  addAnnotation,
@@ -8,7 +8,7 @@ import {
8
8
  import type { Types } from '@cornerstonejs/core';
9
9
 
10
10
  import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
11
- import roundNumber from '../../utilities/roundNumber';
11
+ import { roundNumber } from '../../utilities';
12
12
  import { AnnotationTool } from '../base';
13
13
  import throttle from '../../utilities/throttle';
14
14
  import {
@@ -3,7 +3,6 @@ import {
3
3
  getEnabledElement,
4
4
  triggerEvent,
5
5
  eventTarget,
6
- StackViewport,
7
6
  VolumeViewport,
8
7
  utilities as csUtils,
9
8
  } from '@cornerstonejs/core';
@@ -14,7 +13,7 @@ import {
14
13
  getCalibratedAreaUnits,
15
14
  getCalibratedScale,
16
15
  } from '../../utilities/getCalibratedUnits';
17
- import roundNumber from '../../utilities/roundNumber';
16
+ import { roundNumber } from '../../utilities';
18
17
  import { Events } from '../../enums';
19
18
  import { AnnotationTool } from '../base';
20
19
  import {
@@ -24,7 +24,7 @@ import {
24
24
  import { state } from '../../store';
25
25
  import { Events } from '../../enums';
26
26
  import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
27
- import roundNumber from '../../utilities/roundNumber';
27
+ import { roundNumber } from '../../utilities';
28
28
  import {
29
29
  resetElementCursor,
30
30
  hideElementCursor,
@@ -13,7 +13,7 @@ import {
13
13
  getCalibratedAreaUnits,
14
14
  getCalibratedScale,
15
15
  } from '../../utilities/getCalibratedUnits';
16
- import roundNumber from '../../utilities/roundNumber';
16
+ import { roundNumber } from '../../utilities';
17
17
  import throttle from '../../utilities/throttle';
18
18
  import {
19
19
  addAnnotation,
@@ -4,12 +4,13 @@ import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransf
4
4
  import {
5
5
  cache,
6
6
  getEnabledElementByIds,
7
+ StackViewport,
7
8
  Types,
8
9
  utilities,
10
+ VolumeViewport,
9
11
  } from '@cornerstonejs/core';
10
12
 
11
13
  import Representations from '../../../enums/SegmentationRepresentations';
12
- import * as SegmentationConfig from '../../../stateManagement/segmentation/config/segmentationConfig';
13
14
  import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
14
15
  import { getToolGroup } from '../../../store/ToolGroupManager';
15
16
  import type {
@@ -18,7 +19,6 @@ import type {
18
19
  LabelmapSegmentationData,
19
20
  } from '../../../types/LabelmapTypes';
20
21
  import {
21
- RepresentationPublicInput,
22
22
  SegmentationRepresentationConfig,
23
23
  ToolGroupSpecificRepresentation,
24
24
  } from '../../../types/SegmentationStateTypes';
@@ -131,11 +131,21 @@ async function render(
131
131
  } = representation;
132
132
 
133
133
  const segmentation = SegmentationState.getSegmentation(segmentationId);
134
+
135
+ if (!segmentation) {
136
+ console.warn('No segmentation found for segmentationId: ', segmentationId);
137
+ return;
138
+ }
139
+
134
140
  const labelmapData =
135
141
  segmentation.representationData[Representations.Labelmap];
136
142
 
137
143
  let actorEntry = viewport.getActor(segmentationRepresentationUID);
138
144
  if (isVolumeSegmentation(labelmapData)) {
145
+ if (viewport instanceof StackViewport) {
146
+ return;
147
+ }
148
+
139
149
  const { volumeId: labelmapUID } = labelmapData;
140
150
 
141
151
  const labelmap = cache.getVolume(labelmapUID);
@@ -159,6 +169,10 @@ async function render(
159
169
 
160
170
  actorEntry = viewport.getActor(segmentationRepresentationUID);
161
171
  } else {
172
+ if (viewport instanceof VolumeViewport) {
173
+ return;
174
+ }
175
+
162
176
  // stack segmentation
163
177
  const imageId = viewport.getCurrentImageId();
164
178
  const { imageIdReferenceMap } = labelmapData;