@ohif/app 3.8.0 → 3.8.2

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 (46) hide show
  1. package/dist/{117.bundle.77cc4e62d0de5d843e2e.js → 117.bundle.17ae130d2bb21ef9d31f.js} +75 -80
  2. package/dist/{121.bundle.47f05840a5b3cdf75543.js → 121.bundle.27d181784f24551bc546.js} +2 -1
  3. package/dist/{164.bundle.b101cb64d04a22453984.js → 164.bundle.e30009bee13acb6967da.js} +554 -311
  4. package/dist/{236.bundle.f774cdc955890e6cdac9.js → 236.bundle.79a374f5fdf7fde431f4.js} +753 -140
  5. package/dist/{188.bundle.f2b81ec70ae344f57183.js → 243.bundle.7891b41d969264043783.js} +8 -8
  6. package/dist/{325.bundle.5012b0285b6baadd1884.js → 325.bundle.bfb7de5a397beae16d24.js} +11 -11
  7. package/dist/{342.bundle.36ee082163b01284eeba.js → 342.bundle.17f0c50a27c0ba1f3846.js} +7 -0
  8. package/dist/{203.bundle.3581da3a32a0b720d3a7.js → 370.bundle.e4cd6c20d3496c949374.js} +614 -455
  9. package/dist/{448.bundle.35b8f8e262fa954026df.js → 448.bundle.375bbf6d00a23e35f229.js} +2 -2
  10. package/dist/{483.bundle.581b242d7b90866fdfb9.js → 483.bundle.016de3c3ec209d9fa42a.js} +16 -3
  11. package/dist/{487.bundle.79aff4db7df5f383b423.js → 487.bundle.205821cf073b4d0d2e71.js} +2 -2
  12. package/dist/{416.bundle.9b0d7559344fd02c9e08.js → 501.bundle.de519580f8ba42802378.js} +1206 -305
  13. package/dist/{530.bundle.207b38c15c4c01e4db0e.js → 530.bundle.17b9a34fefff133e5379.js} +3 -3
  14. package/dist/{544.bundle.3542927ec15c3f688c8d.js → 544.bundle.170c67e76a6900a9a644.js} +4 -4
  15. package/dist/{206.bundle.e1ea316389b21006d3df.js → 545.bundle.c9cc3bd30adc9904cf64.js} +28 -24
  16. package/dist/{321.bundle.39a76114e54cd9833c43.js → 550.bundle.53604ec87839bd9b4a49.js} +82 -49
  17. package/dist/{574.bundle.4b059c95cd34efdc9cb3.js → 574.bundle.b369b11b04c3e080f0b3.js} +40 -37
  18. package/dist/{41.bundle.64e0da470e235cfac4bb.js → 682.bundle.fdd752d2920107f695fb.js} +26 -6
  19. package/dist/{699.bundle.b9666b1d4ddf7e8577ee.js → 699.bundle.fee3d1c6609ecc557a9a.js} +32 -3
  20. package/dist/{669.bundle.64309c677c5ca188348c.js → 721.bundle.d01a6829ac9b0abef67d.js} +73 -73
  21. package/dist/{722.bundle.52eb61926d08a08793fe.js → 722.bundle.1242e0348afc63ca4f5e.js} +10 -4
  22. package/dist/{724.bundle.72aef9dfca69ae057d37.js → 776.bundle.bb8a64b917ff1e559734.js} +13 -15
  23. package/dist/{862.bundle.9897a9b748078d53f9ab.js → 862.bundle.59bb164ca7e871a33e44.js} +1 -1
  24. package/dist/{889.bundle.b6231f995fd098f7e3f9.js → 889.bundle.5b10c495e1442d648ffc.js} +8 -8
  25. package/dist/{905.bundle.cd3e2b347340dd47a1b0.js → 905.bundle.1ba21a0406473fc92696.js} +2 -2
  26. package/dist/{907.bundle.723a425dedf8147243d2.js → 907.bundle.b199f25916a94c4ebb97.js} +2 -2
  27. package/dist/{473.bundle.11f707c8170ade2eb56a.js → 914.bundle.2b3a856b7d41ac8298e6.js} +510 -272
  28. package/dist/{94.bundle.33ca3bc10aa42716dbbb.js → 94.bundle.ae3ca435b134c95aea2e.js} +38 -8
  29. package/dist/{961.bundle.2c4663737c970764a41e.js → 961.bundle.d1b25d8f354bde3be17c.js} +2 -2
  30. package/dist/{7.bundle.94692aed50fe4ba2e2f5.js → 981.bundle.808058a6555d322675e1.js} +15 -15
  31. package/dist/{594.bundle.c292423defd9581bfbe3.js → 989.bundle.b929ddc23c16980560de.js} +5 -5
  32. package/dist/{633.bundle.e258ba4843985e67336a.js → 998.bundle.df083f740270855652bd.js} +21 -20
  33. package/dist/app-config.js +5 -1
  34. package/dist/{app.bundle.a05edb830ad2ecd67aac.js → app.bundle.7fa3782f7fa236cc53a8.js} +791 -568
  35. package/dist/app.bundle.css +1 -1
  36. package/dist/cornerstoneDICOMImageLoader.min.js +1 -1
  37. package/dist/cornerstoneDICOMImageLoader.min.js.map +1 -1
  38. package/dist/google.js +1 -0
  39. package/dist/index.html +1 -1
  40. package/dist/{polySeg.bundle.4442dd3318266fddf4d0.js → polySeg.bundle.36ddebc98d8b109edf33.js} +3 -3
  41. package/dist/{suv-peak-worker.bundle.348c016f7f973d05f2d2.js → suv-peak-worker.bundle.f4df597fab47d977d7f3.js} +3 -3
  42. package/dist/sw.js +1 -1
  43. package/package.json +18 -18
  44. /package/dist/{321.css → 550.css} +0 -0
  45. /package/dist/{783.bundle.11d774eb13ffc74cdca5.js → 783.bundle.f4f09b94ebe4d1a466b1.js} +0 -0
  46. /package/dist/{633.css → 998.css} +0 -0
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[473],{
2
+ (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[914],{
3
3
 
4
4
  /***/ 52454:
5
5
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
@@ -154,7 +154,7 @@ class AnnotationTool extends _AnnotationDisplayTool__WEBPACK_IMPORTED_MODULE_2__
154
154
  if (viewport instanceof _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.BaseVolumeViewport) {
155
155
  const volumeId = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getVolumeId(targetId);
156
156
  const volume = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(volumeId);
157
- return volume.scaling?.PT !== undefined;
157
+ return volume?.scaling?.PT !== undefined;
158
158
  }
159
159
  const scalingModule = imageId && _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.metaData.get('scalingModule', imageId);
160
160
  return typeof scalingModule?.suvbw === 'number';
@@ -293,6 +293,102 @@ class AnnotationFrameRange {
293
293
  }
294
294
 
295
295
 
296
+ /***/ }),
297
+
298
+ /***/ 25781:
299
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
300
+
301
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
302
+ /* harmony export */ i: () => (/* binding */ annotationHydration),
303
+ /* harmony export */ x: () => (/* binding */ getClosestImageIdForStackViewport)
304
+ /* harmony export */ });
305
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(92136);
306
+ /* harmony import */ var _stateManagement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(95778);
307
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(44753);
308
+
309
+
310
+
311
+ function annotationHydration(viewport, toolName, worldPoints, options) {
312
+ const viewReference = viewport.getViewReference();
313
+ const { viewPlaneNormal, FrameOfReferenceUID } = viewReference;
314
+ const annotation = {
315
+ annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.uuidv4(),
316
+ data: {
317
+ handles: {
318
+ points: worldPoints,
319
+ },
320
+ },
321
+ highlighted: false,
322
+ autoGenerated: false,
323
+ invalidated: false,
324
+ isLocked: false,
325
+ isVisible: true,
326
+ metadata: {
327
+ toolName,
328
+ viewPlaneNormal,
329
+ FrameOfReferenceUID,
330
+ referencedImageId: getReferencedImageId(viewport, worldPoints[0], viewPlaneNormal),
331
+ ...options,
332
+ },
333
+ };
334
+ (0,_stateManagement__WEBPACK_IMPORTED_MODULE_1__/* .addAnnotation */ .lC)(annotation, viewport.element);
335
+ return annotation;
336
+ }
337
+ function getReferencedImageId(viewport, worldPos, viewPlaneNormal) {
338
+ let referencedImageId;
339
+ if (viewport instanceof _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.StackViewport) {
340
+ referencedImageId = getClosestImageIdForStackViewport(viewport, worldPos, viewPlaneNormal);
341
+ }
342
+ else if (viewport instanceof _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.BaseVolumeViewport) {
343
+ const targetId = getTargetId(viewport);
344
+ const volumeId = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getVolumeId(targetId);
345
+ const imageVolume = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(volumeId);
346
+ referencedImageId = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getClosestImageId(imageVolume, worldPos, viewPlaneNormal);
347
+ }
348
+ else {
349
+ throw new Error('getReferencedImageId: viewport must be a StackViewport or BaseVolumeViewport');
350
+ }
351
+ return referencedImageId;
352
+ }
353
+ function getTargetId(viewport) {
354
+ const targetId = viewport.getReferenceId?.();
355
+ if (targetId) {
356
+ return targetId;
357
+ }
358
+ if (viewport instanceof _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.BaseVolumeViewport) {
359
+ return `volumeId:${getTargetVolumeId(viewport)}`;
360
+ }
361
+ throw new Error('getTargetId: viewport must have a getTargetId method');
362
+ }
363
+ function getTargetVolumeId(viewport) {
364
+ const actorEntries = viewport.getActors();
365
+ if (!actorEntries) {
366
+ return;
367
+ }
368
+ return actorEntries.find((actorEntry) => actorEntry.actor.getClassName() === 'vtkVolume')?.uid;
369
+ }
370
+ function getClosestImageIdForStackViewport(viewport, worldPos, viewPlaneNormal) {
371
+ const imageIds = viewport.getImageIds();
372
+ if (!imageIds || !imageIds.length) {
373
+ return;
374
+ }
375
+ const distanceImagePairs = imageIds.map((imageId) => {
376
+ const { imagePositionPatient } = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.metaData.get('imagePlaneModule', imageId);
377
+ const distance = calculateDistanceToImage(worldPos, imagePositionPatient, viewPlaneNormal);
378
+ return { imageId, distance };
379
+ });
380
+ distanceImagePairs.sort((a, b) => a.distance - b.distance);
381
+ return distanceImagePairs[0].imageId;
382
+ }
383
+ function calculateDistanceToImage(worldPos, ImagePositionPatient, viewPlaneNormal) {
384
+ const dir = gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.create */ .eR.create();
385
+ gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.sub */ .eR.sub(dir, worldPos, ImagePositionPatient);
386
+ const dot = gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.dot */ .eR.dot(dir, viewPlaneNormal);
387
+ return Math.abs(dot);
388
+ }
389
+
390
+
391
+
296
392
  /***/ }),
