@cornerstonejs/tools 0.17.4 → 0.19.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 (216) hide show
  1. package/dist/cjs/enums/Events.d.ts +1 -0
  2. package/dist/cjs/enums/Events.js +1 -0
  3. package/dist/cjs/enums/Events.js.map +1 -1
  4. package/dist/cjs/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js.map +1 -1
  5. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -0
  6. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +3 -0
  7. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
  8. package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +1 -1
  9. package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
  10. package/dist/cjs/stateManagement/segmentation/segmentationState.d.ts +2 -1
  11. package/dist/cjs/stateManagement/segmentation/segmentationState.js +7 -1
  12. package/dist/cjs/stateManagement/segmentation/segmentationState.js.map +1 -1
  13. package/dist/cjs/stateManagement/segmentation/triggerSegmentationEvents.d.ts +2 -1
  14. package/dist/cjs/stateManagement/segmentation/triggerSegmentationEvents.js +8 -1
  15. package/dist/cjs/stateManagement/segmentation/triggerSegmentationEvents.js.map +1 -1
  16. package/dist/cjs/store/ToolGroupManager/ToolGroup.d.ts +4 -0
  17. package/dist/cjs/store/ToolGroupManager/ToolGroup.js +17 -5
  18. package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
  19. package/dist/cjs/synchronizers/callbacks/voiSyncCallback.js +16 -6
  20. package/dist/cjs/synchronizers/callbacks/voiSyncCallback.js.map +1 -1
  21. package/dist/cjs/tools/CrosshairsTool.js +6 -5
  22. package/dist/cjs/tools/CrosshairsTool.js.map +1 -1
  23. package/dist/cjs/tools/StackScrollTool.d.ts +3 -1
  24. package/dist/cjs/tools/StackScrollTool.js +33 -11
  25. package/dist/cjs/tools/StackScrollTool.js.map +1 -1
  26. package/dist/cjs/tools/StackScrollToolMouseWheelTool.d.ts +4 -1
  27. package/dist/cjs/tools/StackScrollToolMouseWheelTool.js +17 -9
  28. package/dist/cjs/tools/StackScrollToolMouseWheelTool.js.map +1 -1
  29. package/dist/cjs/tools/ZoomTool.d.ts +13 -3
  30. package/dist/cjs/tools/ZoomTool.js +64 -4
  31. package/dist/cjs/tools/ZoomTool.js.map +1 -1
  32. package/dist/cjs/tools/displayTools/Labelmap/addLabelmapToElement.js +5 -2
  33. package/dist/cjs/tools/displayTools/Labelmap/addLabelmapToElement.js.map +1 -1
  34. package/dist/cjs/tools/segmentation/strategies/eraseRectangle.js +2 -2
  35. package/dist/cjs/tools/segmentation/strategies/eraseRectangle.js.map +1 -1
  36. package/dist/cjs/tools/segmentation/strategies/fillCircle.js +2 -2
  37. package/dist/cjs/tools/segmentation/strategies/fillCircle.js.map +1 -1
  38. package/dist/cjs/tools/segmentation/strategies/fillRectangle.js +2 -2
  39. package/dist/cjs/tools/segmentation/strategies/fillRectangle.js.map +1 -1
  40. package/dist/cjs/tools/segmentation/strategies/fillSphere.js +1 -1
  41. package/dist/cjs/tools/segmentation/strategies/fillSphere.js.map +1 -1
  42. package/dist/cjs/types/BoundsIJK.d.ts +3 -0
  43. package/dist/cjs/types/BoundsIJK.js +3 -0
  44. package/dist/cjs/types/BoundsIJK.js.map +1 -0
  45. package/dist/cjs/types/EventTypes.d.ts +5 -1
  46. package/dist/cjs/types/IToolGroup.d.ts +2 -1
  47. package/dist/cjs/types/JumpToSliceOptions.d.ts +1 -0
  48. package/dist/cjs/types/ScrollOptions.d.ts +1 -0
  49. package/dist/cjs/types/index.d.ts +2 -1
  50. package/dist/cjs/utilities/{segmentation/getBoundingBoxUtils.d.ts → boundingBox/extend2DBoundingBoxInViewAxis.d.ts} +1 -2
  51. package/dist/cjs/utilities/boundingBox/extend2DBoundingBoxInViewAxis.js +13 -0
  52. package/dist/cjs/utilities/boundingBox/extend2DBoundingBoxInViewAxis.js.map +1 -0
  53. package/dist/cjs/utilities/boundingBox/getBoundingBoxAroundShape.d.ts +3 -0
  54. package/dist/cjs/utilities/boundingBox/getBoundingBoxAroundShape.js +40 -0
  55. package/dist/cjs/utilities/boundingBox/getBoundingBoxAroundShape.js.map +1 -0
  56. package/dist/cjs/utilities/boundingBox/index.d.ts +3 -0
  57. package/dist/cjs/utilities/boundingBox/index.js +11 -0
  58. package/dist/cjs/utilities/boundingBox/index.js.map +1 -0
  59. package/dist/cjs/utilities/cine/playClip.js +8 -7
  60. package/dist/cjs/utilities/cine/playClip.js.map +1 -1
  61. package/dist/cjs/utilities/index.d.ts +5 -2
  62. package/dist/cjs/utilities/index.js +9 -3
  63. package/dist/cjs/utilities/index.js.map +1 -1
  64. package/dist/cjs/utilities/pointInShapeCallback.d.ts +1 -2
  65. package/dist/cjs/utilities/pointInShapeCallback.js.map +1 -1
  66. package/dist/cjs/utilities/pointInSurroundingSphereCallback.d.ts +1 -1
  67. package/dist/cjs/utilities/pointInSurroundingSphereCallback.js +42 -12
  68. package/dist/cjs/utilities/pointInSurroundingSphereCallback.js.map +1 -1
  69. package/dist/cjs/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.d.ts +5 -0
  70. package/dist/cjs/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.js +51 -0
  71. package/dist/cjs/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.js.map +1 -0
  72. package/dist/cjs/utilities/rectangleROITool/index.d.ts +2 -0
  73. package/dist/cjs/utilities/rectangleROITool/index.js +9 -0
  74. package/dist/cjs/utilities/rectangleROITool/index.js.map +1 -0
  75. package/dist/cjs/utilities/scroll.d.ts +4 -0
  76. package/dist/cjs/utilities/scroll.js +40 -0
  77. package/dist/cjs/utilities/scroll.js.map +1 -0
  78. package/dist/cjs/utilities/segmentation/index.d.ts +2 -2
  79. package/dist/cjs/utilities/segmentation/index.js +3 -4
  80. package/dist/cjs/utilities/segmentation/index.js.map +1 -1
  81. package/dist/cjs/utilities/segmentation/rectangleROIThresholdVolumeByRange.d.ts +19 -0
  82. package/dist/cjs/utilities/segmentation/rectangleROIThresholdVolumeByRange.js +42 -0
  83. package/dist/cjs/utilities/segmentation/rectangleROIThresholdVolumeByRange.js.map +1 -0
  84. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.d.ts +5 -19
  85. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.js +13 -69
  86. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.js.map +1 -1
  87. package/dist/cjs/utilities/stackPrefetch/index.d.ts +2 -0
  88. package/dist/cjs/utilities/stackPrefetch/index.js +9 -0
  89. package/dist/cjs/utilities/stackPrefetch/index.js.map +1 -0
  90. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.d.ts +8 -0
  91. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.js +232 -0
  92. package/dist/cjs/utilities/stackPrefetch/stackPrefetch.js.map +1 -0
  93. package/dist/cjs/utilities/stackPrefetch/state.d.ts +3 -0
  94. package/dist/cjs/utilities/stackPrefetch/state.js +18 -0
  95. package/dist/cjs/utilities/stackPrefetch/state.js.map +1 -0
  96. package/dist/cjs/utilities/viewport/jumpToSlice.d.ts +1 -1
  97. package/dist/cjs/utilities/viewport/jumpToSlice.js +9 -7
  98. package/dist/cjs/utilities/viewport/jumpToSlice.js.map +1 -1
  99. package/dist/esm/enums/Events.d.ts +1 -0
  100. package/dist/esm/enums/Events.js +1 -0
  101. package/dist/esm/enums/Events.js.map +1 -1
  102. package/dist/esm/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js.map +1 -1
  103. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -0
  104. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +3 -0
  105. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
  106. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +1 -1
  107. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
  108. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
  109. package/dist/esm/stateManagement/segmentation/segmentationState.js +7 -2
  110. package/dist/esm/stateManagement/segmentation/segmentationState.js.map +1 -1
  111. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.d.ts +2 -1
  112. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +7 -1
  113. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js.map +1 -1
  114. package/dist/esm/store/ToolGroupManager/ToolGroup.d.ts +4 -0
  115. package/dist/esm/store/ToolGroupManager/ToolGroup.js +18 -6
  116. package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
  117. package/dist/esm/synchronizers/callbacks/voiSyncCallback.js +17 -7
  118. package/dist/esm/synchronizers/callbacks/voiSyncCallback.js.map +1 -1
  119. package/dist/esm/tools/CrosshairsTool.js +6 -5
  120. package/dist/esm/tools/CrosshairsTool.js.map +1 -1
  121. package/dist/esm/tools/StackScrollTool.d.ts +3 -1
  122. package/dist/esm/tools/StackScrollTool.js +34 -12
  123. package/dist/esm/tools/StackScrollTool.js.map +1 -1
  124. package/dist/esm/tools/StackScrollToolMouseWheelTool.d.ts +4 -1
  125. package/dist/esm/tools/StackScrollToolMouseWheelTool.js +17 -9
  126. package/dist/esm/tools/StackScrollToolMouseWheelTool.js.map +1 -1
  127. package/dist/esm/tools/ZoomTool.d.ts +13 -3
  128. package/dist/esm/tools/ZoomTool.js +64 -4
  129. package/dist/esm/tools/ZoomTool.js.map +1 -1
  130. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +5 -2
  131. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js.map +1 -1
  132. package/dist/esm/tools/segmentation/strategies/eraseRectangle.js +1 -1
  133. package/dist/esm/tools/segmentation/strategies/eraseRectangle.js.map +1 -1
  134. package/dist/esm/tools/segmentation/strategies/fillCircle.js +1 -1
  135. package/dist/esm/tools/segmentation/strategies/fillCircle.js.map +1 -1
  136. package/dist/esm/tools/segmentation/strategies/fillRectangle.js +1 -1
  137. package/dist/esm/tools/segmentation/strategies/fillRectangle.js.map +1 -1
  138. package/dist/esm/tools/segmentation/strategies/fillSphere.js +1 -1
  139. package/dist/esm/tools/segmentation/strategies/fillSphere.js.map +1 -1
  140. package/dist/esm/types/BoundsIJK.d.ts +3 -0
  141. package/dist/esm/types/BoundsIJK.js +2 -0
  142. package/dist/esm/types/BoundsIJK.js.map +1 -0
  143. package/dist/esm/types/EventTypes.d.ts +5 -1
  144. package/dist/esm/types/IToolGroup.d.ts +2 -1
  145. package/dist/esm/types/JumpToSliceOptions.d.ts +1 -0
  146. package/dist/esm/types/ScrollOptions.d.ts +1 -0
  147. package/dist/esm/types/index.d.ts +2 -1
  148. package/dist/esm/utilities/{segmentation/getBoundingBoxUtils.d.ts → boundingBox/extend2DBoundingBoxInViewAxis.d.ts} +1 -2
  149. package/dist/esm/utilities/boundingBox/extend2DBoundingBoxInViewAxis.js +11 -0
  150. package/dist/esm/utilities/boundingBox/extend2DBoundingBoxInViewAxis.js.map +1 -0
  151. package/dist/esm/utilities/boundingBox/getBoundingBoxAroundShape.d.ts +3 -0
  152. package/dist/esm/utilities/boundingBox/getBoundingBoxAroundShape.js +38 -0
  153. package/dist/esm/utilities/boundingBox/getBoundingBoxAroundShape.js.map +1 -0
  154. package/dist/esm/utilities/boundingBox/index.d.ts +3 -0
  155. package/dist/esm/utilities/boundingBox/index.js +4 -0
  156. package/dist/esm/utilities/boundingBox/index.js.map +1 -0
  157. package/dist/esm/utilities/cine/playClip.js +8 -7
  158. package/dist/esm/utilities/cine/playClip.js.map +1 -1
  159. package/dist/esm/utilities/index.d.ts +5 -2
  160. package/dist/esm/utilities/index.js +5 -2
  161. package/dist/esm/utilities/index.js.map +1 -1
  162. package/dist/esm/utilities/pointInShapeCallback.d.ts +1 -2
  163. package/dist/esm/utilities/pointInShapeCallback.js.map +1 -1
  164. package/dist/esm/utilities/pointInSurroundingSphereCallback.d.ts +1 -1
  165. package/dist/esm/utilities/pointInSurroundingSphereCallback.js +40 -10
  166. package/dist/esm/utilities/pointInSurroundingSphereCallback.js.map +1 -1
  167. package/dist/esm/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.d.ts +5 -0
  168. package/dist/esm/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.js +45 -0
  169. package/dist/esm/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.js.map +1 -0
  170. package/dist/esm/utilities/rectangleROITool/index.d.ts +2 -0
  171. package/dist/esm/utilities/rectangleROITool/index.js +3 -0
  172. package/dist/esm/utilities/rectangleROITool/index.js.map +1 -0
  173. package/dist/esm/utilities/scroll.d.ts +4 -0
  174. package/dist/esm/utilities/scroll.js +35 -0
  175. package/dist/esm/utilities/scroll.js.map +1 -0
  176. package/dist/esm/utilities/segmentation/index.d.ts +2 -2
  177. package/dist/esm/utilities/segmentation/index.js +2 -2
  178. package/dist/esm/utilities/segmentation/index.js.map +1 -1
  179. package/dist/esm/utilities/segmentation/rectangleROIThresholdVolumeByRange.d.ts +19 -0
  180. package/dist/esm/utilities/segmentation/rectangleROIThresholdVolumeByRange.js +37 -0
  181. package/dist/esm/utilities/segmentation/rectangleROIThresholdVolumeByRange.js.map +1 -0
  182. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.d.ts +5 -19
  183. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.js +13 -47
  184. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.js.map +1 -1
  185. package/dist/esm/utilities/stackPrefetch/index.d.ts +2 -0
  186. package/dist/esm/utilities/stackPrefetch/index.js +3 -0
  187. package/dist/esm/utilities/stackPrefetch/index.js.map +1 -0
  188. package/dist/esm/utilities/stackPrefetch/stackPrefetch.d.ts +8 -0
  189. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +226 -0
  190. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js.map +1 -0
  191. package/dist/esm/utilities/stackPrefetch/state.d.ts +3 -0
  192. package/dist/esm/utilities/stackPrefetch/state.js +14 -0
  193. package/dist/esm/utilities/stackPrefetch/state.js.map +1 -0
  194. package/dist/esm/utilities/viewport/jumpToSlice.d.ts +1 -1
  195. package/dist/esm/utilities/viewport/jumpToSlice.js +9 -7
  196. package/dist/esm/utilities/viewport/jumpToSlice.js.map +1 -1
  197. package/dist/umd/index.js +1 -1
  198. package/dist/umd/index.js.LICENSE.txt +2 -0
  199. package/dist/umd/index.js.map +1 -1
  200. package/package.json +4 -4
  201. package/dist/cjs/utilities/segmentation/getBoundingBoxUtils.js +0 -51
  202. package/dist/cjs/utilities/segmentation/getBoundingBoxUtils.js.map +0 -1
  203. package/dist/cjs/utilities/stackScrollTool/index.d.ts +0 -2
  204. package/dist/cjs/utilities/stackScrollTool/index.js +0 -9
  205. package/dist/cjs/utilities/stackScrollTool/index.js.map +0 -1
  206. package/dist/cjs/utilities/stackScrollTool/scrollThroughStack.d.ts +0 -3
  207. package/dist/cjs/utilities/stackScrollTool/scrollThroughStack.js +0 -43
  208. package/dist/cjs/utilities/stackScrollTool/scrollThroughStack.js.map +0 -1
  209. package/dist/esm/utilities/segmentation/getBoundingBoxUtils.js +0 -47
  210. package/dist/esm/utilities/segmentation/getBoundingBoxUtils.js.map +0 -1
  211. package/dist/esm/utilities/stackScrollTool/index.d.ts +0 -2
  212. package/dist/esm/utilities/stackScrollTool/index.js +0 -3
  213. package/dist/esm/utilities/stackScrollTool/index.js.map +0 -1
  214. package/dist/esm/utilities/stackScrollTool/scrollThroughStack.d.ts +0 -3
  215. package/dist/esm/utilities/stackScrollTool/scrollThroughStack.js +0 -37
  216. package/dist/esm/utilities/stackScrollTool/scrollThroughStack.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@cornerstonejs/core");
