@cornerstonejs/tools 1.40.3 → 1.42.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 (211) hide show
  1. package/dist/cjs/drawingSvg/drawHandle.d.ts +4 -0
  2. package/dist/cjs/drawingSvg/drawHandle.js +66 -0
  3. package/dist/cjs/drawingSvg/drawHandle.js.map +1 -0
  4. package/dist/cjs/drawingSvg/drawHandles.js +4 -60
  5. package/dist/cjs/drawingSvg/drawHandles.js.map +1 -1
  6. package/dist/cjs/drawingSvg/index.d.ts +2 -1
  7. package/dist/cjs/drawingSvg/index.js +3 -1
  8. package/dist/cjs/drawingSvg/index.js.map +1 -1
  9. package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
  10. package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
  11. package/dist/cjs/index.d.ts +2 -2
  12. package/dist/cjs/index.js +3 -2
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/stateManagement/annotation/annotationState.js +3 -0
  15. package/dist/cjs/stateManagement/annotation/annotationState.js.map +1 -1
  16. package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
  17. package/dist/cjs/tools/annotation/BidirectionalTool.js +7 -6
  18. package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
  19. package/dist/cjs/tools/annotation/LengthTool.js +4 -3
  20. package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
  21. package/dist/cjs/tools/annotation/ProbeTool.js +24 -3
  22. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  23. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.d.ts +36 -0
  24. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js +483 -0
  25. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js.map +1 -0
  26. package/dist/cjs/tools/index.d.ts +2 -1
  27. package/dist/cjs/tools/index.js +3 -1
  28. package/dist/cjs/tools/index.js.map +1 -1
  29. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +28 -0
  30. package/dist/cjs/types/index.d.ts +2 -1
  31. package/dist/cjs/utilities/contours/AnnotationToPointData.d.ts +11 -0
  32. package/dist/cjs/utilities/contours/AnnotationToPointData.js +44 -0
  33. package/dist/cjs/utilities/contours/AnnotationToPointData.js.map +1 -0
  34. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.d.ts +6 -0
  35. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js +43 -0
  36. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
  37. package/dist/cjs/utilities/contours/contourFinder.d.ts +7 -0
  38. package/dist/cjs/utilities/contours/contourFinder.js +68 -0
  39. package/dist/cjs/utilities/contours/contourFinder.js.map +1 -0
  40. package/dist/cjs/utilities/contours/detectContourHoles.d.ts +5 -0
  41. package/dist/cjs/utilities/contours/detectContourHoles.js +78 -0
  42. package/dist/cjs/utilities/contours/detectContourHoles.js.map +1 -0
  43. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.d.ts +4 -0
  44. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js +124 -0
  45. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
  46. package/dist/cjs/utilities/contours/index.d.ts +6 -0
  47. package/dist/cjs/utilities/contours/index.js +17 -0
  48. package/dist/cjs/utilities/contours/index.js.map +1 -0
  49. package/dist/cjs/utilities/contours/mergePoints.d.ts +8 -0
  50. package/dist/cjs/utilities/contours/mergePoints.js +77 -0
  51. package/dist/cjs/utilities/contours/mergePoints.js.map +1 -0
  52. package/dist/cjs/utilities/getCalibratedUnits.d.ts +16 -2
  53. package/dist/cjs/utilities/getCalibratedUnits.js +127 -5
  54. package/dist/cjs/utilities/getCalibratedUnits.js.map +1 -1
  55. package/dist/cjs/utilities/index.d.ts +2 -1
  56. package/dist/cjs/utilities/index.js +3 -1
  57. package/dist/cjs/utilities/index.js.map +1 -1
  58. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +1 -0
  59. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js +31 -0
  60. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
  61. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.d.ts +14 -0
  62. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js +43 -0
  63. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
  64. package/dist/cjs/utilities/segmentation/findLargestBidirectional.d.ts +1 -0
  65. package/dist/cjs/utilities/segmentation/findLargestBidirectional.js +94 -0
  66. package/dist/cjs/utilities/segmentation/findLargestBidirectional.js.map +1 -0
  67. package/dist/cjs/utilities/segmentation/index.d.ts +4 -1
  68. package/dist/cjs/utilities/segmentation/index.js +7 -1
  69. package/dist/cjs/utilities/segmentation/index.js.map +1 -1
  70. package/dist/cjs/utilities/segmentation/isLineInSegment.d.ts +9 -0
  71. package/dist/cjs/utilities/segmentation/isLineInSegment.js +55 -0
  72. package/dist/cjs/utilities/segmentation/isLineInSegment.js.map +1 -0
  73. package/dist/cjs/utilities/segmentation/segmentContourAction.d.ts +17 -0
  74. package/dist/cjs/utilities/segmentation/segmentContourAction.js +122 -0
  75. package/dist/cjs/utilities/segmentation/segmentContourAction.js.map +1 -0
  76. package/dist/esm/drawingSvg/drawHandle.js +61 -0
  77. package/dist/esm/drawingSvg/drawHandle.js.map +1 -0
  78. package/dist/esm/drawingSvg/drawHandles.js +4 -60
  79. package/dist/esm/drawingSvg/drawHandles.js.map +1 -1
  80. package/dist/esm/drawingSvg/index.js +2 -1
  81. package/dist/esm/drawingSvg/index.js.map +1 -1
  82. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
  83. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
  84. package/dist/esm/index.js +2 -2
  85. package/dist/esm/index.js.map +1 -1
  86. package/dist/esm/stateManagement/annotation/annotationState.js +3 -0
  87. package/dist/esm/stateManagement/annotation/annotationState.js.map +1 -1
  88. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  89. package/dist/esm/tools/annotation/BidirectionalTool.js +7 -6
  90. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  91. package/dist/esm/tools/annotation/LengthTool.js +5 -4
  92. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  93. package/dist/esm/tools/annotation/ProbeTool.js +24 -3
  94. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  95. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +478 -0
  96. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js.map +1 -0
  97. package/dist/esm/tools/index.js +2 -1
  98. package/dist/esm/tools/index.js.map +1 -1
  99. package/dist/esm/utilities/contours/AnnotationToPointData.js +39 -0
  100. package/dist/esm/utilities/contours/AnnotationToPointData.js.map +1 -0
  101. package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js +41 -0
  102. package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
  103. package/dist/esm/utilities/contours/contourFinder.js +63 -0
  104. package/dist/esm/utilities/contours/contourFinder.js.map +1 -0
  105. package/dist/esm/utilities/contours/detectContourHoles.js +74 -0
  106. package/dist/esm/utilities/contours/detectContourHoles.js.map +1 -0
  107. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +117 -0
  108. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
  109. package/dist/esm/utilities/contours/index.js +7 -0
  110. package/dist/esm/utilities/contours/index.js.map +1 -0
  111. package/dist/esm/utilities/contours/mergePoints.js +73 -0
  112. package/dist/esm/utilities/contours/mergePoints.js.map +1 -0
  113. package/dist/esm/utilities/getCalibratedUnits.js +125 -6
  114. package/dist/esm/utilities/getCalibratedUnits.js.map +1 -1
  115. package/dist/esm/utilities/index.js +2 -1
  116. package/dist/esm/utilities/index.js.map +1 -1
  117. package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js +25 -0
  118. package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
  119. package/dist/esm/utilities/segmentation/createBidirectionalToolData.js +40 -0
  120. package/dist/esm/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
  121. package/dist/esm/utilities/segmentation/findLargestBidirectional.js +96 -0
  122. package/dist/esm/utilities/segmentation/findLargestBidirectional.js.map +1 -0
  123. package/dist/esm/utilities/segmentation/index.js +4 -1
  124. package/dist/esm/utilities/segmentation/index.js.map +1 -1
  125. package/dist/esm/utilities/segmentation/isLineInSegment.js +50 -0
  126. package/dist/esm/utilities/segmentation/isLineInSegment.js.map +1 -0
  127. package/dist/esm/utilities/segmentation/segmentContourAction.js +98 -0
  128. package/dist/esm/utilities/segmentation/segmentContourAction.js.map +1 -0
  129. package/dist/types/drawingSvg/drawHandle.d.ts +5 -0
  130. package/dist/types/drawingSvg/drawHandle.d.ts.map +1 -0
  131. package/dist/types/drawingSvg/drawHandles.d.ts.map +1 -1
  132. package/dist/types/drawingSvg/index.d.ts +2 -1
  133. package/dist/types/drawingSvg/index.d.ts.map +1 -1
  134. package/dist/types/eventDispatchers/keyboardEventHandlers/keyDown.d.ts.map +1 -1
  135. package/dist/types/index.d.ts +2 -2
  136. package/dist/types/index.d.ts.map +1 -1
  137. package/dist/types/stateManagement/annotation/annotationState.d.ts.map +1 -1
  138. package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
  139. package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
  140. package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
  141. package/dist/types/tools/annotation/ProbeTool.d.ts.map +1 -1
  142. package/dist/types/tools/annotation/UltrasoundDirectionalTool.d.ts +37 -0
  143. package/dist/types/tools/annotation/UltrasoundDirectionalTool.d.ts.map +1 -0
  144. package/dist/types/tools/index.d.ts +2 -1
  145. package/dist/types/tools/index.d.ts.map +1 -1
  146. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +28 -0
  147. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
  148. package/dist/types/types/index.d.ts +2 -1
  149. package/dist/types/types/index.d.ts.map +1 -1
  150. package/dist/types/utilities/contours/AnnotationToPointData.d.ts +12 -0
  151. package/dist/types/utilities/contours/AnnotationToPointData.d.ts.map +1 -0
  152. package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts +7 -0
  153. package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts.map +1 -0
  154. package/dist/types/utilities/contours/contourFinder.d.ts +8 -0
  155. package/dist/types/utilities/contours/contourFinder.d.ts.map +1 -0
  156. package/dist/types/utilities/contours/detectContourHoles.d.ts +6 -0
  157. package/dist/types/utilities/contours/detectContourHoles.d.ts.map +1 -0
  158. package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts +5 -0
  159. package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts.map +1 -0
  160. package/dist/types/utilities/contours/index.d.ts +7 -0
  161. package/dist/types/utilities/contours/index.d.ts.map +1 -0
  162. package/dist/types/utilities/contours/mergePoints.d.ts +9 -0
  163. package/dist/types/utilities/contours/mergePoints.d.ts.map +1 -0
  164. package/dist/types/utilities/getCalibratedUnits.d.ts +16 -2
  165. package/dist/types/utilities/getCalibratedUnits.d.ts.map +1 -1
  166. package/dist/types/utilities/index.d.ts +2 -1
  167. package/dist/types/utilities/index.d.ts.map +1 -1
  168. package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +2 -0
  169. package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts.map +1 -0
  170. package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts +15 -0
  171. package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts.map +1 -0
  172. package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts +2 -0
  173. package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts.map +1 -0
  174. package/dist/types/utilities/segmentation/index.d.ts +4 -1
  175. package/dist/types/utilities/segmentation/index.d.ts.map +1 -1
  176. package/dist/types/utilities/segmentation/isLineInSegment.d.ts +10 -0
  177. package/dist/types/utilities/segmentation/isLineInSegment.d.ts.map +1 -0
  178. package/dist/types/utilities/segmentation/segmentContourAction.d.ts +18 -0
  179. package/dist/types/utilities/segmentation/segmentContourAction.d.ts.map +1 -0
  180. package/dist/umd/index.js +1 -1
  181. package/dist/umd/index.js.map +1 -1
  182. package/package.json +3 -3
  183. package/src/drawingSvg/drawHandle.ts +88 -0
  184. package/src/drawingSvg/drawHandles.ts +9 -75
  185. package/src/drawingSvg/index.ts +2 -0
  186. package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +7 -1
  187. package/src/index.ts +2 -0
  188. package/src/stateManagement/annotation/annotationState.ts +3 -0
  189. package/src/tools/annotation/AngleTool.ts +0 -1
  190. package/src/tools/annotation/BidirectionalTool.ts +9 -5
  191. package/src/tools/annotation/LengthTool.ts +6 -8
  192. package/src/tools/annotation/ProbeTool.ts +31 -7
  193. package/src/tools/annotation/UltrasoundDirectionalTool.ts +916 -0
  194. package/src/tools/index.ts +2 -0
  195. package/src/types/ToolSpecificAnnotationTypes.ts +29 -0
  196. package/src/types/index.ts +2 -0
  197. package/src/utilities/contours/AnnotationToPointData.ts +61 -0
  198. package/src/utilities/contours/RectangleROIStartEndThreshold.ts +60 -0
  199. package/src/utilities/contours/contourFinder.ts +78 -0
  200. package/src/utilities/contours/detectContourHoles.ts +147 -0
  201. package/src/utilities/contours/generateContourSetsFromLabelmap.ts +160 -0
  202. package/src/utilities/contours/index.ts +14 -0
  203. package/src/utilities/contours/mergePoints.ts +108 -0
  204. package/src/utilities/getCalibratedUnits.ts +203 -7
  205. package/src/utilities/index.ts +2 -0
  206. package/src/utilities/segmentation/contourAndFindLargestBidirectional.ts +46 -0
  207. package/src/utilities/segmentation/createBidirectionalToolData.ts +68 -0
  208. package/src/utilities/segmentation/findLargestBidirectional.ts +159 -0
  209. package/src/utilities/segmentation/index.ts +6 -0
  210. package/src/utilities/segmentation/isLineInSegment.ts +84 -0
  211. package/src/utilities/segmentation/segmentContourAction.ts +169 -0