297
393
 
298
394
  /***/ 42290:
@@ -895,81 +991,6 @@ function removeContourSegmentationAnnotation(annotation) {
895
991
  }
896
992
 
897
993
 
898
- /***/ }),
899
-
900
- /***/ 93712:
901
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
902
-
903
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
904
- /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
905
- /* harmony export */ });
906
- /* harmony import */ var _RectangleROIStartEndThreshold__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(69405);
907
-
908
- function validateAnnotation(annotation) {
909
- if (!annotation?.data) {
910
- throw new Error('Tool data is empty');
911
- }
912
- if (!annotation.metadata || annotation.metadata.referenceImageId) {
913
- throw new Error('Tool data is not associated with any imageId');
914
- }
915
- }
916
- class AnnotationToPointData {
917
- constructor() {
918
- }
919
- static { this.TOOL_NAMES = {}; }
920
- static convert(annotation, index, metadataProvider) {
921
- validateAnnotation(annotation);
922
- const { toolName } = annotation.metadata;
923
- const toolClass = AnnotationToPointData.TOOL_NAMES[toolName];
924
- if (!toolClass) {
925
- throw new Error(`Unknown tool type: ${toolName}, cannot convert to RTSSReport`);
926
- }
927
- const ContourSequence = toolClass.getContourSequence(annotation, metadataProvider);
928
- const color = [
929
- Math.floor(Math.random() * 255),
930
- Math.floor(Math.random() * 255),
931
- Math.floor(Math.random() * 255),
932
- ];
933
- return {
934
- ReferencedROINumber: index + 1,
935
- ROIDisplayColor: color,
936
- ContourSequence,
937
- };
938
- }
939
- static register(toolClass) {
940
- AnnotationToPointData.TOOL_NAMES[toolClass.toolName] = toolClass;
941
- }
942
- }
943
- AnnotationToPointData.register(_RectangleROIStartEndThreshold__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A);
944
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (AnnotationToPointData);
945
-
946
-
947
- /***/ }),
948
-
949
- /***/ 14633:
950
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
951
-
952
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
953
- /* harmony export */ A: () => (/* binding */ areCoplanarContours)
954
- /* harmony export */ });
955
- /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44753);
956
-
957
- function areCoplanarContours(firstAnnotation, secondAnnotation) {
958
- const { viewPlaneNormal: firstViewPlaneNormal } = firstAnnotation.metadata;
959
- const { viewPlaneNormal: secondViewPlaneNormal } = secondAnnotation.metadata;
960
- const dot = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(firstViewPlaneNormal, secondViewPlaneNormal);
961
- const parallelPlanes = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .glMatrix.equals */ .Fd.equals(1, Math.abs(dot));
962
- if (!parallelPlanes) {
963
- return false;
964
- }
965
- const { polyline: firstPolyline } = firstAnnotation.data.contour;
966
- const { polyline: secondPolyline } = secondAnnotation.data.contour;
967
- const firstDistance = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(firstViewPlaneNormal, firstPolyline[0]);
968
- const secondDistance = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(firstViewPlaneNormal, secondPolyline[0]);
969
- return gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .glMatrix.equals */ .Fd.equals(firstDistance, secondDistance);
970
- }
971
-
972
-
973
994
  /***/ }),