7
+ const getBoundingBoxAroundShape_1 = __importDefault(require("../boundingBox/getBoundingBoxAroundShape"));
8
+ const extend2DBoundingBoxInViewAxis_1 = __importDefault(require("../boundingBox/extend2DBoundingBoxInViewAxis"));
9
+ function getBoundsIJKFromRectangleAnnotations(annotations, referenceVolume, options = {}) {
10
+ const AllBoundsIJK = [];
11
+ annotations.forEach((annotation) => {
12
+ var _a, _b;
13
+ const { data } = annotation;
14
+ const { points } = data.handles;
15
+ const { imageData, dimensions } = referenceVolume;
16
+ let pointsToUse = points;
17
+ if ((_a = data.cachedStats) === null || _a === void 0 ? void 0 : _a.projectionPoints) {
18
+ const { projectionPoints } = data.cachedStats;
19
+ pointsToUse = [].concat(...projectionPoints);
20
+ }
21
+ const rectangleCornersIJK = pointsToUse.map((world) => core_1.utilities.transformWorldToIndex(imageData, world));
22
+ let boundsIJK = (0, getBoundingBoxAroundShape_1.default)(rectangleCornersIJK, dimensions);
23
+ if (options.numSlicesToProject && !((_b = data.cachedStats) === null || _b === void 0 ? void 0 : _b.projectionPoints)) {
24
+ boundsIJK = (0, extend2DBoundingBoxInViewAxis_1.default)(boundsIJK, options.numSlicesToProject);
25
+ }
26
+ AllBoundsIJK.push(boundsIJK);
27
+ });
28
+ if (AllBoundsIJK.length === 1) {
29
+ return AllBoundsIJK[0];
30
+ }
31
+ const boundsIJK = AllBoundsIJK.reduce((accumulator, currentValue) => {
32
+ return {
33
+ iMin: Math.min(accumulator.iMin, currentValue.iMin),
34
+ jMin: Math.min(accumulator.jMin, currentValue.jMin),
35
+ kMin: Math.min(accumulator.kMin, currentValue.kMin),
36
+ iMax: Math.max(accumulator.iMax, currentValue.iMax),
37
+ jMax: Math.max(accumulator.jMax, currentValue.jMax),
38
+ kMax: Math.max(accumulator.kMax, currentValue.kMax),
39
+ };
40
+ }, {
41
+ iMin: Infinity,
42
+ jMin: Infinity,
43
+ kMin: Infinity,
44
+ iMax: -Infinity,
45
+ jMax: -Infinity,
46
+ kMax: -Infinity,
47
+ });
48
+ return boundsIJK;
49
+ }
50
+ exports.default = getBoundsIJKFromRectangleAnnotations;
51
+ //# sourceMappingURL=getBoundsIJKFromRectangleAnnotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBoundsIJKFromRectangleAnnotations.js","sourceRoot":"","sources":["../../../../src/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.ts"],"names":[],"mappings":";;;;;AAAA,8CAA2D;AAE3D,yGAAiF;AACjF,iHAAyF;AAMzF,SAAS,oCAAoC,CAC3C,WAAW,EACX,eAAe,EACf,UAAU,EAAa;IAEvB,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;;QACjC,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;QAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEhC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC;QAElD,IAAI,WAAW,GAAG,MAAM,CAAC;QAEzB,IAAI,MAAA,IAAI,CAAC,WAAW,0CAAE,gBAAgB,EAAE;YACtC,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;YAC9C,WAAW,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC,CAAC;SAC9C;QAED,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,CACzC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAO,CAAC,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAiB,CAC3E,CAAC;QACF,IAAI,SAAS,GAAG,IAAA,mCAAyB,EAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAI3E,IAAI,OAAO,CAAC,kBAAkB,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,gBAAgB,CAAA,EAAE;YACrE,SAAS,GAAG,IAAA,uCAA6B,EACvC,SAAS,EACT,OAAO,CAAC,kBAAkB,CAC3B,CAAC;SACH;QAED,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;KACxB;IAID,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CACnC,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE;QAC5B,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;YACnD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;YACnD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;YACnD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;YACnD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;YACnD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;SACpD,CAAC;IACJ,CAAC,EACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,QAAQ;QACf,IAAI,EAAE,CAAC,QAAQ;QACf,IAAI,EAAE,CAAC,QAAQ;KAChB,CACF,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,kBAAe,oCAAoC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import getBoundsIJKFromRectangleAnnotations from './getBoundsIJKFromRectangleAnnotations';
2
+ export { getBoundsIJKFromRectangleAnnotations };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getBoundsIJKFromRectangleAnnotations = void 0;
7
+ const getBoundsIJKFromRectangleAnnotations_1 = __importDefault(require("./getBoundsIJKFromRectangleAnnotations"));
8
+ exports.getBoundsIJKFromRectangleAnnotations = getBoundsIJKFromRectangleAnnotations_1.default;
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/rectangleROITool/index.ts"],"names":[],"mappings":";;;;;;AAAA,kHAA0F;AAEjF,+CAFF,8CAAoC,CAEE"}
@@ -0,0 +1,4 @@
1
+ import { Types, VolumeViewport } from '@cornerstonejs/core';
2
+ import { ScrollOptions } from '../types';
3
+ export default function scroll(viewport: Types.IStackViewport | Types.IVolumeViewport, options: ScrollOptions): void;
4
+ export declare function scrollVolume(viewport: VolumeViewport, volumeId: string, delta: number): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scrollVolume = void 0;
4
+ const core_1 = require("@cornerstonejs/core");
5
+ function scroll(viewport, options) {
6
+ const { type: viewportType } = viewport;
7
+ const { volumeId, delta } = options;
8
+ if (viewport instanceof core_1.StackViewport) {
9
+ viewport.scroll(delta, options.debounceLoading);
10
+ }
11
+ else if (viewport instanceof core_1.VolumeViewport) {
12
+ scrollVolume(viewport, volumeId, delta);
13
+ }
14
+ else {
15
+ throw new Error(`Not implemented for Viewport Type: ${viewportType}`);
16
+ }
17
+ }
18
+ exports.default = scroll;
19
+ function scrollVolume(viewport, volumeId, delta) {
20
+ const camera = viewport.getCamera();
21
+ const { focalPoint, viewPlaneNormal, position } = camera;
22
+ const { spacingInNormalDirection, imageVolume } = core_1.utilities.getTargetVolumeAndSpacingInNormalDir(viewport, camera, volumeId);
23
+ if (!imageVolume) {
24
+ throw new Error(`Could not find image volume with id ${volumeId} in the viewport`);
25
+ }
26
+ const actorEntry = viewport.getActor(imageVolume.volumeId);
27
+ if (!actorEntry) {
28
+ console.warn('No actor found for with actorUID of', imageVolume.volumeId);
29
+ }
30
+ const volumeActor = actorEntry.actor;
31
+ const sliceRange = core_1.utilities.getSliceRange(volumeActor, viewPlaneNormal, focalPoint);
32
+ const { newFocalPoint, newPosition } = core_1.utilities.snapFocalPointToSlice(focalPoint, position, sliceRange, viewPlaneNormal, spacingInNormalDirection, delta);
33
+ viewport.setCamera({
34
+ focalPoint: newFocalPoint,
35
+ position: newPosition,
36
+ });
37
+ viewport.render();
38
+ }
39
+ exports.scrollVolume = scrollVolume;
40
+ //# sourceMappingURL=scroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../../src/utilities/scroll.ts"],"names":[],"mappings":";;;AAAA,8CAK6B;AAY7B,SAAwB,MAAM,CAC5B,QAAsD,EACtD,OAAsB;IAEtB,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IACxC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEpC,IAAI,QAAQ,YAAY,oBAAa,EAAE;QACrC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;KACjD;SAAM,IAAI,QAAQ,YAAY,qBAAc,EAAE;QAC7C,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;KACzC;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,sCAAsC,YAAY,EAAE,CAAC,CAAC;KACvE;AACH,CAAC;AAdD,yBAcC;AAED,SAAgB,YAAY,CAC1B,QAAwB,EACxB,QAAgB,EAChB,KAAa;IAEb,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,EAAE,wBAAwB,EAAE,WAAW,EAAE,GAC7C,gBAAO,CAAC,oCAAoC,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE3E,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CACb,uCAAuC,QAAQ,kBAAkB,CAClE,CAAC;KACH;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE3D,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC3E;IAED,MAAM,WAAW,GAAG,UAAU,CAAC,KAA0B,CAAC;IAC1D,MAAM,UAAU,GAAG,gBAAO,CAAC,aAAa,CACtC,WAAW,EACX,eAAe,EACf,UAAU,CACX,CAAC;IAEF,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,gBAAO,CAAC,qBAAqB,CAClE,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,KAAK,CACN,CAAC;IAEF,QAAQ,CAAC,SAAS,CAAC;QACjB,UAAU,EAAE,aAAa;QACzB,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC;AACpB,CAAC;AA3CD,oCA2CC"}
@@ -1,7 +1,7 @@
1
- import { getBoundingBoxAroundShape, extend2DBoundingBoxInViewAxis } from './getBoundingBoxUtils';
2
1
  import thresholdVolumeByRange from './thresholdVolumeByRange';