@@ -1,19 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCalibratedAspect = exports.getCalibratedScale = exports.getCalibratedLengthUnits = exports.getCalibratedAreaUnits = void 0;
3
+ exports.getCalibratedProbeUnitsAndValue = exports.getCalibratedAspect = exports.getCalibratedScale = exports.getCalibratedLengthUnitsAndScale = exports.getCalibratedLengthUnits = exports.getCalibratedAreaUnits = void 0;
4
4
  const core_1 = require("@cornerstonejs/core");
5
5
  const { CalibrationTypes } = core_1.Enums;
6
6
  const PIXEL_UNITS = 'px';
7
+ const SUPPORTED_REGION_DATA_TYPES = [
8
+ 1,
9
+ ];
10
+ const SUPPORTED_LENGTH_VARIANT = [
11
+ '3,3',
12
+ ];
13
+ const SUPPORTED_PROBE_VARIANT = [
14
+ '4,3',
15
+ ];
16
+ const UNIT_MAPPING = {
17
+ 3: 'cm',
18
+ 4: 'seconds',
19
+ };
20
+ const EPS = 1e-3;
7
21
  const getCalibratedLengthUnits = (handles, image) => {
8
22
  const { calibration, hasPixelSpacing } = image;
9
23
  const units = hasPixelSpacing ? 'mm' : PIXEL_UNITS;
10
- if (!calibration || !calibration.type) {
24
+ if (!calibration ||
25
+ (!calibration.type && !calibration.sequenceOfUltrasoundRegions)) {
11
26
  return units;
12
27
  }
13
28
  if (calibration.type === CalibrationTypes.UNCALIBRATED) {
14
29
  return PIXEL_UNITS;
15
30
  }
16
- if (calibration.SequenceOfUltrasoundRegions) {
31
+ if (calibration.sequenceOfUltrasoundRegions) {
17
32
  return 'US Region';
18
33
  }
19
34
  return `${units} ${calibration.type}`;
@@ -26,14 +41,121 @@ const getCalibratedAreaUnits = (handles, image) => {
26
41
  if (!calibration || !calibration.type) {
27
42
  return units;
28
43
  }
29
- if (calibration.SequenceOfUltrasoundRegions) {
44
+ if (calibration.sequenceOfUltrasoundRegions) {
30
45
  return 'US Region';
31
46
  }
32
47
  return `${units} ${calibration.type}`;
33
48
  };
34
49
  exports.getCalibratedAreaUnits = getCalibratedAreaUnits;
35
- const getCalibratedScale = (image) => { var _a; return ((_a = image.calibration) === null || _a === void 0 ? void 0 : _a.scale) || 1; };
50
+ const getCalibratedScale = (image, handles = []) => {
51
+ var _a, _b;
52
+ if ((_a = image.calibration) === null || _a === void 0 ? void 0 : _a.sequenceOfUltrasoundRegions) {
53
+ }
54
+ else if ((_b = image.calibration) === null || _b === void 0 ? void 0 : _b.scale) {
55
+ return image.calibration.scale;
56
+ }
57
+ else {
58
+ return 1;
59
+ }
60
+ };
36
61
  exports.getCalibratedScale = getCalibratedScale;
62
+ const getCalibratedLengthUnitsAndScale = (image, handles) => {
63
+ const [imageIndex1, imageIndex2] = handles;
64
+ const { calibration, hasPixelSpacing } = image;
65
+ let units = hasPixelSpacing ? 'mm' : PIXEL_UNITS;
66
+ const areaUnits = units + SQUARE;
67
+ let scale = 1;
68
+ let calibrationType = '';
69
+ if (!calibration ||
70
+ (!calibration.type && !calibration.sequenceOfUltrasoundRegions)) {
71
+ return { units, areaUnits, scale };
72
+ }
73
+ if (calibration.type === CalibrationTypes.UNCALIBRATED) {
74
+ return { units: PIXEL_UNITS, areaUnits: PIXEL_UNITS + SQUARE, scale };
75
+ }
76
+ if (calibration.sequenceOfUltrasoundRegions) {
77
+ let regions = calibration.sequenceOfUltrasoundRegions.filter((region) => imageIndex1[0] >= region.regionLocationMinX0 &&
78
+ imageIndex1[0] <= region.regionLocationMaxX1 &&
79
+ imageIndex1[1] >= region.regionLocationMinY0 &&
80
+ imageIndex1[1] <= region.regionLocationMaxY1 &&
81
+ imageIndex2[0] >= region.regionLocationMinX0 &&
82
+ imageIndex2[0] <= region.regionLocationMaxX1 &&
83
+ imageIndex2[1] >= region.regionLocationMinY0 &&
84
+ imageIndex2[1] <= region.regionLocationMaxY1);
85
+ if (!(regions === null || regions === void 0 ? void 0 : regions.length)) {
86
+ return { units, areaUnits, scale };
87
+ }
88
+ regions = regions.filter((region) => SUPPORTED_REGION_DATA_TYPES.includes(region.regionDataType) &&
89
+ SUPPORTED_LENGTH_VARIANT.includes(`${region.physicalUnitXDirection},${region.physicalUnitYDirection}`));
90
+ if (!regions.length) {
91
+ return { units: PIXEL_UNITS, areaUnits: PIXEL_UNITS + SQUARE, scale };
92
+ }
93
+ const region = regions[0];
94
+ const physicalDeltaX = Math.abs(region.physicalDeltaX);
95
+ const physicalDeltaY = Math.abs(region.physicalDeltaY);
96
+ const isSamePhysicalDelta = core_1.utilities.isEqual(physicalDeltaX, physicalDeltaY, EPS);
97
+ if (isSamePhysicalDelta) {
98
+ scale = 1 / (physicalDeltaX * physicalDeltaY * 100);
99
+ calibrationType = 'US Region';
100
+ units = 'mm';
101
+ }
102
+ else {
103
+ return { units: PIXEL_UNITS, areaUnits: PIXEL_UNITS + SQUARE, scale };
104
+ }
105
+ }
106
+ else if (calibration.scale) {
107
+ scale = calibration.scale;
108
+ }
109
+ return {
110
+ units: units + (calibrationType ? ` ${calibrationType}` : ''),
111
+ areaUnits: areaUnits + (calibrationType ? ` ${calibrationType}` : ''),
112
+ scale,
113
+ };
114
+ };
115
+ exports.getCalibratedLengthUnitsAndScale = getCalibratedLengthUnitsAndScale;
116
+ const getCalibratedProbeUnitsAndValue = (image, handles) => {
117
+ const [imageIndex] = handles;
118
+ const { calibration } = image;
119
+ let units = ['raw'];
120
+ let values = [null];
121
+ let calibrationType = '';
122
+ if (!calibration ||
123
+ (!calibration.type && !calibration.sequenceOfUltrasoundRegions)) {
124
+ return { units, values };
125
+ }
126
+ if (calibration.sequenceOfUltrasoundRegions) {
127
+ const supportedRegionsMetadata = calibration.sequenceOfUltrasoundRegions.filter((region) => SUPPORTED_REGION_DATA_TYPES.includes(region.regionDataType) &&
128
+ SUPPORTED_PROBE_VARIANT.includes(`${region.physicalUnitXDirection},${region.physicalUnitYDirection}`));
129
+ if (!(supportedRegionsMetadata === null || supportedRegionsMetadata === void 0 ? void 0 : supportedRegionsMetadata.length)) {
130
+ return { units, values };
131
+ }
132
+ const region = supportedRegionsMetadata.find((region) => imageIndex[0] >= region.regionLocationMinX0 &&
133
+ imageIndex[0] <= region.regionLocationMaxX1 &&
134
+ imageIndex[1] >= region.regionLocationMinY0 &&
135
+ imageIndex[1] <= region.regionLocationMaxY1);
136
+ if (!region) {
137
+ return { units, values };
138
+ }
139
+ const { referencePixelX0 = 0, referencePixelY0 = 0 } = region;
140
+ const { physicalDeltaX, physicalDeltaY } = region;
141
+ const yValue = (imageIndex[1] - region.regionLocationMinY0 - referencePixelY0) *
142
+ physicalDeltaY;
143
+ const xValue = (imageIndex[0] - region.regionLocationMinX0 - referencePixelX0) *
144
+ physicalDeltaX;
145
+ calibrationType = 'US Region';
146
+ values = [xValue, yValue];
147
+ units = [
148
+ UNIT_MAPPING[region.physicalUnitXDirection],
149
+ UNIT_MAPPING[region.physicalUnitYDirection],
150
+ ];
151
+ }
152
+ return {
153
+ units,
154
+ values,
155
+ calibrationType,
156
+ };
157
+ };
158
+ exports.getCalibratedProbeUnitsAndValue = getCalibratedProbeUnitsAndValue;
37
159
  const getCalibratedAspect = (image) => { var _a; return ((_a = image.calibration) === null || _a === void 0 ? void 0 : _a.aspect) || 1; };
38
160
  exports.getCalibratedAspect = getCalibratedAspect;
39
161
  exports.default = getCalibratedLengthUnits;
@@ -1 +1 @@
1
- {"version":3,"file":"getCalibratedUnits.js","sourceRoot":"","sources":["../../../src/utilities/getCalibratedUnits.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAE5C,MAAM,EAAE,gBAAgB,EAAE,GAAG,YAAK,CAAC;AACnC,MAAM,WAAW,GAAG,IAAI,CAAC;AAkBzB,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAU,EAAE;IAC1D,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;IAE/C,MAAM,KAAK,GAAG,eAAe,CA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,GAAG,MAAM,CAAC;QAElD,MAAM,MAAM,GACV,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,mBAAmB,GAAG,gBAAgB,CAAC;YAC/D,cAAc,CAAC;QAEjB,MAAM,MAAM,GACV,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,mBAAmB,GAAG,gBAAgB,CAAC;YAC/D,cAAc,CAAC;QAEjB,eAAe,GAAG,WAAW,CAAC;QAC9B,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,KAAK,GAAG;YACN,YAAY,CAAC,MAAM,CAAC,sBAAsB,CAAC;YAC3C,YAAY,CAAC,MAAM,CAAC,sBAAsB,CAAC;SAC5C,CAAC;KACH;IAED,OAAO;QACL,KAAK;QACL,MAAM;QACN,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAkBA,0EAA+B;AAVjC,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,KAAK,CAAC,WAAW,0CAAE,MAAM,KAAI,CAAC,CAAA,EAAA,CAAC;AASpE,kDAAmB;AAPrB,kBAAe,wBAAwB,CAAC"}
@@ -14,6 +14,7 @@ import scroll from './scroll';
14
14
  import roundNumber from './roundNumber';
15
15
  import { pointToString } from './pointToString';
16
16
  import annotationFrameRange from './annotationFrameRange';
17
+ import * as contours from './contours';
17
18
  import * as segmentation from './segmentation';
18
19
  import * as drawing from './drawing';
19
20
  import * as math from './math';
@@ -31,4 +32,4 @@ import * as dynamicVolume from './dynamicVolume';
31
32
  import * as polyDataUtils from './polyData/utils';
32
33
  import * as voi from './voi';
33
34
  import { triggerEvent } from '@cornerstonejs/core';
34
- export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnits, getCalibratedAreaUnits, getCalibratedScale, segmentation, triggerAnnotationRenderForViewportIds, triggerAnnotationRender, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, viewport, cine, clip, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, scroll, roundNumber, pointToString, polyDataUtils, voi, annotationFrameRange, };
35
+ export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnits, getCalibratedAreaUnits, getCalibratedScale, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRender, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, viewport, cine, clip, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, scroll, roundNumber, pointToString, polyDataUtils, voi, annotationFrameRange, };
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.annotationFrameRange = exports.voi = exports.polyDataUtils = exports.pointToString = exports.roundNumber = exports.scroll = exports.stackContextPrefetch = exports.stackPrefetch = exports.planarFreehandROITool = exports.rectangleROITool = exports.boundingBox = exports.clip = exports.cine = exports.viewport = exports.jumpToSlice = exports.getAnnotationNearPointOnEnabledElement = exports.getAnnotationNearPoint = exports.pointInSurroundingSphereCallback = exports.pointInShapeCallback = exports.triggerAnnotationRender = exports.triggerAnnotationRenderForViewportIds = exports.segmentation = exports.getCalibratedScale = exports.getCalibratedAreaUnits = exports.getCalibratedLengthUnits = exports.calibrateImageSpacing = exports.triggerEvent = exports.touch = exports.isObject = exports.orientation = exports.throttle = exports.dynamicVolume = exports.debounce = exports.drawing = exports.viewportFilters = exports.planar = exports.math = void 0;
29
+ exports.annotationFrameRange = exports.voi = exports.polyDataUtils = exports.pointToString = exports.roundNumber = exports.scroll = exports.stackContextPrefetch = exports.stackPrefetch = exports.planarFreehandROITool = exports.rectangleROITool = exports.boundingBox = exports.clip = exports.cine = exports.viewport = exports.jumpToSlice = exports.getAnnotationNearPointOnEnabledElement = exports.getAnnotationNearPoint = exports.pointInSurroundingSphereCallback = exports.pointInShapeCallback = exports.triggerAnnotationRender = exports.triggerAnnotationRenderForViewportIds = exports.contours = exports.segmentation = exports.getCalibratedScale = exports.getCalibratedAreaUnits = exports.getCalibratedLengthUnits = exports.calibrateImageSpacing = exports.triggerEvent = exports.touch = exports.isObject = exports.orientation = exports.throttle = exports.dynamicVolume = exports.debounce = exports.drawing = exports.viewportFilters = exports.planar = exports.math = void 0;
30
30
  const getAnnotationNearPoint_1 = require("./getAnnotationNearPoint");
31
31
  Object.defineProperty(exports, "getAnnotationNearPoint", { enumerable: true, get: function () { return getAnnotationNearPoint_1.getAnnotationNearPoint; } });
32
32
  Object.defineProperty(exports, "getAnnotationNearPointOnEnabledElement", { enumerable: true, get: function () { return getAnnotationNearPoint_1.getAnnotationNearPointOnEnabledElement; } });
@@ -62,6 +62,8 @@ const pointToString_1 = require("./pointToString");
62
62
  Object.defineProperty(exports, "pointToString", { enumerable: true, get: function () { return pointToString_1.pointToString; } });
63
63
  const annotationFrameRange_1 = __importDefault(require("./annotationFrameRange"));
64
64
  exports.annotationFrameRange = annotationFrameRange_1.default;
65
+ const contours = __importStar(require("./contours"));
66
+ exports.contours = contours;
65
67
  const segmentation = __importStar(require("./segmentation"));
66
68
  exports.segmentation = segmentation;
67
69
  const drawing = __importStar(require("./drawing"));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAGkC;AAkEhC,uGApEA,+CAAsB,OAoEA;AACtB,uHApEA,+DAAsC,OAoEA;AAhExC,0DAAkC;AA+ChC,mBA/CK,kBAAQ,CA+CL;AA9CV,0DAAkC;AAgDhC,mBAhDK,kBAAQ,CAgD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Bb,6CAA+B;AAwC7B,oBAAI;AAvCN,2DAA6C;AAyC3C,kCAAW;AAxCb,+EAAiE;AA0C/D,sDAAqB;AAzCvB,qEAAuD;AAwCrD,4CAAgB;AAvClB,mDAAsE;AAyCpE,8FAzCO,6BAAa,OAyCP;AACb,qGA1CsB,oCAAoB,OA0CtB;AAzCtB,qDAAuC;AAkCrC,4BAAQ;AAjCV,+CAAiC;AAkB/B,sBAAK;AAjBP,+DAAiD;AAa/C,sCAAa;AAZf,gEAAkD;AA0ChD,sCAAa;AAzCf,2CAA6B;AA0C3B,kBAAG;AAvCL,8CAAmD;AAajD,6FAbO,mBAAY,OAaP"}
@@ -0,0 +1 @@
1
+ export default function contourAndFindLargestBidirectional(segmentation: any): any;
@@ -0,0 +1,31 @@
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 contours_1 = require("../contours");
7
+ const SegmentationRepresentations_1 = __importDefault(require("../../enums/SegmentationRepresentations"));
8
+ const findLargestBidirectional_1 = __importDefault(require("./findLargestBidirectional"));
9
+ const EPSILON = 1e-2;
10
+ const { Labelmap } = SegmentationRepresentations_1.default;
11
+ function contourAndFindLargestBidirectional(segmentation) {
12
+ const contours = (0, contours_1.generateContourSetsFromLabelmap)({
13
+ segmentations: segmentation,
14
+ });
15
+ if (!(contours === null || contours === void 0 ? void 0 : contours.length) || !contours[0].sliceContours.length) {
16
+ return;
17
+ }
18
+ const { representationData, segments = [
19
+ null,
20
+ { label: 'Unspecified', color: null, containedSegmentIndices: null },
21
+ ], } = segmentation;
22
+ const { volumeId: segVolumeId } = representationData[Labelmap];
23
+ const segmentIndex = segments.findIndex((it) => !!it);
24
+ if (segmentIndex === -1) {
25
+ return;
26
+ }
27
+ segments[segmentIndex].segmentIndex = segmentIndex;
28
+ return (0, findLargestBidirectional_1.default)(contours[0], segVolumeId, segments[segmentIndex]);
29
+ }
30
+ exports.default = contourAndFindLargestBidirectional;
31
+ //# sourceMappingURL=contourAndFindLargestBidirectional.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contourAndFindLargestBidirectional.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/contourAndFindLargestBidirectional.ts"],"names":[],"mappings":";;;;;AAAA,0CAA8D;AAC9D,0GAAkF;AAClF,0FAAkE;AAElE,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,qCAA2B,CAAC;AAYjD,SAAwB,kCAAkC,CAAC,YAAY;IACrE,MAAM,QAAQ,GAAG,IAAA,0CAA+B,EAAC;QAC/C,aAAa,EAAE,YAAY;KAC5B,CAAC,CAAC;IAEH,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAA,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE;QAC1D,OAAO;KACR;IAED,MAAM,EACJ,kBAAkB,EAClB,QAAQ,GAAG;QACT,IAAI;QACJ,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE;KACrE,GACF,GAAG,YAAY,CAAC;IACjB,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE/D,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;QACvB,OAAO;KACR;IACD,QAAQ,CAAC,YAAY,CAAC,CAAC,YAAY,GAAG,YAAY,CAAC;IACnD,OAAO,IAAA,kCAAwB,EAC7B,QAAQ,CAAC,CAAC,CAAC,EACX,WAAW,EACX,QAAQ,CAAC,YAAY,CAAC,CACvB,CAAC;AACJ,CAAC;AA5BD,qDA4BC"}
@@ -0,0 +1,14 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import type { Annotation } from '../../types/AnnotationTypes';
3
+ export declare type BidirectionalData = {
4
+ majorAxis: [Types.Point3, Types.Point3];
5
+ minorAxis: [Types.Point3, Types.Point3];
6
+ maxMajor: number;
7
+ maxMinor: number;
8
+ segmentIndex: number;
9
+ label?: string;
10
+ color?: string | number[];
11
+ referencedImageId: string;
12
+ FrameOfReferenceUID: string;
13
+ };
14
+ export default function createBidirectionalToolData(bidirectionalData: BidirectionalData, viewport: any): Annotation;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function createBidirectionalToolData(bidirectionalData, viewport) {
4
+ const { majorAxis, minorAxis, label = '', FrameOfReferenceUID, referencedImageId, } = bidirectionalData;
5
+ const [major0, major1] = majorAxis;
6
+ const [minor0, minor1] = minorAxis;
7
+ const { viewUp, viewPlaneNormal } = viewport.getCamera();
8
+ const points = [major0, major1, minor0, minor1];
9
+ const bidirectionalToolData = {
10
+ highlighted: true,
11
+ invalidated: true,
12
+ metadata: {
13
+ toolName: 'Bidirectional',
14
+ viewPlaneNormal,
15
+ viewUp,
16
+ FrameOfReferenceUID,
17
+ referencedImageId,
18
+ },
19
+ data: {
20
+ handles: {
21
+ points,
22
+ textBox: {
23
+ hasMoved: false,
24
+ worldPosition: [0, 0, 0],
25
+ worldBoundingBox: {
26
+ topLeft: [0, 0, 0],
27
+ topRight: [0, 0, 0],
28
+ bottomLeft: [0, 0, 0],
29
+ bottomRight: [0, 0, 0],
30
+ },
31
+ },
32
+ activeHandleIndex: null,
33
+ },
34
+ label,
35
+ cachedStats: {},
36
+ },
37
+ isLocked: false,
38
+ isVisible: true,
39
+ };
40
+ return bidirectionalToolData;
41
+ }
42
+ exports.default = createBidirectionalToolData;
43
+ //# sourceMappingURL=createBidirectionalToolData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBidirectionalToolData.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/createBidirectionalToolData.ts"],"names":[],"mappings":";;AAmBA,SAAwB,2BAA2B,CACjD,iBAAoC,EACpC,QAAQ;IAER,MAAM,EACJ,SAAS,EACT,SAAS,EACT,KAAK,GAAG,EAAE,EACV,mBAAmB,EACnB,iBAAiB,GAClB,GAAG,iBAAiB,CAAC;IACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAEnC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;IACzD,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,qBAAqB,GAAG;QAC5B,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,QAAQ,EAAE;YACR,QAAQ,EAAE,eAAe;YACzB,eAAe;YACf,MAAM;YACN,mBAAmB;YACnB,iBAAiB;SAClB;QACD,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,MAAM;gBACN,OAAO,EAAE;oBACP,QAAQ,EAAE,KAAK;oBACf,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAiB;oBACxC,gBAAgB,EAAE;wBAChB,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAiB;wBAClC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAiB;wBACnC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAiB;wBACrC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAiB;qBACvC;iBACF;gBACD,iBAAiB,EAAE,IAAI;aACxB;YACD,KAAK;YACL,WAAW,EAAE,EAAE;SAChB;QACD,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,IAAI;KAChB,CAAC;IACF,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAhDD,8CAgDC"}
@@ -0,0 +1 @@
1
+ export default function findLargestBidirectional(contours: any, segVolumeId: string, segment: any): any;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const gl_matrix_1 = require("gl-matrix");
4
+ const isLineInSegment_1 = require("./isLineInSegment");
5
+ const EPSILON = 1e-2;
6
+ function findLargestBidirectional(contours, segVolumeId, segment) {
7
+ const { sliceContours } = contours;
8
+ const { segmentIndex, containedSegmentIndices } = segment;
9
+ let maxBidirectional;
10
+ const isInSegment = (0, isLineInSegment_1.createIsInSegment)(segVolumeId, segmentIndex, containedSegmentIndices);
11
+ for (const sliceContour of sliceContours) {
12
+ const bidirectional = createBidirectionalForSlice(sliceContour, isInSegment, maxBidirectional);
13
+ if (!bidirectional) {
14
+ continue;
15
+ }
16
+ maxBidirectional = bidirectional;
17
+ }
18
+ if (maxBidirectional) {
19
+ Object.assign(maxBidirectional, segment);
20
+ }
21
+ return maxBidirectional;
22
+ }
23
+ exports.default = findLargestBidirectional;
24
+ function createBidirectionalForSlice(sliceContour, isInSegment, currentMax = { maxMajor: 0, maxMinor: 0 }) {
25
+ const { points } = sliceContour.polyData;
26
+ const { maxMinor: currentMaxMinor, maxMajor: currentMaxMajor } = currentMax;
27
+ let maxMajor = currentMaxMajor * currentMaxMajor;
28
+ let maxMinor = currentMaxMinor * currentMaxMinor;
29
+ let maxMajorPoints;
30
+ for (let index1 = 0; index1 < points.length; index1++) {
31
+ for (let index2 = index1 + 1; index2 < points.length; index2++) {
32
+ const point1 = points[index1];
33
+ const point2 = points[index2];
34
+ const distance2 = gl_matrix_1.vec3.sqrDist(point1, point2);
35
+ if (distance2 < maxMajor) {
36
+ continue;
37
+ }
38
+ if (distance2 - EPSILON < maxMajor + EPSILON && maxMajorPoints) {
39
+ continue;
40
+ }
41
+ if (!isInSegment.testCenter(point1, point2)) {
42
+ continue;
43
+ }
44
+ if (!(0, isLineInSegment_1.isLineInSegment)(point1, point2, isInSegment)) {
45
+ continue;
46
+ }
47
+ maxMajor = distance2 - EPSILON;
48
+ maxMajorPoints = [index1, index2];
49
+ maxMinor = 0;
50
+ }
51
+ }
52
+ if (!maxMajorPoints) {
53
+ return;
54
+ }
55
+ maxMajor = Math.sqrt(maxMajor + EPSILON);
56
+ const handle0 = points[maxMajorPoints[0]];
57
+ const handle1 = points[maxMajorPoints[1]];
58
+ const unitMajor = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), handle0, handle1);
59
+ gl_matrix_1.vec3.scale(unitMajor, unitMajor, 1 / maxMajor);
60
+ let maxMinorPoints;
61
+ for (let index1 = 0; index1 < points.length; index1++) {
62
+ for (let index2 = index1 + 1; index2 < points.length; index2++) {
63
+ const point1 = points[index1];
64
+ const point2 = points[index2];
65
+ const distance2 = gl_matrix_1.vec3.sqrDist(point1, point2);
66
+ if (distance2 <= maxMinor) {
67
+ continue;
68
+ }
69
+ const delta = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), point1, point2);
70
+ const dot = Math.abs(gl_matrix_1.vec3.dot(delta, unitMajor)) / Math.sqrt(distance2);
71
+ if (dot > EPSILON) {
72
+ continue;
73
+ }
74
+ if (!isInSegment.testCenter(point1, point2)) {
75
+ continue;
76
+ }
77
+ if (!(0, isLineInSegment_1.isLineInSegment)(point1, point2, isInSegment)) {
78
+ continue;
79
+ }
80
+ maxMinor = distance2;
81
+ maxMinorPoints = [index1, index2];
82
+ }
83
+ }
84
+ if (!maxMinorPoints) {
85
+ return;
86
+ }
87
+ maxMinor = Math.sqrt(maxMinor);
88
+ const handle2 = points[maxMinorPoints[0]];
89
+ const handle3 = points[maxMinorPoints[1]];
90
+ const bidirectional = Object.assign({ majorAxis: [handle0, handle1], minorAxis: [handle2, handle3], maxMajor,
91
+ maxMinor }, sliceContour);
92
+ return bidirectional;
93
+ }
94
+ //# sourceMappingURL=findLargestBidirectional.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findLargestBidirectional.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/findLargestBidirectional.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AAEjC,uDAAuE;AAGvE,MAAM,OAAO,GAAG,IAAI,CAAC;AAqBrB,SAAwB,wBAAwB,CAC9C,QAAQ,EACR,WAAmB,EACnB,OAAO;IAEP,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;IACnC,MAAM,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;IAC1D,IAAI,gBAAgB,CAAC;IACrB,MAAM,WAAW,GAAG,IAAA,mCAAiB,EACnC,WAAW,EACX,YAAY,EACZ,uBAAuB,CACxB,CAAC;IACF,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,MAAM,aAAa,GAAG,2BAA2B,CAC/C,YAAY,EACZ,WAAW,EACX,gBAAgB,CACjB,CAAC;QACF,IAAI,CAAC,aAAa,EAAE;YAClB,SAAS;SACV;QACD,gBAAgB,GAAG,aAAa,CAAC;KAClC;IACD,IAAI,gBAAgB,EAAE;QACpB,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;KAC1C;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA5BD,2CA4BC;AAWD,SAAS,2BAA2B,CAClC,YAAY,EACZ,WAAW,EACX,UAAU,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE;IAEzC,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,QAAQ,CAAC;IACzC,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,UAAU,CAAC;IAC5E,IAAI,QAAQ,GAAG,eAAe,GAAG,eAAe,CAAC;IACjD,IAAI,QAAQ,GAAG,eAAe,GAAG,eAAe,CAAC;IACjD,IAAI,cAA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R;IACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1C,MAAM,aAAa,GAAG,gBACpB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAC7B,QAAQ;QACR,QAAQ,IACL,YAAY,CACK,CAAC;IACvB,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -9,4 +9,7 @@ import floodFill from './floodFill';
9
9
  import { getBrushSizeForToolGroup, setBrushSizeForToolGroup } from './brushSizeForToolGroup';
