@cornerstonejs/tools 1.61.6 → 1.62.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 (36) hide show
  1. package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +1 -1
  2. package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -1
  3. package/dist/cjs/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js.map +1 -1
  4. package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +2 -2
  5. package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
  6. package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js +1 -0
  7. package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js.map +1 -1
  8. package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js +13 -10
  9. package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js.map +1 -1
  10. package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js +0 -1
  11. package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
  12. package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +1 -1
  13. package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -1
  14. package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js.map +1 -1
  15. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +2 -2
  16. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
  17. package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js +1 -0
  18. package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js.map +1 -1
  19. package/dist/esm/utilities/contours/interpolation/getInterpolationData.js +13 -10
  20. package/dist/esm/utilities/contours/interpolation/getInterpolationData.js.map +1 -1
  21. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +0 -1
  22. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
  23. package/dist/types/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.d.ts.map +1 -1
  24. package/dist/types/utilities/contourSegmentation/removeContourSegmentationAnnotation.d.ts.map +1 -1
  25. package/dist/types/utilities/contours/interpolation/createPolylineToolData.d.ts.map +1 -1
  26. package/dist/types/utilities/contours/interpolation/getInterpolationData.d.ts.map +1 -1
  27. package/dist/types/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts.map +1 -1
  28. package/dist/umd/index.js +1 -1
  29. package/dist/umd/index.js.map +1 -1
  30. package/package.json +3 -3
  31. package/src/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.ts +1 -1
  32. package/src/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.ts +1 -0
  33. package/src/utilities/contourSegmentation/removeContourSegmentationAnnotation.ts +5 -4
  34. package/src/utilities/contours/interpolation/createPolylineToolData.ts +1 -0
  35. package/src/utilities/contours/interpolation/getInterpolationData.ts +30 -14
  36. package/src/utilities/segmentation/InterpolationManager/InterpolationManager.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.61.6",
3
+ "version": "1.62.0",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.61.6",
32
+ "@cornerstonejs/core": "^1.62.0",
33
33
  "@icr/polyseg-wasm": "0.4.0",
34
34
  "@types/offscreencanvas": "2019.7.3",
35
35
  "comlink": "^4.4.1",
@@ -59,5 +59,5 @@
59
59
  "type": "individual",
60
60
  "url": "https://ohif.org/donate"
61
61
  },
62
- "gitHead": "4d53b47bb74d03a1858b78489b38996e7d537adc"
62
+ "gitHead": "f42feae4b86eba94ce9ca3b493fb080905241007"
63
63
  }