2
+ import rectangleROIThresholdVolumeByRange from './rectangleROIThresholdVolumeByRange';
3
3
  import createMergedLabelmapForIndex from './createMergedLabelmapForIndex';
4
4
  import isValidRepresentationConfig from './isValidRepresentationConfig';
5
5
  import getDefaultRepresentationConfig from './getDefaultRepresentationConfig';
6
6
  import createLabelmapVolumeForViewport from './createLabelmapVolumeForViewport';
7
- export { getBoundingBoxAroundShape, extend2DBoundingBoxInViewAxis, thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, };
7
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, };
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createLabelmapVolumeForViewport = exports.getDefaultRepresentationConfig = exports.isValidRepresentationConfig = exports.createMergedLabelmapForIndex = exports.thresholdVolumeByRange = exports.extend2DBoundingBoxInViewAxis = exports.getBoundingBoxAroundShape = void 0;
7
- const getBoundingBoxUtils_1 = require("./getBoundingBoxUtils");
8
- Object.defineProperty(exports, "getBoundingBoxAroundShape", { enumerable: true, get: function () { return getBoundingBoxUtils_1.getBoundingBoxAroundShape; } });
9
- Object.defineProperty(exports, "extend2DBoundingBoxInViewAxis", { enumerable: true, get: function () { return getBoundingBoxUtils_1.extend2DBoundingBoxInViewAxis; } });
6
+ exports.rectangleROIThresholdVolumeByRange = exports.createLabelmapVolumeForViewport = exports.getDefaultRepresentationConfig = exports.isValidRepresentationConfig = exports.createMergedLabelmapForIndex = exports.thresholdVolumeByRange = void 0;
10
7
  const thresholdVolumeByRange_1 = __importDefault(require("./thresholdVolumeByRange"));