974
995
 
975
996
  /***/ 53891:
@@ -998,14 +1019,92 @@ function calculatePerimeter(polyline, closed) {
998
1019
 
999
1020
  /***/ }),
1000
1021
 
1001
- /***/ 11716:
1022
+ /***/ 84045:
1002
1023
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1003
1024
 
1004
1025
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1005
- /* harmony export */ Ay: () => (__WEBPACK_DEFAULT_EXPORT__),
1006
- /* harmony export */ d1: () => (/* binding */ findContoursFromReducedSet)
1026
+ /* harmony export */ A: () => (/* binding */ findHandlePolylineIndex)
1007
1027
  /* harmony export */ });
1008
- /* unused harmony export findContours */
1028
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(92136);
1029
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(44753);
1030
+
1031
+
1032
+ const { isEqual } = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities;
1033
+ function findHandlePolylineIndex(annotation, handleIndex) {
1034
+ const { polyline } = annotation.data.contour;
1035
+ const { points } = annotation.data.handles;
1036
+ const { length } = points;
1037
+ if (handleIndex === length) {
1038
+ return polyline.length;
1039
+ }
1040
+ if (handleIndex < 0) {
1041
+ handleIndex = (handleIndex + length) % length;
1042
+ }
1043
+ if (handleIndex === 0) {
1044
+ return 0;
1045
+ }
1046
+ const handle = points[handleIndex];
1047
+ const index = polyline.findIndex((point) => isEqual(handle, point));
1048
+ if (index !== -1) {
1049
+ return index;
1050
+ }
1051
+ let closestDistance = Infinity;
1052
+ return polyline.reduce((closestIndex, point, testIndex) => {
1053
+ const distance = gl_matrix__WEBPACK_IMPORTED_MODULE_1__/* .vec3.squaredDistance */ .eR.squaredDistance(point, handle);
1054
+ if (distance < closestDistance) {
1055
+ closestDistance = distance;
1056
+ return testIndex;
1057
+ }
1058
+ return closestIndex;
1059
+ }, -1);
1060
+ }
1061
+
1062
+
1063
+ /***/ }),
1064
+
1065
+ /***/ 75908:
1066
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1067
+
1068
+ // ESM COMPAT FLAG
1069
+ __webpack_require__.r(__webpack_exports__);
1070
+
1071
+ // EXPORTS
1072
+ __webpack_require__.d(__webpack_exports__, {
1073
+ AnnotationToPointData: () => (/* reexport */ contours_AnnotationToPointData),
1074
+ acceptAutogeneratedInterpolations: () => (/* reexport */ acceptAutogeneratedInterpolations),
1075
+ areCoplanarContours: () => (/* reexport */ areCoplanarContours),
1076
+ calculatePerimeter: () => (/* reexport */ calculatePerimeter/* default */.A),
1077
+ contourFinder: () => (/* reexport */ contourFinder),
1078
+ detectContourHoles: () => (/* reexport */ detectContourHoles),
1079
+ findHandlePolylineIndex: () => (/* reexport */ findHandlePolylineIndex/* default */.A),
1080
+ generateContourSetsFromLabelmap: () => (/* reexport */ generateContourSetsFromLabelmap),
1081
+ getContourHolesDataCanvas: () => (/* reexport */ getContourHolesDataCanvas),
1082
+ getContourHolesDataWorld: () => (/* reexport */ getContourHolesDataWorld),
1083
+ getDeduplicatedVTKPolyDataPoints: () => (/* reexport */ getDeduplicatedVTKPolyDataPoints),
1084
+ interpolation: () => (/* reexport */ interpolation),
1085
+ updateContourPolyline: () => (/* reexport */ updateContourPolyline/* default */.A)
1086
+ });
1087
+
1088
+ // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/index.js + 1 modules
1089
+ var esm = __webpack_require__(44753);
1090
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/areCoplanarContours.js
1091
+
1092
+ function areCoplanarContours(firstAnnotation, secondAnnotation) {
1093
+ const { viewPlaneNormal: firstViewPlaneNormal } = firstAnnotation.metadata;
1094
+ const { viewPlaneNormal: secondViewPlaneNormal } = secondAnnotation.metadata;
1095
+ const dot = esm/* vec3.dot */.eR.dot(firstViewPlaneNormal, secondViewPlaneNormal);
1096
+ const parallelPlanes = esm/* glMatrix.equals */.Fd.equals(1, Math.abs(dot));
1097
+ if (!parallelPlanes) {
1098
+ return false;
1099
+ }
1100
+ const { polyline: firstPolyline } = firstAnnotation.data.contour;
1101
+ const { polyline: secondPolyline } = secondAnnotation.data.contour;
1102
+ const firstDistance = esm/* vec3.dot */.eR.dot(firstViewPlaneNormal, firstPolyline[0]);
1103
+ const secondDistance = esm/* vec3.dot */.eR.dot(firstViewPlaneNormal, secondPolyline[0]);
1104
+ return esm/* glMatrix.equals */.Fd.equals(firstDistance, secondDistance);
1105
+ }
1106
+
1107
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/contourFinder.js
1009
1108
  function findNextLink(line, lines, contourPoints) {
1010
1109
  let index = -1;
1011
1110
  lines.forEach((cell, i) => {
@@ -1064,21 +1163,59 @@ function findContours(lines) {
1064
1163
  function findContoursFromReducedSet(lines) {
1065
1164
  return findContours(lines);
1066
1165
  }
1067
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
1166
+ /* harmony default export */ const contourFinder = ({
1068
1167
  findContours,
1069
1168
  findContoursFromReducedSet,
1070
1169
  });
1071
1170
 
1171
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/getDeduplicatedVTKPolyDataPoints.js
1172
+ function getDeduplicatedVTKPolyDataPoints(polyData, bypass = false) {
1173
+ const points = polyData.getPoints();
1174
+ const lines = polyData.getLines();
1175
+ const pointsArray = new Array(points.getNumberOfPoints())
1176
+ .fill(0)
1177
+ .map((_, i) => points.getPoint(i).slice());
1178
+ const linesArray = new Array(lines.getNumberOfCells()).fill(0).map((_, i) => {
1179
+ const cell = lines.getCell(i * 3).slice();
1180
+ return { a: cell[0], b: cell[1] };
1181
+ });
1182
+ if (bypass) {
1183
+ return { points: pointsArray, lines: linesArray };
1184
+ }
1185
+ const newPoints = [];
1186
+ for (const [i, pt] of pointsArray.entries()) {
1187
+ const index = newPoints.findIndex((point) => point[0] === pt[0] && point[1] === pt[1] && point[2] === pt[2]);
1188
+ if (index >= 0) {
1189
+ linesArray.map((line) => {
1190
+ if (line.a === i) {
1191
+ line.a = index;
1192
+ }
1193
+ if (line.b === i) {
1194
+ line.b = index;
1195
+ }
1196
+ return line;
1197
+ });
1198
+ }
1199
+ else {
1200
+ const newIndex = newPoints.length;
1201
+ newPoints.push(pt);
1202
+ linesArray.map((line) => {
1203
+ if (line.a === i) {
1204
+ line.a = newIndex;
1205
+ }
1206
+ if (line.b === i) {
1207
+ line.b = newIndex;
1208
+ }
1209
+ return line;
1210
+ });
1211
+ }
1212
+ }
1213
+ const newLines = linesArray.filter((line) => line.a !== line.b);
1214
+ return { points: newPoints, lines: newLines };
1215
+ }
1216
+ /* harmony default export */ const contours_getDeduplicatedVTKPolyDataPoints = ({ getDeduplicatedVTKPolyDataPoints });
1072
1217
 
1073
- /***/ }),
1074
-
1075
- /***/ 92806:
1076
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1077
-
1078
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1079
- /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1080
- /* harmony export */ });
1081
- /* unused harmony export processContourHoles */
1218
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/detectContourHoles.js
1082
1219
  const getIsPointInsidePolygon = (point, vertices) => {
1083
1220
  const x = point[0];
1084
1221
  const y = point[1];
@@ -1151,67 +1288,19 @@ function processContourHoles(contours, points, useXOR = true) {
1151
1288
  }
1152
1289
  return retContours;
1153
1290
  }