10
10
  import { getBrushThresholdForToolGroup, setBrushThresholdForToolGroup } from './brushThresholdForToolGroup';
11
11
  import thresholdSegmentationByRange from './thresholdSegmentationByRange';
12
- export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, };
12
+ import contourAndFindLargestBidirectional from './contourAndFindLargestBidirectional';
13
+ import createBidirectionalToolData from './createBidirectionalToolData';
14
+ import segmentContourAction from './segmentContourAction';
15
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, };
@@ -3,7 +3,7 @@ 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.thresholdSegmentationByRange = exports.setBrushThresholdForToolGroup = exports.getBrushThresholdForToolGroup = exports.setBrushSizeForToolGroup = exports.getBrushSizeForToolGroup = exports.floodFill = exports.triggerSegmentationRender = exports.rectangleROIThresholdVolumeByRange = exports.createLabelmapVolumeForViewport = exports.getDefaultRepresentationConfig = exports.isValidRepresentationConfig = exports.createMergedLabelmapForIndex = exports.thresholdVolumeByRange = void 0;
6
+ exports.segmentContourAction = exports.createBidirectionalToolData = exports.contourAndFindLargestBidirectional = exports.thresholdSegmentationByRange = exports.setBrushThresholdForToolGroup = exports.getBrushThresholdForToolGroup = exports.setBrushSizeForToolGroup = exports.getBrushSizeForToolGroup = exports.floodFill = exports.triggerSegmentationRender = exports.rectangleROIThresholdVolumeByRange = exports.createLabelmapVolumeForViewport = exports.getDefaultRepresentationConfig = exports.isValidRepresentationConfig = exports.createMergedLabelmapForIndex = exports.thresholdVolumeByRange = void 0;
7
7
  const thresholdVolumeByRange_1 = __importDefault(require("./thresholdVolumeByRange"));