11
8
  exports.thresholdVolumeByRange = thresholdVolumeByRange_1.default;
9
+ const rectangleROIThresholdVolumeByRange_1 = __importDefault(require("./rectangleROIThresholdVolumeByRange"));
10
+ exports.rectangleROIThresholdVolumeByRange = rectangleROIThresholdVolumeByRange_1.default;
12
11
  const createMergedLabelmapForIndex_1 = __importDefault(require("./createMergedLabelmapForIndex"));
13
12
  exports.createMergedLabelmapForIndex = createMergedLabelmapForIndex_1.default;
14
13
  const isValidRepresentationConfig_1 = __importDefault(require("./isValidRepresentationConfig"));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAG+B;AAQ7B,0GAVA,+CAAyB,OAUA;AACzB,8GAVA,mDAA6B,OAUA;AAR/B,sFAA8D;AAS5D,iCATK,gCAAsB,CASL;AARxB,kGAA0E;AASxE,uCATK,sCAA4B,CASL;AAR9B,gGAAwE;AAStE,sCATK,qCAA2B,CASL;AAR7B,sGAA8E;AAS5E,yCATK,wCAA8B,CASL;AARhC,wGAAgF;AAS9E,0CATK,yCAA+B,CASL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA8D;AAQ5D,iCARK,gCAAsB,CAQL;AAPxB,8GAAsF;AAYpF,6CAZK,4CAAkC,CAYL;AAXpC,kGAA0E;AAOxE,uCAPK,sCAA4B,CAOL;AAN9B,gGAAwE;AAOtE,sCAPK,qCAA2B,CAOL;AAN7B,sGAA8E;AAO5E,yCAPK,wCAA8B,CAOL;AANhC,wGAAgF;AAO9E,0CAPK,yCAA+B,CAOL"}