1154
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ processContourHoles });
1291
+ /* harmony default export */ const detectContourHoles = ({ processContourHoles });
1155
1292
 
1156
-
1157
- /***/ }),
1158
-
1159
- /***/ 84045:
1160
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1161
-
1162
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1163
- /* harmony export */ A: () => (/* binding */ findHandlePolylineIndex)
1164
- /* harmony export */ });
1165
- /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(92136);
1166
- /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(44753);
1167
-
1168
-
1169
- const { isEqual } = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities;
1170
- function findHandlePolylineIndex(annotation, handleIndex) {
1171
- const { polyline } = annotation.data.contour;
1172
- const { points } = annotation.data.handles;
1173
- const { length } = points;
1174
- if (handleIndex === length) {
1175
- return polyline.length;
1176
- }
1177
- if (handleIndex < 0) {
1178
- handleIndex = (handleIndex + length) % length;
1179
- }
1180
- if (handleIndex === 0) {
1181
- return 0;
1182
- }
1183
- const handle = points[handleIndex];
1184
- const index = polyline.findIndex((point) => isEqual(handle, point));
1185
- if (index !== -1) {
1186
- return index;
1187
- }
1188
- let closestDistance = Infinity;
1189
- return polyline.reduce((closestIndex, point, testIndex) => {
1190
- const distance = gl_matrix__WEBPACK_IMPORTED_MODULE_1__/* .vec3.squaredDistance */ .eR.squaredDistance(point, handle);
1191
- if (distance < closestDistance) {
1192
- closestDistance = distance;
1193
- return testIndex;
1194
- }
1195
- return closestIndex;
1196
- }, -1);
1197
- }
1198
-
1199
-
1200
- /***/ }),
1201
-
1202
- /***/ 36392:
1203
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1204
-
1205
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1206
- /* harmony export */ d: () => (/* binding */ generateContourSetsFromLabelmap)
1207
- /* harmony export */ });
1208
- /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(92136);
1209
- /* harmony import */ var _kitware_vtk_js_Filters_General_ImageMarchingSquares__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(52754);
1210
- /* harmony import */ var _kitware_vtk_js_Common_Core_DataArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(45128);
1211
- /* harmony import */ var _kitware_vtk_js_Common_DataModel_ImageData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(51250);
1212
- /* harmony import */ var _contours__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(75534);
1213
- /* harmony import */ var _contourFinder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(11716);
1214
- /* harmony import */ var _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(83946);
1293
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 28 modules
1294
+ var dist_esm = __webpack_require__(92136);
1295
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Filters/General/ImageMarchingSquares.js
1296
+ var ImageMarchingSquares = __webpack_require__(52754);
1297
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/Core/DataArray.js
1298
+ var DataArray = __webpack_require__(45128);
1299
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/DataModel/ImageData.js
1300
+ var ImageData = __webpack_require__(51250);
1301
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/enums/SegmentationRepresentations.js
1302
+ var SegmentationRepresentations = __webpack_require__(83946);
1303
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js
1215
1304
 
1216
1305
 
1217
1306
 