8
8
  exports.thresholdVolumeByRange = thresholdVolumeByRange_1.default;
9
9
  const rectangleROIThresholdVolumeByRange_1 = __importDefault(require("./rectangleROIThresholdVolumeByRange"));
@@ -28,4 +28,10 @@ Object.defineProperty(exports, "getBrushThresholdForToolGroup", { enumerable: tr
28
28
  Object.defineProperty(exports, "setBrushThresholdForToolGroup", { enumerable: true, get: function () { return brushThresholdForToolGroup_1.setBrushThresholdForToolGroup; } });
29
29
  const thresholdSegmentationByRange_1 = __importDefault(require("./thresholdSegmentationByRange"));
30
30
  exports.thresholdSegmentationByRange = thresholdSegmentationByRange_1.default;
31
+ const contourAndFindLargestBidirectional_1 = __importDefault(require("./contourAndFindLargestBidirectional"));
32
+ exports.contourAndFindLargestBidirectional = contourAndFindLargestBidirectional_1.default;
33
+ const createBidirectionalToolData_1 = __importDefault(require("./createBidirectionalToolData"));
34
+ exports.createBidirectionalToolData = createBidirectionalToolData_1.default;
35
+ const segmentContourAction_1 = __importDefault(require("./segmentContourAction"));
36
+ exports.segmentContourAction = segmentContourAction_1.default;
31
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA8D;AAmB5D,iCAnBK,gCAAsB,CAmBL;AAlBxB,8GAAsF;AAuBpF,6CAvBK,4CAAkC,CAuBL;AAtBpC,kGAA0E;AAkBxE,uCAlBK,sCAA4B,CAkBL;AAjB9B,gGAAwE;AAkBtE,sCAlBK,qCAA2B,CAkBL;AAjB7B,sGAA8E;AAkB5E,yCAlBK,wCAA8B,CAkBL;AAjBhC,wGAAgF;AAkB9E,0CAlBK,yCAA+B,CAkBL;AAjBjC,2EAAwE;AAmBtE,0GAnBO,qDAAyB,OAmBP;AAlB3B,4DAAoC;AAmBlC,oBAnBK,mBAAS,CAmBL;AAlBX,mEAGiC;AAgB/B,yGAlBA,gDAAwB,OAkBA;AACxB,yGAlBA,gDAAwB,OAkBA;AAhB1B,6EAGsC;AAcpC,8GAhBA,0DAA6B,OAgBA;AAC7B,8GAhBA,0DAA6B,OAgBA;AAd/B,kGAA0E;AAexE,uCAfK,sCAA4B,CAeL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA8D;AAsB5D,iCAtBK,gCAAsB,CAsBL;AArBxB,8GAAsF;AA0BpF,6CA1BK,4CAAkC,CA0BL;AAzBpC,kGAA0E;AAqBxE,uCArBK,sCAA4B,CAqBL;AApB9B,gGAAwE;AAqBtE,sCArBK,qCAA2B,CAqBL;AApB7B,sGAA8E;AAqB5E,yCArBK,wCAA8B,CAqBL;AApBhC,wGAAgF;AAqB9E,0CArBK,yCAA+B,CAqBL;AApBjC,2EAAwE;AAsBtE,0GAtBO,qDAAyB,OAsBP;AArB3B,4DAAoC;AAsBlC,oBAtBK,mBAAS,CAsBL;AArBX,mEAGiC;AAmB/B,yGArBA,gDAAwB,OAqBA;AACxB,yGArBA,gDAAwB,OAqBA;AAnB1B,6EAGsC;AAiBpC,8GAnBA,0DAA6B,OAmBA;AAC7B,8GAnBA,0DAA6B,OAmBA;AAjB/B,kGAA0E;AAkBxE,uCAlBK,sCAA4B,CAkBL;AAjB9B,8GAAsF;AAkBpF,6CAlBK,4CAAkC,CAkBL;AAjBpC,gGAAwE;AAkBtE,sCAlBK,qCAA2B,CAkBL;AAjB7B,kFAA0D;AAkBxD,+BAlBK,8BAAoB,CAkBL"}
@@ -0,0 +1,9 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import { vec3 } from 'gl-matrix';
3
+ export default function isLineInSegment(point1: Types.Point3, point2: Types.Point3, isInSegment: any): boolean;
4
+ declare function createIsInSegment(segVolumeId: string, segmentIndex: number, containedSegmentIndices?: Set<number>): {
5
+ testCenter: (point1: any, point2: any) => boolean;
6
+ toIJK: (point: any) => vec3;
7
+ testIJK: (ijk: any) => boolean;
8
+ };
9
+ export { createIsInSegment, isLineInSegment };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLineInSegment = exports.createIsInSegment = void 0;
4
+ const core_1 = require("@cornerstonejs/core");
5
+ const gl_matrix_1 = require("gl-matrix");
6
+ function isLineInSegment(point1, point2, isInSegment) {
7
+ const ijk1 = isInSegment.toIJK(point1);
8
+ const ijk2 = isInSegment.toIJK(point2);
9
+ const testPoint = gl_matrix_1.vec3.create();
10
+ const { testIJK } = isInSegment;
11
+ const delta = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), ijk1, ijk2);
12
+ const testSize = Math.round(Math.max(...delta.map(Math.abs)));
13
+ if (testSize < 2) {
14
+ return true;
15
+ }
16
+ const unitDelta = gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), delta, 1 / testSize);
17
+ for (let i = 1; i < testSize; i++) {
18
+ gl_matrix_1.vec3.scaleAndAdd(testPoint, ijk2, unitDelta, i);
19
+ if (!testIJK(testPoint)) {
20
+ return false;
21
+ }
22
+ }
23
+ return true;
24
+ }
25
+ exports.default = isLineInSegment;
26
+ exports.isLineInSegment = isLineInSegment;
27
+ function createIsInSegment(segVolumeId, segmentIndex, containedSegmentIndices) {
28
+ const vol = core_1.cache.getVolume(segVolumeId);
29
+ if (!vol) {
30
+ console.warn(`No volume found for ${segVolumeId}`);
31
+ return;
32
+ }
33
+ const segData = vol.imageData.getPointData().getScalars().getData();
34
+ const width = vol.dimensions[0];
35
+ const pixelsPerSlice = width * vol.dimensions[1];
36
+ return {
37
+ testCenter: (point1, point2) => {
38
+ const point = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), point1, point2).map((it) => it / 2);
39
+ const ijk = vol.imageData.worldToIndex(point).map(Math.round);
40
+ const [i, j, k] = ijk;
41
+ const index = i + j * width + k * pixelsPerSlice;
42
+ const value = segData[index];
43
+ return value === segmentIndex || (containedSegmentIndices === null || containedSegmentIndices === void 0 ? void 0 : containedSegmentIndices.has(value));
44
+ },
45
+ toIJK: (point) => vol.imageData.worldToIndex(point),
46
+ testIJK: (ijk) => {
47
+ const [i, j, k] = ijk;
48
+ const index = Math.round(i) + Math.round(j) * width + Math.round(k) * pixelsPerSlice;
49
+ const value = segData[index];
50
+ return value === segmentIndex || (containedSegmentIndices === null || containedSegmentIndices === void 0 ? void 0 : containedSegmentIndices.has(value));
51
+ },
52
+ };
53
+ }
54
+ exports.createIsInSegment = createIsInSegment;
55
+ //# sourceMappingURL=isLineInSegment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isLineInSegment.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/isLineInSegment.ts"],"names":[],"mappings":";;;AACA,8CAA4C;AAC5C,yCAAiC;AAMjC,SAAwB,eAAe,CACrC,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GACT,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC;YACzE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7B,OAAO,KAAK,KAAK,YAAY,KAAI,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,GAAG,CAAC,KAAK,CAAC,CAAA,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC;AAEQ,8CAAiB"}
@@ -0,0 +1,17 @@
1
+ import { type Types } from '@cornerstonejs/core';
2
+ export declare type Segment = {
3
+ segmentationId: string;
4
+ segmentIndex: number;
5
+ label: string;
6
+ style?: any;
7
+ containedSegmentIndices?: (number: any) => boolean;
8
+ };
9
+ export declare type SegmentContourActionConfiguration = {
10
+ getSegment?: (enabledElement: Types.IEnabledElement, configuration: SegmentContourActionConfiguration) => Segment;
11
+ segmentationId?: string;
12
+ segmentIndex?: number;
13
+ segmentData?: Map<number, Segment>;
14
+ toolGroupId?: string;
15
+ };
16
+ export default function segmentContourAction(element: HTMLDivElement, configuration: any): any;
17
+ export declare function defaultGetSegment(enabledElement: Types.IEnabledElement, configuration: SegmentContourActionConfiguration): Segment;