@@ -0,0 +1,19 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export declare type ThresholdRangeOptions = {
3
+ lower: number;
4
+ upper: number;
5
+ numSlicesToProject?: number;
6
+ overwrite: boolean;
7
+ };
8
+ export declare type AnnotationForThresholding = {
9
+ data: {
10
+ handles: {
11
+ points: Types.Point3[];
12
+ };
13
+ cachedStats?: {
14
+ projectionPoints?: Types.Point3[][];
15
+ };
16
+ };
17
+ };
18
+ declare function rectangleROIThresholdVolumeByRange(annotationUIDs: string[], segmentationVolume: Types.IImageVolume, referenceVolumes: Types.IImageVolume[], options: ThresholdRangeOptions): Types.IImageVolume;
19
+ export default rectangleROIThresholdVolumeByRange;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const annotation_1 = require("../../stateManagement/annotation");
7
+ const tools_1 = require("../../tools");
8
+ const thresholdVolumeByRange_1 = __importDefault(require("./thresholdVolumeByRange"));
9
+ const getBoundsIJKFromRectangleAnnotations_1 = __importDefault(require("../rectangleROITool/getBoundsIJKFromRectangleAnnotations"));
10
+ function rectangleROIThresholdVolumeByRange(annotationUIDs, segmentationVolume, referenceVolumes, options) {
11
+ if (referenceVolumes.length > 1) {
12
+ throw new Error('thresholding based on more than one reference volumes data is not supported yet');
13
+ }
14
+ const referenceVolume = referenceVolumes[0];
15
+ const annotations = annotationUIDs.map((annotationUID) => {
16
+ return annotation_1.state.getAnnotation(annotationUID);
17
+ });
18
+ _validateAnnotations(annotations);
19
+ const boundsIJK = (0, getBoundsIJKFromRectangleAnnotations_1.default)(annotations, referenceVolume, options);
20
+ const optionsToUse = {
21
+ lower: options.lower,
22
+ upper: options.upper,
23
+ overwrite: options.overwrite,
24
+ boundsIJK,
25
+ };
26
+ const outputSegmentationVolume = (0, thresholdVolumeByRange_1.default)(segmentationVolume, referenceVolume, optionsToUse);
27
+ return outputSegmentationVolume;
28
+ }
29
+ function _validateAnnotations(annotations) {
30
+ const validToolNames = [
31
+ tools_1.RectangleROIThresholdTool.toolName,
32
+ tools_1.RectangleROIStartEndThresholdTool.toolName,
33
+ ];
34
+ for (const annotation of annotations) {
35
+ const name = annotation.metadata.toolName;
36
+ if (!validToolNames.includes(name)) {
37
+ throw new Error('rectangleROIThresholdVolumeByRange only supports RectangleROIThreshold and RectangleROIStartEndThreshold annotations');
38
+ }
39
+ }
40
+ }
41
+ exports.default = rectangleROIThresholdVolumeByRange;
42
+ //# sourceMappingURL=rectangleROIThresholdVolumeByRange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectangleROIThresholdVolumeByRange.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts"],"names":[],"mappings":";;;;;AACA,iEAAyD;AACzD,uCAGqB;AAErB,sFAA8D;AAC9D,oIAA4G;AA+B5G,SAAS,kCAAkC,CACzC,cAAwB,EACxB,kBAAsC,EACtC,gBAAsC,EACtC,OAA8B;IAE9B,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;KACH;IAED,MAAM,eAAe,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE;QACvD,OAAO,kBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAElC,MAAM,SAAS,GAAG,IAAA,8CAAoC,EACpD,WAAW,EACX,eAAe,EACf,OAAO,CACR,CAAC;IAEF,MAAM,YAAY,GAAG;QACnB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS;KACV,CAAC;IAEF,MAAM,wBAAwB,GAAG,IAAA,gCAAsB,EACrD,kBAAkB,EAClB,eAAe,EACf,YAAY,CACb,CAAC;IAEF,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED,SAAS,oBAAoB,CAAC,WAAW;IACvC,MAAM,cAAc,GAAG;QACrB,iCAAyB,CAAC,QAAQ;QAClC,yCAAiC,CAAC,QAAQ;KAC3C,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAClC,MAAM,IAAI,KAAK,CACb,sHAAsH,CACvH,CAAC;SACH;KACF;AACH,CAAC;AAED,kBAAe,kCAAkC,CAAC"}
@@ -1,24 +1,10 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
- import { ToolGroupSpecificRepresentation } from '../../types/SegmentationStateTypes';
2
+ import { BoundsIJK } from '../../types';
3
3
  export declare type ThresholdRangeOptions = {
4
- higherThreshold: number;
5
- lowerThreshold: number;
6
- numSlicesToProject?: number;
4
+ upper: number;
5
+ lower: number;
6
+ boundsIJK: BoundsIJK;
7
7
  overwrite: boolean;
8
8
  };