@@ -1219,11 +1308,11 @@ function findHandlePolylineIndex(annotation, handleIndex) {
1219
1308
 
1220
1309
 
1221
1310
 
1222
- const { Labelmap } = _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A;
1311
+ const { Labelmap } = SegmentationRepresentations/* default */.A;
1223
1312
  function generateContourSetsFromLabelmap({ segmentations }) {
1224
1313
  const { representationData, segments = [0, 1] } = segmentations;
1225
1314
  const { volumeId: segVolumeId } = representationData[Labelmap];
1226
- const vol = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(segVolumeId);
1315
+ const vol = dist_esm.cache.getVolume(segVolumeId);
1227
1316
  if (!vol) {
1228
1317
  console.warn(`No volume found for ${segVolumeId}`);
1229
1318
  return;
@@ -1247,7 +1336,7 @@ function generateContourSetsFromLabelmap({ segmentations }) {
1247
1336
  continue;
1248
1337
  }
1249
1338
  const sliceContours = [];
1250
- const scalars = _kitware_vtk_js_Common_Core_DataArray__WEBPACK_IMPORTED_MODULE_2__/* ["default"].newInstance */ .Ay.newInstance({
1339
+ const scalars = DataArray/* default.newInstance */.Ay.newInstance({
1251
1340
  name: 'Scalars',
1252
1341
  numberOfComponents: 1,
1253
1342
  size: pixelsPerSlice * numSlices,
@@ -1269,10 +1358,10 @@ function generateContourSetsFromLabelmap({ segmentations }) {
1269
1358
  scalars.setValue(i, 0);
1270
1359
  }
1271
1360
  }
1272
- const mSquares = _kitware_vtk_js_Filters_General_ImageMarchingSquares__WEBPACK_IMPORTED_MODULE_1__/* ["default"].newInstance */ .Ay.newInstance({
1361
+ const mSquares = ImageMarchingSquares/* default.newInstance */.Ay.newInstance({
1273
1362
  slice: sliceIndex,
1274
1363
  });
1275
- const imageDataCopy = _kitware_vtk_js_Common_DataModel_ImageData__WEBPACK_IMPORTED_MODULE_3__/* ["default"].newInstance */ .Ay.newInstance();
1364
+ const imageDataCopy = ImageData/* default.newInstance */.Ay.newInstance();
1276
1365
  imageDataCopy.shallowCopy(vol.imageData);
1277
1366
  imageDataCopy.getPointData().setScalars(scalars);
1278
1367
  mSquares.setInputData(imageDataCopy);
@@ -1280,9 +1369,9 @@ function generateContourSetsFromLabelmap({ segmentations }) {
1280
1369
  mSquares.setContourValues(cValues);
1281
1370
  mSquares.setMergePoints(false);
1282
1371
  const msOutput = mSquares.getOutputData();
1283
- const reducedSet = (0,_contours__WEBPACK_IMPORTED_MODULE_4__.getDeduplicatedVTKPolyDataPoints)(msOutput);
1372
+ const reducedSet = getDeduplicatedVTKPolyDataPoints(msOutput);
1284
1373
  if (reducedSet.points?.length) {
1285
- const contours = (0,_contourFinder__WEBPACK_IMPORTED_MODULE_5__/* .findContoursFromReducedSet */ .d1)(reducedSet.lines);
1374
+ const contours = findContoursFromReducedSet(reducedSet.lines);
1286
1375
  sliceContours.push({
1287
1376
  contours,
1288
1377
  polyData: reducedSet,
@@ -1322,19 +1411,61 @@ function isSliceEmptyForSegment(sliceIndex, segData, pixelsPerSlice, segIndex) {
1322
1411
  }
1323
1412
 
1324
1413
 
1414
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js
1415
+ var RectangleROIStartEndThreshold = __webpack_require__(69405);
1416
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/AnnotationToPointData.js
1325
1417
 
1326
- /***/ }),
1418
+ function validateAnnotation(annotation) {
1419
+ if (!annotation?.data) {
1420
+ throw new Error('Tool data is empty');
1421
+ }
1422
+ if (!annotation.metadata || annotation.metadata.referenceImageId) {
1423
+ throw new Error('Tool data is not associated with any imageId');
1424
+ }
1425
+ }
1426
+ class AnnotationToPointData {
1427
+ constructor() {
1428
+ }
1429
+ static { this.TOOL_NAMES = {}; }
1430
+ static convert(annotation, index, metadataProvider) {
1431
+ validateAnnotation(annotation);
1432
+ const { toolName } = annotation.metadata;
1433
+ const toolClass = AnnotationToPointData.TOOL_NAMES[toolName];
1434
+ if (!toolClass) {
1435
+ throw new Error(`Unknown tool type: ${toolName}, cannot convert to RTSSReport`);
1436
+ }
1437
+ const ContourSequence = toolClass.getContourSequence(annotation, metadataProvider);
1438
+ const color = [
1439
+ Math.floor(Math.random() * 255),
1440
+ Math.floor(Math.random() * 255),
1441
+ Math.floor(Math.random() * 255),
1442
+ ];
1443
+ return {
1444
+ ReferencedROINumber: index + 1,
1445
+ ROIDisplayColor: color,
1446
+ ContourSequence,
1447
+ };
1448
+ }
1449
+ static register(toolClass) {
1450
+ AnnotationToPointData.TOOL_NAMES[toolClass.toolName] = toolClass;
1451
+ }
1452
+ }
1453
+ AnnotationToPointData.register(RectangleROIStartEndThreshold/* default */.A);
1454
+ /* harmony default export */ const contours_AnnotationToPointData = (AnnotationToPointData);
1327
1455
 
1328
- /***/ 88267:
1329
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1456
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/stateManagement/index.js
1457
+ var stateManagement = __webpack_require__(95778);
1458
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/getContourHolesDataWorld.js
1330
1459
 
1331
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1332
- /* harmony export */ A: () => (/* binding */ getContourHolesDataCanvas)
1333
- /* harmony export */ });
1334
- /* harmony import */ var _getContourHolesDataWorld__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(98043);
1460
+ function getContourHolesDataWorld(annotation) {
1461
+ const childAnnotationUIDs = annotation.childAnnotationUIDs ?? [];
1462
+ return childAnnotationUIDs.map((uid) => (0,stateManagement/* getAnnotation */.gw)(uid).data.contour.polyline);
1463
+ }
1464
+
1465
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/getContourHolesDataCanvas.js
1335
1466
 
1336
1467
  function getContourHolesDataCanvas(annotation, viewport) {
1337
- const worldHoleContours = (0,_getContourHolesDataWorld__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(annotation);
1468
+ const worldHoleContours = getContourHolesDataWorld(annotation);
1338
1469
  const canvasHoleContours = [];
1339
1470
  worldHoleContours.forEach((worldHoleContour) => {
1340
1471
  const numPoints = worldHoleContour.length;
@@ -1347,91 +1478,37 @@ function getContourHolesDataCanvas(annotation, viewport) {
1347
1478
  return canvasHoleContours;
1348
1479
  }
1349
1480
 
1481
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/updateContourPolyline.js
1482
+ var updateContourPolyline = __webpack_require__(89111);
1483
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js
1484
+ var InterpolationManager = __webpack_require__(33836);
1485
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js
1486
+
1487
+ function acceptAutogeneratedInterpolations(annotationGroupSelector, selector) {
1488
+ InterpolationManager/* default */.A.acceptAutoGenerated(annotationGroupSelector, selector);
1489
+ }
1490
+
1491
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/interpolation/index.js
1492
+ var interpolation = __webpack_require__(69115);
1493
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/findHandlePolylineIndex.js
1494
+ var findHandlePolylineIndex = __webpack_require__(84045);
1495
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/calculatePerimeter.js
1496
+ var calculatePerimeter = __webpack_require__(53891);
1497
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/index.js
1498
+
1350
1499
 
1351
- /***/ }),
1352
1500
 
1353
- /***/ 98043:
1354
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1355
1501
 
1356
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1357
- /* harmony export */ A: () => (/* binding */ getContourHolesDataWorld)
1358
- /* harmony export */ });
1359
- /* harmony import */ var _stateManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(95778);
1360
1502
 
1361
- function getContourHolesDataWorld(annotation) {
1362
- const childAnnotationUIDs = annotation.childAnnotationUIDs ?? [];
1363
- return childAnnotationUIDs.map((uid) => (0,_stateManagement__WEBPACK_IMPORTED_MODULE_0__/* .getAnnotation */ .gw)(uid).data.contour.polyline);
1364
- }
1365
1503
 
1366
1504
 
1367
- /***/ }),
1368
1505
 
1369
- /***/ 19866:
1370
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1371
1506
 
1372
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1373
- /* harmony export */ v: () => (/* binding */ getDeduplicatedVTKPolyDataPoints)
1374
- /* harmony export */ });
1375
- function getDeduplicatedVTKPolyDataPoints(polyData, bypass = false) {
1376
- const points = polyData.getPoints();
1377
- const lines = polyData.getLines();
1378
- const pointsArray = new Array(points.getNumberOfPoints())
1379
- .fill(0)
1380
- .map((_, i) => points.getPoint(i).slice());
1381
- const linesArray = new Array(lines.getNumberOfCells()).fill(0).map((_, i) => {
1382
- const cell = lines.getCell(i * 3).slice();
1383
- return { a: cell[0], b: cell[1] };
1384
- });
1385
- if (bypass) {
1386
- return { points: pointsArray, lines: linesArray };
1387
- }
1388
- const newPoints = [];
1389
- for (const [i, pt] of pointsArray.entries()) {
1390
- const index = newPoints.findIndex((point) => point[0] === pt[0] && point[1] === pt[1] && point[2] === pt[2]);
1391
- if (index >= 0) {
1392
- linesArray.map((line) => {
1393
- if (line.a === i) {
1394
- line.a = index;
1395
- }
1396
- if (line.b === i) {
1397
- line.b = index;
1398
- }
1399
- return line;
1400
- });
1401
- }
1402
- else {
1403
- const newIndex = newPoints.length;
1404
- newPoints.push(pt);
1405
- linesArray.map((line) => {
1406
- if (line.a === i) {
1407
- line.a = newIndex;
1408
- }
1409
- if (line.b === i) {
1410
- line.b = newIndex;
1411
- }
1412
- return line;
1413
- });
1414
- }
1415
- }
1416
- const newLines = linesArray.filter((line) => line.a !== line.b);
1417
- return { points: newPoints, lines: newLines };
1418
- }
1419
- /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ({ getDeduplicatedVTKPolyDataPoints });
1420
1507
 
1421
1508
 
1422
- /***/ }),
1423
1509
 
1424
- /***/ 65864:
1425
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1426
1510
 
1427
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1428
- /* harmony export */ A: () => (/* binding */ acceptAutogeneratedInterpolations)
1429
- /* harmony export */ });
1430
- /* harmony import */ var _segmentation_InterpolationManager_InterpolationManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33836);
1431
1511
 