@@ -359,7 +359,7 @@ function combinePolylines(
359
359
  metadata: {
360
360
  ...metadata,
361
361
  toolName: DEFAULT_CONTOUR_SEG_TOOLNAME,
362
- originalToolName: targetAnnotation.metadata.toolName,
362
+ originalToolName: metadata.originalToolName || metadata.toolName,
363
363
  },
364
364
  data: {
365
365
  cachedStats: {},
@@ -127,6 +127,7 @@ class FrameOfReferenceSpecificAnnotationManager implements IAnnotationManager {
127
127
  * @param toolName - Optional. The name of the tool to retrieve annotations for.
128
128
  * @returns The annotations associated with the specified group (default FrameOfReferenceUID) and tool,
129
129
  * or all annotations for the group (FrameOfReferenceUID) if the tool name is not provided.
130
+ * WARNING: The list returned here is internal tool data, not a copy, so do NOT modify it.
130
131
  */
131
132
  getAnnotations = (
132
133
  groupKey: string,
@@ -3,9 +3,10 @@ import { ContourSegmentationAnnotation } from '../../types';
3
3
 
4
4
  /**
5
5
  * Removes a contour segmentation annotation from the given annotation.
6
- * If the annotation does not have a segmentation data, an error is thrown.
6
+ * If the annotation does not have a segmentation data, this method returns
7
+ * quietly. This can occur for interpolated segmentations that have not yet
8
+ * been converted to real segmentations or other in-process segmentations.
7
9
  * @param annotation - The contour segmentation annotation to remove.
8
- * @throws Error if the annotation does not have a segmentation data.
9
10
  */
10
11
  export function removeContourSegmentationAnnotation(
11
12
  annotation: ContourSegmentationAnnotation
@@ -18,8 +19,8 @@ export function removeContourSegmentationAnnotation(
18
19
 
19
20
  const { segmentationId, segmentIndex } = annotation.data.segmentation;
20
21
  const segmentation = state.getSegmentation(segmentationId);
21
- const { annotationUIDsMap } = segmentation.representationData.CONTOUR;
22
- const annotationsUIDsSet = annotationUIDsMap.get(segmentIndex);
22
+ const { annotationUIDsMap } = segmentation?.representationData.CONTOUR || {};
23
+ const annotationsUIDsSet = annotationUIDsMap?.get(segmentIndex);
23
24
 
24
25
  if (!annotationsUIDsSet) {
25
26
  return;
@@ -30,6 +30,7 @@ export default function createPolylineToolData(
30
30
  autoGenerated: true,
31
31
  annotationUID: undefined,
32
32
  cachedStats: {},
33
+ childAnnotationUIDs: [],
33
34
  });
34
35
  Object.assign(annotation.data, {
35
36
  handles: {
@@ -45,21 +45,37 @@ export default function getInterpolationData(
45
45
  const interpolationDatas = new Map<number, Annotation[]>();
46
46
  const { toolName, originalToolName } = annotation.metadata;
47
47
  const testToolName = originalToolName || toolName;
48
- const annotations = getAnnotations(testToolName, viewport.element) || [];
49
- const modifiedAnnotations = getAnnotations(
50
- DEFAULT_CONTOUR_SEG_TOOLNAME,
51
- viewport.element
48
+ // Get a copy of the annotations list by filtering it for only
49
+ // items which are originally the right tool name
50
+ const annotations = (
51
+ (getAnnotations(
52
+ testToolName,
53
+ viewport.element
54
+ ) as ContourSegmentationAnnotation[]) || []
55
+ ).filter(
56
+ (annotation) =>
57
+ !annotation.metadata.originalToolName ||
58
+ annotation.metadata.originalToolName === testToolName
52
59
  );
53
- if (modifiedAnnotations?.length) {
54
- modifiedAnnotations.forEach((annotation) => {
55
- const { metadata } = annotation as ContourSegmentationAnnotation;
56
- if (
57
- metadata.originalToolName === testToolName &&
58
- !annotations.find((it) => it === annotation)
59
- ) {
60
- annotations.push(annotation);
61
- }
62
- });
60
+
61
+ // Then add the default contour seg tool name which has the testTool name
62
+ // to the segmentations list.
63
+ if (testToolName !== DEFAULT_CONTOUR_SEG_TOOLNAME) {
64
+ const modifiedAnnotations = getAnnotations(
65
+ DEFAULT_CONTOUR_SEG_TOOLNAME,
66
+ viewport.element
67
+ ) as ContourSegmentationAnnotation[];
68
+ if (modifiedAnnotations?.length) {
69
+ modifiedAnnotations.forEach((annotation) => {
70
+ const { metadata } = annotation;
71
+ if (
72
+ metadata.originalToolName === testToolName &&
73
+ metadata.originalToolName !== metadata.toolName
74
+ ) {
75
+ annotations.push(annotation);
76
+ }
77
+ });
78
+ }
63
79
  }
64
80
 
65
81
  if (!annotations?.length) {
@@ -122,7 +122,6 @@ export default class InterpolationManager {
122
122
  ) {
123
123
  return;
124
124
  }
125
- console.log('Interpolation annotation', annotation.annotationUID);
126
125
 
127
126
  const viewport = getViewportForAnnotation(annotation);
128
127
  if (!viewport) {