9
- export declare type AnnotationForThresholding = {
10
- metadata: {
11
- enabledElement: Types.IEnabledElement;
12
- };
13
- data: {
14
- handles: {
15
- points: Types.Point3[];
16
- };
17
- cachedStats?: {
18
- projectionPoints?: Types.Point3[][];
19
- };
20
- };
21
- };
22
- declare function thresholdVolumeByRange(annotations: AnnotationForThresholding[], referenceVolumes: Types.IImageVolume[], segmentationRepresentation: ToolGroupSpecificRepresentation, options: ThresholdRangeOptions): Types.IImageVolume;
23
- export declare function extendBoundingBoxInSliceAxisIfNecessary(boundsIJK: [Types.Point2, Types.Point2, Types.Point2], numSlicesToProject: number): [Types.Point2, Types.Point2, Types.Point2];
9
+ declare function thresholdVolumeByRange(segmentationVolume: Types.IImageVolume, referenceVolume: Types.IImageVolume, options: ThresholdRangeOptions): Types.IImageVolume;
24
10
  export default thresholdVolumeByRange;
@@ -1,84 +1,28 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.extendBoundingBoxInSliceAxisIfNecessary = void 0;
23
- const core_1 = require("@cornerstonejs/core");
24
- const segmentation_1 = require("../segmentation");
25
3
  const utilities_1 = require("../../utilities");
26
4
  const triggerSegmentationEvents_1 = require("../../stateManagement/segmentation/triggerSegmentationEvents");