1432
- function acceptAutogeneratedInterpolations(annotationGroupSelector, selector) {
1433
- _segmentation_InterpolationManager_InterpolationManager__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.acceptAutoGenerated(annotationGroupSelector, selector);
1434
- }
1435
1512
 
1436
1513
 
1437
1514
  /***/ }),
@@ -1463,7 +1540,7 @@ __webpack_require__.r(__webpack_exports__);
1463
1540
 
1464
1541
 
1465
1542
  function updateContourPolyline(annotation, polylineData, transforms, options) {
1466
- const { canvasToWorld } = transforms;
1543
+ const { canvasToWorld, worldToCanvas } = transforms;
1467
1544
  const { data } = annotation;
1468
1545
  const { targetWindingDirection } = polylineData;
1469
1546
  let { points: polyline } = polylineData;
@@ -1473,7 +1550,7 @@ function updateContourPolyline(annotation, polylineData, transforms, options) {
1473
1550
  let { closed } = polylineData;
1474
1551
  const numPoints = polyline.length;
1475
1552
  const polylineWorldPoints = new Array(numPoints);
1476
- const currentWindingDirection = _math__WEBPACK_IMPORTED_MODULE_1__.polyline.getWindingDirection(polyline);
1553
+ const currentPolylineWindingDirection = _math__WEBPACK_IMPORTED_MODULE_1__.polyline.getWindingDirection(polyline);
1477
1554
  const parentAnnotation = (0,_stateManagement__WEBPACK_IMPORTED_MODULE_2__/* .getParentAnnotation */ .Ay)(annotation);
1478
1555
  if (closed === undefined) {
1479
1556
  let currentClosedState = false;
@@ -1487,11 +1564,18 @@ function updateContourPolyline(annotation, polylineData, transforms, options) {
1487
1564
  ? parentAnnotation.data.contour.windingDirection * -1
1488
1565
  : targetWindingDirection;
1489
1566
  if (windingDirection === undefined) {
1490
- windingDirection = currentWindingDirection;
1567
+ windingDirection = currentPolylineWindingDirection;
1491
1568
  }
1492
- else if (windingDirection !== currentWindingDirection) {
1569
+ if (windingDirection !== currentPolylineWindingDirection) {
1493
1570
  polyline.reverse();
1494
1571
  }
1572
+ const handlePoints = data.handles.points.map((p) => worldToCanvas(p));
1573
+ if (handlePoints.length > 2) {
1574
+ const currentHandlesWindingDirection = _math__WEBPACK_IMPORTED_MODULE_1__.polyline.getWindingDirection(handlePoints);
1575
+ if (currentHandlesWindingDirection !== windingDirection) {
1576
+ data.handles.points.reverse();
1577
+ }
1578
+ }
1495
1579
  for (let i = 0; i < numPoints; i++) {
1496
1580
  polylineWorldPoints[i] = canvasToWorld(polyline[i]);
1497
1581
  }
@@ -2214,6 +2298,8 @@ __webpack_require__.d(__webpack_exports__, {
2214
2298
  Calculator: () => (/* reexport */ basic_Calculator)
2215
2299
  });
2216
2300
 
2301
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 28 modules
2302
+ var esm = __webpack_require__(92136);
2217
2303
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/math/basic/Calculator.js
2218
2304
  class Calculator {
2219
2305
  }
@@ -2221,55 +2307,73 @@ class Calculator {
2221
2307
 
2222
2308
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/math/basic/BasicStatsCalculator.js
2223
2309
 
2310
+
2311
+ const { PointsManager } = esm.utilities;
2224
2312
  class BasicStatsCalculator extends basic_Calculator {
2225
2313
  static { this.max = [-Infinity]; }
2314
+ static { this.min = [Infinity]; }
2226
2315
  static { this.sum = [0]; }
2227
- static { this.sumSquares = [0]; }
2228
- static { this.squaredDiffSum = [0]; }
2229
2316
  static { this.count = 0; }
2230
- static { this.statsCallback = ({ value: newValue }) => {
2317
+ static { this.runMean = [0]; }
2318
+ static { this.m2 = [0]; }
2319
+ static { this.pointsInShape = PointsManager.create3(1024); }
2320
+ static statsInit(options) {
2321
+ if (options.noPointsCollection) {
2322
+ BasicStatsCalculator.pointsInShape = null;
2323
+ }
2324
+ }
2325
+ static { this.statsCallback = ({ value: newValue, pointLPS = null }) => {
2231
2326
  if (Array.isArray(newValue) &&
2232
2327
  newValue.length > 1 &&
2233
2328
  this.max.length === 1) {
2234
2329
  this.max.push(this.max[0], this.max[0]);
2330
+ this.min.push(this.min[0], this.min[0]);
2235
2331
  this.sum.push(this.sum[0], this.sum[0]);
2236
- this.sumSquares.push(this.sumSquares[0], this.sumSquares[0]);
2237
- this.squaredDiffSum.push(this.squaredDiffSum[0], this.squaredDiffSum[0]);
2332
+ this.runMean.push(0, 0);
2333
+ this.m2.push(this.m2[0], this.m2[0]);
2238
2334
  }
2335
+ this.pointsInShape?.push(pointLPS);
2239
2336
  const newArray = Array.isArray(newValue) ? newValue : [newValue];
2240
2337
  this.count += 1;
2241
- this.max.forEach((it, idx) => (this.max[idx] = Math.max(it, newArray[idx])));
2242
- this.sum.map((it, idx) => (this.sum[idx] += newArray[idx]));
2243
- this.sumSquares.map((it, idx) => (this.sumSquares[idx] += newArray[idx] ** 2));
2244
- this.squaredDiffSum.map((it, idx) => (this.squaredDiffSum[idx] += Math.pow(newArray[idx] - this.sum[idx] / this.count, 2)));
2338
+ this.max.map((it, idx) => {
2339
+ const value = newArray[idx];
2340
+ const delta = value - this.runMean[idx];
2341
+ this.sum[idx] += value;
2342
+ this.runMean[idx] += delta / this.count;
2343
+ const delta2 = value - this.runMean[idx];
2344
+ this.m2[idx] += delta * delta2;
2345
+ this.min[idx] = Math.min(this.min[idx], value);
2346
+ this.max[idx] = Math.max(it, value);
2347
+ });
2245
2348
  }; }
2246
- static { this.getStatistics = () => {
2349
+ static { this.getStatistics = (options) => {
2247
2350
  const mean = this.sum.map((sum) => sum / this.count);
2248
- const stdDev = this.squaredDiffSum.map((squaredDiffSum) => Math.sqrt(squaredDiffSum / this.count));
2249
- const stdDevWithSumSquare = this.sumSquares.map((it, idx) => Math.sqrt(this.sumSquares[idx] / this.count - mean[idx] ** 2));
2351
+ const stdDev = this.m2.map((squaredDiffSum) => Math.sqrt(squaredDiffSum / this.count));
2352
+ const unit = options?.unit || null;
2250
2353
  const named = {
2251
2354
  max: {
2252
2355
  name: 'max',
2253
2356
  label: 'Max Pixel',
2254
2357
  value: singleArrayAsNumber(this.max),
2255
- unit: null,
2358
+ unit,
2359
+ },
2360
+ min: {
2361
+ name: 'min',
2362
+ label: 'Min Pixel',
2363
+ value: singleArrayAsNumber(this.min),
2364
+ unit,
2256
2365
  },
2257
2366
  mean: {
2258
2367
  name: 'mean',
2259
2368
  label: 'Mean Pixel',
2260
2369
  value: singleArrayAsNumber(mean),
2261
- unit: null,
2370
+ unit,
2262
2371
  },
2263
2372
  stdDev: {
2264
2373
  name: 'stdDev',
2265
2374
  label: 'Standard Deviation',
2266
2375
  value: singleArrayAsNumber(stdDev),
2267
- unit: null,
2268
- },
2269
- stdDevWithSumSquare: {
2270
- name: 'stdDevWithSumSquare',
2271
- value: singleArrayAsNumber(stdDevWithSumSquare),
2272
- unit: null,
2376
+ unit,
2273
2377
  },
2274
2378
  count: {
2275
2379
  name: 'count',
@@ -2277,14 +2381,17 @@ class BasicStatsCalculator extends basic_Calculator {
2277
2381
  value: this.count,
2278
2382
  unit: null,
2279
2383
  },
2384
+ pointsInShape: this.pointsInShape,
2280
2385
  array: [],
2281
2386
  };
2282
- named.array.push(named.max, named.mean, named.stdDev, named.stdDevWithSumSquare, named.count);
2387
+ named.array.push(named.max, named.mean, named.stdDev, named.stdDev, named.count);
2283
2388
  this.max = [-Infinity];
2389
+ this.min = [Infinity];
2284
2390
  this.sum = [0];
2285
- this.sumSquares = [0];
2286
- this.squaredDiffSum = [0];
2391
+ this.m2 = [0];
2392
+ this.runMean = [0];
2287
2393
  this.count = 0;
2394
+ this.pointsInShape = PointsManager.create3(1024);
2288
2395
  return named;
2289
2396
  }; }
2290
2397
  }
@@ -4491,8 +4598,8 @@ __webpack_require__.d(__webpack_exports__, {
4491
4598
  A: () => (/* binding */ contourAndFindLargestBidirectional)
4492
4599
  });
4493
4600
 
4494
- // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/index.js
4495
- var utilities_contours = __webpack_require__(75534);
4601
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/index.js + 9 modules
4602
+ var utilities_contours = __webpack_require__(75908);
4496
4603
  // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/enums/SegmentationRepresentations.js
4497
4604
  var SegmentationRepresentations = __webpack_require__(83946);
4498
4605
  // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/index.js + 1 modules
@@ -6968,14 +7075,145 @@ __webpack_require__.r(__webpack_exports__);
6968
7075
 
6969
7076
  /***/ }),
6970
7077
 
6971
- /***/ 10413:
7078
+ /***/ 14149:
6972
7079
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6973
7080
 
7081
+ // ESM COMPAT FLAG
6974
7082
  __webpack_require__.r(__webpack_exports__);
6975
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6976
- /* harmony export */ colorbar: () => (/* reexport module object */ _colorbar__WEBPACK_IMPORTED_MODULE_0__)
6977
- /* harmony export */ });
6978
- /* harmony import */ var _colorbar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(64690);
7083
+
7084
+ // EXPORTS
7085
+ __webpack_require__.d(__webpack_exports__, {
7086
+ colorbar: () => (/* reexport */ colorbar),
7087
+ windowLevel: () => (/* reexport */ windowlevel_namespaceObject)
7088
+ });
7089
+
7090
+ // NAMESPACE OBJECT: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/windowlevel/index.js
7091
+ var windowlevel_namespaceObject = {};
7092
+ __webpack_require__.r(windowlevel_namespaceObject);
7093
+ __webpack_require__.d(windowlevel_namespaceObject, {
7094
+ calculateMinMaxMean: () => (calculateMinMaxMean),
7095
+ extractWindowLevelRegionToolData: () => (extractWindowLevelRegionToolData),
7096
+ getLuminanceFromRegion: () => (getLuminanceFromRegion)
7097
+ });
7098
+
7099
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/colorbar/index.js
7100
+ var colorbar = __webpack_require__(64690);
7101
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/windowlevel/getLuminanceFromRegion.js
7102
+ function getLuminanceFromRegion(imageData, x, y, width, height) {
7103
+ const luminance = [];
7104
+ let index = 0;
7105
+ const pixelData = imageData.scalarData;
7106
+ let spIndex, row, column;
7107
+ if (imageData.color) {
7108
+ for (row = 0; row < height; row++) {
7109
+ for (column = 0; column < width; column++) {
7110
+ spIndex = ((row + y) * imageData.columns + (column + x)) * 4;
7111
+ const red = pixelData[spIndex];
7112
+ const green = pixelData[spIndex + 1];
7113
+ const blue = pixelData[spIndex + 2];
7114
+ luminance[index++] = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
7115
+ }
7116
+ }
7117
+ }
7118
+ else {
7119
+ for (row = 0; row < height; row++) {
7120
+ for (column = 0; column < width; column++) {
7121
+ spIndex = (row + y) * imageData.columns + (column + x);
7122
+ luminance[index++] = pixelData[spIndex];
7123
+ }
7124
+ }
7125
+ }
7126
+ return luminance;
7127
+ }
7128
+
7129
+
7130
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/windowlevel/calculateMinMaxMean.js
7131
+ function calculateMinMaxMean(pixelLuminance, globalMin, globalMax) {
7132
+ const numPixels = pixelLuminance.length;
7133
+ let min = globalMax;
7134
+ let max = globalMin;
7135
+ let sum = 0;
7136
+ if (numPixels < 2) {
7137
+ return {
7138
+ min,
7139
+ max,
7140
+ mean: (globalMin + globalMax) / 2,
7141
+ };
7142
+ }
7143
+ for (let index = 0; index < numPixels; index++) {
7144
+ const spv = pixelLuminance[index];
7145
+ min = Math.min(min, spv);
7146
+ max = Math.max(max, spv);
7147
+ sum += spv;
7148
+ }
7149
+ return {
7150
+ min,
7151
+ max,
7152
+ mean: sum / numPixels,
7153
+ };
7154
+ }
7155
+
7156
+
7157
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 28 modules
7158
+ var esm = __webpack_require__(92136);
7159
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/windowlevel/extractWindowLevelRegionToolData.js
7160
+
7161
+ function extractWindowLevelRegionToolData(viewport) {
7162
+ if (viewport instanceof esm.VolumeViewport) {
7163
+ return extractImageDataVolume(viewport);
7164
+ }
7165
+ if (viewport instanceof esm.StackViewport) {
7166
+ return extractImageDataStack(viewport);
7167
+ }
7168
+ throw new Error('Viewport not supported');
7169
+ }
7170
+ function extractImageDataVolume(viewport) {
7171
+ const { scalarData, width, height } = esm.utilities.getCurrentVolumeViewportSlice(viewport);
7172
+ const { min: minPixelValue, max: maxPixelValue } = esm.utilities.getMinMax(scalarData);
7173
+ const volumeId = viewport.getVolumeId();
7174
+ const volume = esm.cache.getVolume(volumeId);
7175
+ const { metadata, cornerstoneImageMetaData } = volume;
7176
+ const { Rows: rows, Columns: columns } = metadata;
7177
+ const { color } = cornerstoneImageMetaData;
7178
+ return {
7179
+ scalarData,
7180
+ width,
7181
+ height,
7182
+ minPixelValue,
7183
+ maxPixelValue,
7184
+ rows,
7185
+ columns,
7186
+ color,
7187
+ };
7188
+ }
7189
+ function extractImageDataStack(viewport) {
7190
+ const imageData = viewport.getImageData();
7191
+ const { scalarData } = imageData;
7192
+ const { min: minPixelValue, max: maxPixelValue } = esm.utilities.getMinMax(scalarData);
7193
+ const width = imageData.dimensions[0];
7194
+ const height = imageData.dimensions[1];
7195
+ const { rows, columns, color } = viewport.getCornerstoneImage();
7196
+ return {
7197
+ scalarData,
7198
+ width,
7199
+ height,
7200
+ minPixelValue,
7201
+ maxPixelValue,
7202
+ rows,
7203
+ columns,
7204
+ color,
7205
+ };
7206
+ }
7207
+
7208
+
7209
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/windowlevel/index.js
7210
+
7211
+
7212
+
7213
+
7214
+
7215
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/index.js
7216
+
6979
7217
 
6980
7218
 
6981
7219