27
- const SegmentationState = __importStar(require("../../stateManagement/segmentation/segmentationState"));
28
- const { transformWorldToIndex } = core_1.utilities;
29
- function thresholdVolumeByRange(annotations, referenceVolumes, segmentationRepresentation, options) {
30
- if (referenceVolumes.length > 1) {
31
- throw new Error('thresholding more than one volumes is not supported yet');
32
- }
33
- const segmentation = SegmentationState.getSegmentation(segmentationRepresentation.segmentationId);
34
- const { segmentationId } = segmentationRepresentation;
35
- if (!segmentation) {
36
- throw new Error('No Segmentation Found');
37
- }
38
- const { type, representationData } = segmentation;
39
- const { volumeId } = representationData[type];
40
- const segmentationVolume = core_1.cache.getVolume(volumeId);
5
+ function thresholdVolumeByRange(segmentationVolume, referenceVolume, options) {
41
6
  const { scalarData, imageData: segmentationImageData } = segmentationVolume;
42
- const { lowerThreshold, higherThreshold, numSlicesToProject, overwrite } = options;
7
+ const { overwrite, boundsIJK, upper, lower } = options;
8
+ const { imageData } = referenceVolume;
9
+ const referenceValues = imageData.getPointData().getScalars().getData();
43
10
  if (overwrite) {
44
11
  for (let i = 0; i < scalarData.length; i++) {
45
12
  scalarData[i] = 0;
46
13
  }
47
14
  }
48
- annotations.forEach((annotation) => {
49
- var _a, _b;
50
- const { data } = annotation;
51
- const { points } = data.handles;
52
- const referenceVolume = referenceVolumes[0];
53
- const { imageData, dimensions } = referenceVolume;
54
- const values = imageData.getPointData().getScalars().getData();
55
- let pointsToUse = points;
56
- if ((_a = data.cachedStats) === null || _a === void 0 ? void 0 : _a.projectionPoints) {
57
- const { projectionPoints } = data.cachedStats;
58
- pointsToUse = [].concat(...projectionPoints);
15
+ const callback = ({ index, pointIJK }) => {
16
+ const offset = imageData.computeOffsetIndex(pointIJK);
17
+ const value = referenceValues[offset];
18
+ if (value <= lower || value >= upper) {
19
+ return;
59
20
  }
60
- const rectangleCornersIJK = pointsToUse.map((world) => transformWorldToIndex(imageData, world));
61
- let boundsIJK = (0, segmentation_1.getBoundingBoxAroundShape)(rectangleCornersIJK, dimensions);
62
- if (numSlicesToProject && !((_b = data.cachedStats) === null || _b === void 0 ? void 0 : _b.projectionPoints)) {
63
- boundsIJK = extendBoundingBoxInSliceAxisIfNecessary(boundsIJK, numSlicesToProject);
64
- }
65
- const callback = ({ index, pointIJK }) => {
66
- const offset = imageData.computeOffsetIndex(pointIJK);
67
- const value = values[offset];
68
- if (value <= lowerThreshold || value >= higherThreshold) {
69
- return;
70
- }
71
- scalarData[index] = 1;
72
- };
73
- (0, utilities_1.pointInShapeCallback)(segmentationImageData, () => true, callback, boundsIJK);
74
- });
75
- (0, triggerSegmentationEvents_1.triggerSegmentationDataModified)(segmentationId);
21
+ scalarData[index] = 1;
22
+ };
23
+ (0, utilities_1.pointInShapeCallback)(segmentationImageData, () => true, callback, boundsIJK);
24
+ (0, triggerSegmentationEvents_1.triggerSegmentationDataModified)(segmentationVolume.volumeId);
76
25
  return segmentationVolume;
77
26
  }
78
- function extendBoundingBoxInSliceAxisIfNecessary(boundsIJK, numSlicesToProject) {
79
- const extendedBoundsIJK = (0, segmentation_1.extend2DBoundingBoxInViewAxis)(boundsIJK, numSlicesToProject);
80
- return extendedBoundsIJK;
81
- }
82
- exports.extendBoundingBoxInSliceAxisIfNecessary = extendBoundingBoxInSliceAxisIfNecessary;
83
27
  exports.default = thresholdVolumeByRange;
84
28
  //# sourceMappingURL=thresholdVolumeByRange.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdVolumeByRange.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/thresholdVolumeByRange.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"thresholdVolumeByRange.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/thresholdVolumeByRange.ts"],"names":[],"mappings":";;AAEA,+CAAuD;AACvD,4GAA+G;AAkB/G,SAAS,sBAAsB,CAC7B,kBAAsC,EACtC,eAAmC,EACnC,OAA8B;IAE9B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,qBAAqB,EAAE,GAAG,kBAAkB,CAAC;IAC5E,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEvD,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC;IACtC,MAAM,eAAe,GAAG,SAAS,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC;IAGxE,IAAI,SAAS,EAAE;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SACnB;KACF;IAED,MAAM,QAAQ,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,SAAS,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE;YACpC,OAAO;SACR;QAGD,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,IAAA,gCAAoB,EAAC,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAE7E,IAAA,2DAA+B,EAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE7D,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,kBAAe,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { enable, disable, setConfiguration, getConfiguration } from './stackPrefetch';
2
+ export { enable, disable, setConfiguration, getConfiguration };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConfiguration = exports.setConfiguration = exports.disable = exports.enable = void 0;
4
+ const stackPrefetch_1 = require("./stackPrefetch");
5
+ Object.defineProperty(exports, "enable", { enumerable: true, get: function () { return stackPrefetch_1.enable; } });
6
+ Object.defineProperty(exports, "disable", { enumerable: true, get: function () { return stackPrefetch_1.disable; } });
7
+ Object.defineProperty(exports, "setConfiguration", { enumerable: true, get: function () { return stackPrefetch_1.setConfiguration; } });
8
+ Object.defineProperty(exports, "getConfiguration", { enumerable: true, get: function () { return stackPrefetch_1.getConfiguration; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/stackPrefetch/index.ts"],"names":[],"mappings":";;;AAAA,mDAKyB;AAEhB,uFANP,sBAAM,OAMO;AAAE,wFALf,uBAAO,OAKe;AAAE,iGAJxB,gCAAgB,OAIwB;AAAE,iGAH1C,gCAAgB,OAG0C"}
@@ -0,0 +1,8 @@
1
+ declare function enable(element: any): void;
2
+ declare function disable(element: any): void;
3
+ declare function getConfiguration(): {
4
+ maxImagesToPrefetch: number;
5
+ preserveExistingPool: boolean;
6
+ };
7
+ declare function setConfiguration(config: any): void;
8
+ export { enable, disable, getConfiguration, setConfiguration };
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setConfiguration = exports.getConfiguration = exports.disable = exports.enable = void 0;
4
+ const core_1 = require("@cornerstonejs/core");
5
+ const state_1 = require("./state");
6
+ const requestType = core_1.Enums.RequestType.Prefetch;
7
+ const priority = 0;
8
+ const addToBeginning = true;
9
+ let configuration = {
10
+ maxImagesToPrefetch: Infinity,
11
+ preserveExistingPool: false,
12
+ };
13
+ let resetPrefetchTimeout;
14
+ const resetPrefetchDelay = 10;
15
+ function range(lowEnd, highEnd) {
16
+ lowEnd = Math.round(lowEnd) || 0;
17
+ highEnd = Math.round(highEnd) || 0;
18
+ const arr = [];
19
+ let c = highEnd - lowEnd + 1;
20
+ if (c <= 0) {
21
+ return arr;
22
+ }
23
+ while (c--) {
24
+ arr[c] = highEnd--;
25
+ }
26
+ return arr;
27
+ }
28
+ function nearestIndex(arr, x) {
29
+ let low = 0;
30
+ let high = arr.length - 1;
31
+ arr.forEach((v, idx) => {
32
+ if (v < x) {
33
+ low = Math.max(idx, low);
34
+ }
35
+ else if (v > x) {
36
+ high = Math.min(idx, high);
37
+ }
38
+ });
39
+ return { low, high };
40
+ }
41
+ function getStackData(element) {
42
+ const enabledElement = (0, core_1.getEnabledElement)(element);
43
+ if (!enabledElement) {
44
+ throw new Error('stackPrefetch: element must be a valid Cornerstone enabled element');
45
+ }
46
+ const { viewport } = enabledElement;
47
+ if (!(viewport instanceof core_1.StackViewport)) {
48
+ throw new Error('stackPrefetch: element must be a StackViewport, VolumeViewport stackPrefetch not yet implemented');
49
+ }
50
+ return {
51
+ currentImageIdIndex: viewport.getCurrentImageIdIndex(),
52
+ imageIds: viewport.getImageIds(),
53
+ };
54
+ }
55
+ function prefetch(element) {
56
+ const stackPrefetchData = (0, state_1.getToolState)(element);
57
+ if (!stackPrefetchData) {
58
+ return;
59
+ }
60
+ const stackPrefetch = stackPrefetchData || {};
61
+ const stack = getStackData(element);
62
+ if (!stack || !stack.imageIds || stack.imageIds.length === 0) {
63
+ console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
64
+ return;
65
+ }
66
+ if (!stackPrefetch.indicesToRequest ||
67
+ !stackPrefetch.indicesToRequest.length) {
68
+ stackPrefetch.enabled = false;
69
+ }
70
+ if (stackPrefetch.enabled === false) {
71
+ return;
72
+ }
73
+ function removeFromList(imageIdIndex) {
74
+ const index = stackPrefetch.indicesToRequest.indexOf(imageIdIndex);
75
+ if (index > -1) {
76
+ stackPrefetch.indicesToRequest.splice(index, 1);
77
+ }
78
+ }
79
+ stackPrefetchData.indicesToRequest.sort((a, b) => a - b);
80
+ const indicesToRequestCopy = stackPrefetch.indicesToRequest.slice();
81
+ indicesToRequestCopy.forEach(function (imageIdIndex) {
82
+ const imageId = stack.imageIds[imageIdIndex];
83
+ if (!imageId) {
84
+ return;
85
+ }
86
+ const imageLoadObject = core_1.cache.getImageLoadObject(imageId);
87
+ if (imageLoadObject) {
88
+ removeFromList(imageIdIndex);
89
+ }
90
+ });
91
+ if (!stackPrefetch.indicesToRequest.length) {
92
+ return;
93
+ }
94
+ if (!configuration.preserveExistingPool) {
95
+ core_1.imageLoadPoolManager.clearRequestStack(requestType);
96
+ }
97
+ const nearest = nearestIndex(stackPrefetch.indicesToRequest, stack.currentImageIdIndex);
98
+ let imageId;
99
+ let nextImageIdIndex;
100
+ const preventCache = false;
101
+ function doneCallback(image) {
102
+ console.log('prefetch done: %s', image.imageId);
103
+ const imageIdIndex = stack.imageIds.indexOf(image.imageId);
104
+ removeFromList(imageIdIndex);
105
+ }
106
+ let lowerIndex = nearest.low;
107
+ let higherIndex = nearest.high;
108
+ const imageIdsToPrefetch = [];
109
+ while (lowerIndex >= 0 ||
110
+ higherIndex < stackPrefetch.indicesToRequest.length) {
111
+ const currentIndex = stack.currentImageIdIndex;
112
+ const shouldSkipLower = currentIndex - stackPrefetch.indicesToRequest[lowerIndex] >
113
+ configuration.maxImagesToPrefetch;
114
+ const shouldSkipHigher = stackPrefetch.indicesToRequest[higherIndex] - currentIndex >
115
+ configuration.maxImagesToPrefetch;
116
+ const shouldLoadLower = !shouldSkipLower && lowerIndex >= 0;
117
+ const shouldLoadHigher = !shouldSkipHigher && higherIndex < stackPrefetch.indicesToRequest.length;
118
+ if (!shouldLoadHigher && !shouldLoadLower) {
119
+ break;
120
+ }
121
+ if (shouldLoadLower) {
122
+ nextImageIdIndex = stackPrefetch.indicesToRequest[lowerIndex--];
123
+ imageId = stack.imageIds[nextImageIdIndex];
124
+ imageIdsToPrefetch.push(imageId);
125
+ }
126
+ if (shouldLoadHigher) {
127
+ nextImageIdIndex = stackPrefetch.indicesToRequest[higherIndex++];
128
+ imageId = stack.imageIds[nextImageIdIndex];
129
+ imageIdsToPrefetch.push(imageId);
130
+ }
131
+ }
132
+ const requestFn = (imageId, options) => core_1.imageLoader.loadAndCacheImage(imageId, options);
133
+ imageIdsToPrefetch.forEach((imageId) => {
134
+ const scalingParameters = core_1.utilities.getScalingParameters(imageId);
135
+ const options = {
136
+ targetBuffer: {
137
+ type: 'Float32Array',
138
+ offset: null,
139
+ length: null,
140
+ },
141
+ preScale: {
142
+ scalingParameters,
143
+ },
144
+ requestType,
145
+ };
146
+ core_1.imageLoadPoolManager.addRequest(requestFn.bind(null, imageId, options), requestType, {
147
+ imageId,
148
+ }, priority);
149
+ });
150
+ }
151
+ function getPromiseRemovedHandler(element) {
152
+ return function (e) {
153
+ const eventData = e.detail;
154
+ let stackData;
155
+ try {
156
+ stackData = getStackData(element);
157
+ }
158
+ catch (error) {
159
+ return;
160
+ }
161
+ if (!stackData || !stackData.imageIds || stackData.imageIds.length === 0) {
162
+ return;
163
+ }
164
+ const stack = stackData;
165
+ const imageIdIndex = stack.imageIds.indexOf(eventData.imageId);
166
+ if (imageIdIndex < 0) {
167
+ return;
168
+ }
169
+ const stackPrefetchData = (0, state_1.getToolState)(element);
170
+ if (!stackPrefetchData ||
171
+ !stackPrefetchData.data ||
172
+ !stackPrefetchData.data.length) {
173
+ return;
174
+ }
175
+ stackPrefetchData.indicesToRequest.push(imageIdIndex);
176
+ };
177
+ }
178
+ function onImageUpdated(e) {
179
+ clearTimeout(resetPrefetchTimeout);
180
+ resetPrefetchTimeout = setTimeout(function () {
181
+ const element = e.target;
182
+ try {
183
+ prefetch(element);
184
+ }
185
+ catch (error) {
186
+ return;
187
+ }
188
+ }, resetPrefetchDelay);
189
+ }
190
+ function enable(element) {
191
+ const stack = getStackData(element);
192
+ if (!stack || !stack.imageIds || stack.imageIds.length === 0) {
193
+ console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
194
+ return;
195
+ }
196
+ const stackPrefetchData = {
197
+ indicesToRequest: range(0, stack.imageIds.length - 1),
198
+ enabled: true,
199
+ direction: 1,
200
+ };
201
+ const indexOfCurrentImage = stackPrefetchData.indicesToRequest.indexOf(stack.currentImageIdIndex);
202
+ stackPrefetchData.indicesToRequest.splice(indexOfCurrentImage, 1);
203
+ (0, state_1.addToolState)(element, stackPrefetchData);
204
+ prefetch(element);
205
+ element.removeEventListener(core_1.Enums.Events.STACK_NEW_IMAGE, onImageUpdated);
206
+ element.addEventListener(core_1.Enums.Events.STACK_NEW_IMAGE, onImageUpdated);
207
+ const promiseRemovedHandler = getPromiseRemovedHandler(element);
208
+ core_1.eventTarget.removeEventListener(core_1.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED, promiseRemovedHandler);
209
+ core_1.eventTarget.addEventListener(core_1.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED, promiseRemovedHandler);
210
+ }
211
+ exports.enable = enable;
212
+ function disable(element) {
213
+ clearTimeout(resetPrefetchTimeout);
214
+ element.removeEventListener(core_1.Enums.Events.STACK_NEW_IMAGE, onImageUpdated);
215
+ const promiseRemovedHandler = getPromiseRemovedHandler(element);
216
+ core_1.eventTarget.removeEventListener(core_1.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED, promiseRemovedHandler);
217
+ const stackPrefetchData = (0, state_1.getToolState)(element);
218
+ if (stackPrefetchData && stackPrefetchData.data.length) {
219
+ stackPrefetchData.enabled = false;
220
+ core_1.imageLoadPoolManager.clearRequestStack(requestType);
221
+ }
222
+ }
223
+ exports.disable = disable;
224
+ function getConfiguration() {
225
+ return configuration;
226
+ }
227
+ exports.getConfiguration = getConfiguration;
228
+ function setConfiguration(config) {
229
+ configuration = config;
230
+ }
231
+ exports.setConfiguration = setConfiguration;
232
+ //# sourceMappingURL=stackPrefetch.js.map