@cornerstonejs/tools 3.19.4 → 3.20.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.
- package/dist/esm/enums/Events.d.ts +1 -0
- package/dist/esm/enums/Events.js +1 -0
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +10 -0
- package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +6 -2
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +24 -16
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.d.ts +4 -0
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +19 -1
- package/dist/esm/tools/annotation/SplineROITool.d.ts +8 -0
- package/dist/esm/tools/annotation/SplineROITool.js +33 -0
- package/dist/esm/utilities/contourSegmentation/convertContourSegmentation.d.ts +2 -0
- package/dist/esm/utilities/contourSegmentation/convertContourSegmentation.js +49 -0
- package/dist/esm/utilities/contourSegmentation/index.d.ts +2 -1
- package/dist/esm/utilities/contourSegmentation/index.js +2 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -12,6 +12,7 @@ declare enum Events {
|
|
|
12
12
|
ANNOTATION_LOCK_CHANGE = "CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE",
|
|
13
13
|
ANNOTATION_VISIBILITY_CHANGE = "CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE",
|
|
14
14
|
ANNOTATION_RENDERED = "CORNERSTONE_TOOLS_ANNOTATION_RENDERED",
|
|
15
|
+
ANNOTATION_CUT_MERGE_PROCESS_COMPLETED = "CORNERSTONE_TOOLS_ANNOTATION_CUT_MERGE_PROCESS_COMPLETED",
|
|
15
16
|
ANNOTATION_INTERPOLATION_PROCESS_COMPLETED = "CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED",
|
|
16
17
|
INTERPOLATED_ANNOTATIONS_REMOVED = "CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED",
|
|
17
18
|
SEGMENTATION_MODIFIED = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",
|
package/dist/esm/enums/Events.js
CHANGED
|
@@ -13,6 +13,7 @@ var Events;
|
|
|
13
13
|
Events["ANNOTATION_LOCK_CHANGE"] = "CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE";
|
|
14
14
|
Events["ANNOTATION_VISIBILITY_CHANGE"] = "CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE";
|
|
15
15
|
Events["ANNOTATION_RENDERED"] = "CORNERSTONE_TOOLS_ANNOTATION_RENDERED";
|
|
16
|
+
Events["ANNOTATION_CUT_MERGE_PROCESS_COMPLETED"] = "CORNERSTONE_TOOLS_ANNOTATION_CUT_MERGE_PROCESS_COMPLETED";
|
|
16
17
|
Events["ANNOTATION_INTERPOLATION_PROCESS_COMPLETED"] = "CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED";
|
|
17
18
|
Events["INTERPOLATED_ANNOTATIONS_REMOVED"] = "CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED";
|
|
18
19
|
Events["SEGMENTATION_MODIFIED"] = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED";
|
package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { eventTarget, triggerEvent } from '@cornerstonejs/core';
|
|
1
2
|
import getViewportsForAnnotation from '../../../utilities/getViewportsForAnnotation';
|
|
2
3
|
import { getAllAnnotations } from '../../../stateManagement/annotation/annotationState';
|
|
3
4
|
import { areSameSegment, isContourSegmentationAnnotation, } from '../../../utilities/contourSegmentation';
|
|
@@ -5,6 +6,7 @@ import { getToolGroupForViewport } from '../../../store/ToolGroupManager';
|
|
|
5
6
|
import { findAllIntersectingContours } from '../../../utilities/contourSegmentation/getIntersectingAnnotations';
|
|
6
7
|
import { processMultipleIntersections } from '../../../utilities/contourSegmentation/mergeMultipleAnnotations';
|
|
7
8
|
import { convertContourPolylineToCanvasSpace, createPolylineHole, combinePolylines, } from '../../../utilities/contourSegmentation/sharedOperations';
|
|
9
|
+
import { Events } from '../../../enums';
|
|
8
10
|
const DEFAULT_CONTOUR_SEG_TOOL_NAME = 'PlanarFreehandContourSegmentationTool';
|
|
9
11
|
export default async function contourSegmentationCompletedListener(evt) {
|
|
10
12
|
const sourceAnnotation = evt.detail
|
|
@@ -15,11 +17,19 @@ export default async function contourSegmentationCompletedListener(evt) {
|
|
|
15
17
|
const viewport = getViewport(sourceAnnotation);
|
|
16
18
|
const contourSegmentationAnnotations = getValidContourSegmentationAnnotations(viewport, sourceAnnotation);
|
|
17
19
|
if (!contourSegmentationAnnotations.length) {
|
|
20
|
+
triggerEvent(eventTarget, Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, {
|
|
21
|
+
element: viewport.element,
|
|
22
|
+
sourceAnnotation,
|
|
23
|
+
});
|
|
18
24
|
return;
|
|
19
25
|
}
|
|
20
26
|
const sourcePolyline = convertContourPolylineToCanvasSpace(sourceAnnotation.data.contour.polyline, viewport);
|
|
21
27
|
const intersectingContours = findAllIntersectingContours(viewport, sourcePolyline, contourSegmentationAnnotations);
|
|
22
28
|
if (!intersectingContours.length) {
|
|
29
|
+
triggerEvent(eventTarget, Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, {
|
|
30
|
+
element: viewport.element,
|
|
31
|
+
sourceAnnotation,
|
|
32
|
+
});
|
|
23
33
|
return;
|
|
24
34
|
}
|
|
25
35
|
if (intersectingContours.length > 1) {
|
|
@@ -35,7 +35,7 @@ declare class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
35
35
|
protected renderAnnotationInstance(renderContext: AnnotationRenderContext): boolean;
|
|
36
36
|
_calculateStatsIfActive(annotation: PlanarFreehandROIAnnotation, targetId: string, viewport: any, renderingEngine: any, enabledElement: any): void;
|
|
37
37
|
private _calculateCachedStats;
|
|
38
|
-
protected updateClosedCachedStats({ viewport, points, imageData, metadata, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, }: {
|
|
38
|
+
protected updateClosedCachedStats({ viewport, points, imageData, metadata, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, deltaInX, deltaInY, }: {
|
|
39
39
|
viewport: any;
|
|
40
40
|
points: any;
|
|
41
41
|
imageData: any;
|
|
@@ -45,14 +45,18 @@ declare class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
45
45
|
modalityUnit: any;
|
|
46
46
|
canvasCoordinates: any;
|
|
47
47
|
calibratedScale: any;
|
|
48
|
+
deltaInX: any;
|
|
49
|
+
deltaInY: any;
|
|
48
50
|
}): void;
|
|
49
|
-
protected updateOpenCachedStats({ targetId, metadata, canvasCoordinates, cachedStats, modalityUnit, calibratedScale, }: {
|
|
51
|
+
protected updateOpenCachedStats({ targetId, metadata, canvasCoordinates, cachedStats, modalityUnit, calibratedScale, deltaInX, deltaInY, }: {
|
|
50
52
|
targetId: any;
|
|
51
53
|
metadata: any;
|
|
52
54
|
canvasCoordinates: any;
|
|
53
55
|
cachedStats: any;
|
|
54
56
|
modalityUnit: any;
|
|
55
57
|
calibratedScale: any;
|
|
58
|
+
deltaInX: any;
|
|
59
|
+
deltaInY: any;
|
|
56
60
|
}): void;
|
|
57
61
|
private _renderStats;
|
|
58
62
|
}
|
|
@@ -168,6 +168,18 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
168
168
|
const bottomRightBBIndex = csUtils.transformWorldToIndex(imageData, bottomRightBBWorld);
|
|
169
169
|
return [topLeftBBIndex, bottomRightBBIndex];
|
|
170
170
|
});
|
|
171
|
+
const canvasPoint = canvasCoordinates[0];
|
|
172
|
+
const originalWorldPoint = viewport.canvasToWorld(canvasPoint);
|
|
173
|
+
const deltaXPoint = viewport.canvasToWorld([
|
|
174
|
+
canvasPoint[0] + 1,
|
|
175
|
+
canvasPoint[1],
|
|
176
|
+
]);
|
|
177
|
+
const deltaYPoint = viewport.canvasToWorld([
|
|
178
|
+
canvasPoint[0],
|
|
179
|
+
canvasPoint[1] + 1,
|
|
180
|
+
]);
|
|
181
|
+
const deltaInX = vec3.distance(originalWorldPoint, deltaXPoint);
|
|
182
|
+
const deltaInY = vec3.distance(originalWorldPoint, deltaYPoint);
|
|
171
183
|
if (closed) {
|
|
172
184
|
this.updateClosedCachedStats({
|
|
173
185
|
targetId,
|
|
@@ -179,6 +191,8 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
179
191
|
cachedStats,
|
|
180
192
|
modalityUnit,
|
|
181
193
|
calibratedScale,
|
|
194
|
+
deltaInX,
|
|
195
|
+
deltaInY,
|
|
182
196
|
});
|
|
183
197
|
}
|
|
184
198
|
else {
|
|
@@ -189,6 +203,8 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
189
203
|
cachedStats,
|
|
190
204
|
modalityUnit,
|
|
191
205
|
calibratedScale,
|
|
206
|
+
deltaInX,
|
|
207
|
+
deltaInY,
|
|
192
208
|
});
|
|
193
209
|
}
|
|
194
210
|
}
|
|
@@ -410,21 +426,9 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
410
426
|
}
|
|
411
427
|
}
|
|
412
428
|
}
|
|
413
|
-
updateClosedCachedStats({ viewport, points, imageData, metadata, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, }) {
|
|
429
|
+
updateClosedCachedStats({ viewport, points, imageData, metadata, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, deltaInX, deltaInY, }) {
|
|
414
430
|
const { scale, areaUnit, unit } = calibratedScale;
|
|
415
431
|
const { voxelManager } = viewport.getImageData();
|
|
416
|
-
const canvasPoint = canvasCoordinates[0];
|
|
417
|
-
const originalWorldPoint = viewport.canvasToWorld(canvasPoint);
|
|
418
|
-
const deltaXPoint = viewport.canvasToWorld([
|
|
419
|
-
canvasPoint[0] + 1,
|
|
420
|
-
canvasPoint[1],
|
|
421
|
-
]);
|
|
422
|
-
const deltaYPoint = viewport.canvasToWorld([
|
|
423
|
-
canvasPoint[0],
|
|
424
|
-
canvasPoint[1] + 1,
|
|
425
|
-
]);
|
|
426
|
-
const deltaInX = vec3.distance(originalWorldPoint, deltaXPoint);
|
|
427
|
-
const deltaInY = vec3.distance(originalWorldPoint, deltaYPoint);
|
|
428
432
|
const worldPosIndex = csUtils.transformWorldToIndex(imageData, points[0]);
|
|
429
433
|
worldPosIndex[0] = Math.floor(worldPosIndex[0]);
|
|
430
434
|
worldPosIndex[1] = Math.floor(worldPosIndex[1]);
|
|
@@ -453,6 +457,8 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
453
457
|
worldPosIndex2[2] = Math.floor(worldPosIndex2[2]);
|
|
454
458
|
let area = polyline.getArea(canvasCoordinates) / scale / scale;
|
|
455
459
|
area *= deltaInX * deltaInY;
|
|
460
|
+
let perimeter = calculatePerimeter(canvasCoordinates, closed) / scale;
|
|
461
|
+
perimeter *= Math.sqrt(Math.pow(deltaInX, 2) + Math.pow(deltaInY, 2));
|
|
456
462
|
const iDelta = 0.01 * (iMax - iMin);
|
|
457
463
|
const jDelta = 0.01 * (jMax - jMin);
|
|
458
464
|
const kDelta = 0.01 * (kMax - kMin);
|
|
@@ -510,7 +516,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
510
516
|
cachedStats[targetId] = {
|
|
511
517
|
Modality: metadata.Modality,
|
|
512
518
|
area,
|
|
513
|
-
perimeter
|
|
519
|
+
perimeter,
|
|
514
520
|
mean: stats.mean?.value,
|
|
515
521
|
max: stats.max?.value,
|
|
516
522
|
min: stats.min?.value,
|
|
@@ -522,11 +528,13 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
522
528
|
unit,
|
|
523
529
|
};
|
|
524
530
|
}
|
|
525
|
-
updateOpenCachedStats({ targetId, metadata, canvasCoordinates, cachedStats, modalityUnit, calibratedScale, }) {
|
|
531
|
+
updateOpenCachedStats({ targetId, metadata, canvasCoordinates, cachedStats, modalityUnit, calibratedScale, deltaInX, deltaInY, }) {
|
|
526
532
|
const { scale, unit } = calibratedScale;
|
|
533
|
+
let length = calculatePerimeter(canvasCoordinates, closed) / scale;
|
|
534
|
+
length *= Math.sqrt(Math.pow(deltaInX, 2) + Math.pow(deltaInY, 2));
|
|
527
535
|
cachedStats[targetId] = {
|
|
528
536
|
Modality: metadata.Modality,
|
|
529
|
-
length
|
|
537
|
+
length,
|
|
530
538
|
modalityUnit,
|
|
531
539
|
unit,
|
|
532
540
|
};
|
|
@@ -2,7 +2,11 @@ import type { PublicToolProps } from '../../types';
|
|
|
2
2
|
import SplineROITool from './SplineROITool';
|
|
3
3
|
declare class SplineContourSegmentationTool extends SplineROITool {
|
|
4
4
|
static toolName: string;
|
|
5
|
+
private annotationCutMergeCompletedBinded;
|
|
5
6
|
constructor(toolProps: PublicToolProps);
|
|
6
7
|
protected isContourSegmentationTool(): boolean;
|
|
8
|
+
protected initializeListeners(): void;
|
|
9
|
+
protected removeListeners(): void;
|
|
10
|
+
protected annotationCutMergeCompleted(evt: any): void;
|
|
7
11
|
}
|
|
8
12
|
export default SplineContourSegmentationTool;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { utilities } from '@cornerstonejs/core';
|
|
1
|
+
import { eventTarget, utilities } from '@cornerstonejs/core';
|
|
2
2
|
import SplineROITool from './SplineROITool';
|
|
3
|
+
import { Events } from '../../enums';
|
|
4
|
+
import { convertContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
|
|
3
5
|
class SplineContourSegmentationTool extends SplineROITool {
|
|
4
6
|
static { this.toolName = 'SplineContourSegmentationTool'; }
|
|
5
7
|
constructor(toolProps) {
|
|
@@ -9,9 +11,25 @@ class SplineContourSegmentationTool extends SplineROITool {
|
|
|
9
11
|
},
|
|
10
12
|
}, toolProps);
|
|
11
13
|
super(initialProps);
|
|
14
|
+
this.annotationCutMergeCompletedBinded =
|
|
15
|
+
this.annotationCutMergeCompleted.bind(this);
|
|
12
16
|
}
|
|
13
17
|
isContourSegmentationTool() {
|
|
14
18
|
return true;
|
|
15
19
|
}
|
|
20
|
+
initializeListeners() {
|
|
21
|
+
eventTarget.addEventListener(Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, this.annotationCutMergeCompletedBinded);
|
|
22
|
+
}
|
|
23
|
+
removeListeners() {
|
|
24
|
+
eventTarget.removeEventListener(Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, this.annotationCutMergeCompletedBinded);
|
|
25
|
+
}
|
|
26
|
+
annotationCutMergeCompleted(evt) {
|
|
27
|
+
const { sourceAnnotation: annotation } = evt.detail;
|
|
28
|
+
if (!this.splineToolNames.includes(annotation?.metadata?.toolName) ||
|
|
29
|
+
!this.configuration.simplifiedSpline) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
convertContourSegmentationAnnotation(annotation);
|
|
33
|
+
}
|
|
16
34
|
}
|
|
17
35
|
export default SplineContourSegmentationTool;
|
|
@@ -15,8 +15,10 @@ declare enum SplineToolActions {
|
|
|
15
15
|
}
|
|
16
16
|
declare class SplineROITool extends ContourSegmentationBaseTool {
|
|
17
17
|
static toolName: string;
|
|
18
|
+
protected splineToolNames: string[];
|
|
18
19
|
static SplineTypes: typeof SplineTypesEnum;
|
|
19
20
|
static Actions: typeof SplineToolActions;
|
|
21
|
+
private annotationCompletedBinded;
|
|
20
22
|
_throttledCalculateCachedStats: Function;
|
|
21
23
|
editData: {
|
|
22
24
|
annotation: SplineROIAnnotation;
|
|
@@ -36,6 +38,12 @@ declare class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
36
38
|
contourHoleProcessingEnabled: boolean;
|
|
37
39
|
};
|
|
38
40
|
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
41
|
+
protected annotationCompleted(evt: any): void;
|
|
42
|
+
protected initializeListeners(): void;
|
|
43
|
+
protected removeListeners(): void;
|
|
44
|
+
onSetToolEnabled(): void;
|
|
45
|
+
onSetToolActive(): void;
|
|
46
|
+
onSetToolDisabled(): void;
|
|
39
47
|
addNewAnnotation(evt: EventTypes.InteractionEventType): SplineROIAnnotation;
|
|
40
48
|
isPointNearTool: (element: HTMLDivElement, annotation: SplineROIAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
|
|
41
49
|
toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: SplineROIAnnotation) => void;
|
|
@@ -18,6 +18,7 @@ import { CatmullRomSpline } from './splines/CatmullRomSpline';
|
|
|
18
18
|
import { BSpline } from './splines/BSpline';
|
|
19
19
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
20
20
|
import { triggerAnnotationRenderForViewportIds } from '../../utilities';
|
|
21
|
+
import { convertContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
|
|
21
22
|
const SPLINE_MIN_POINTS = 3;
|
|
22
23
|
const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
|
|
23
24
|
const DEFAULT_SPLINE_CONFIG = {
|
|
@@ -49,6 +50,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
49
50
|
configuration: {
|
|
50
51
|
preventHandleOutsideImage: false,
|
|
51
52
|
calculateStats: true,
|
|
53
|
+
simplifiedSpline: false,
|
|
52
54
|
getTextLines: defaultGetTextLines,
|
|
53
55
|
contourHoleAdditionModifierKey: KeyboardBindings.Shift,
|
|
54
56
|
decimate: {
|
|
@@ -101,6 +103,12 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
101
103
|
},
|
|
102
104
|
}) {
|
|
103
105
|
super(toolProps, defaultToolProps);
|
|
106
|
+
this.splineToolNames = [
|
|
107
|
+
'CatmullRomSplineROI',
|
|
108
|
+
'LinearSplineROI',
|
|
109
|
+
'BSplineROI',
|
|
110
|
+
'CardinalSplineROI',
|
|
111
|
+
];
|
|
104
112
|
this.isHandleOutsideImage = false;
|
|
105
113
|
this.fireChangeOnUpdate = null;
|
|
106
114
|
this.isPointNearTool = (element, annotation, canvasCoords, proximity) => {
|
|
@@ -487,6 +495,31 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
487
495
|
return cachedStats;
|
|
488
496
|
};
|
|
489
497
|
this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
|
|
498
|
+
this.annotationCompletedBinded = this.annotationCompleted.bind(this);
|
|
499
|
+
}
|
|
500
|
+
annotationCompleted(evt) {
|
|
501
|
+
const { sourceAnnotation: annotation } = evt.detail;
|
|
502
|
+
if (!this.splineToolNames.includes(annotation?.metadata?.toolName) ||
|
|
503
|
+
!this.configuration.simplifiedSpline ||
|
|
504
|
+
!this.isContourSegmentationTool()) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
convertContourSegmentationAnnotation(annotation);
|
|
508
|
+
}
|
|
509
|
+
initializeListeners() {
|
|
510
|
+
eventTarget.addEventListener(Events.ANNOTATION_COMPLETED, this.annotationCompletedBinded);
|
|
511
|
+
}
|
|
512
|
+
removeListeners() {
|
|
513
|
+
eventTarget.removeEventListener(Events.ANNOTATION_COMPLETED, this.annotationCompletedBinded);
|
|
514
|
+
}
|
|
515
|
+
onSetToolEnabled() {
|
|
516
|
+
this.initializeListeners();
|
|
517
|
+
}
|
|
518
|
+
onSetToolActive() {
|
|
519
|
+
this.initializeListeners();
|
|
520
|
+
}
|
|
521
|
+
onSetToolDisabled() {
|
|
522
|
+
this.removeListeners();
|
|
490
523
|
}
|
|
491
524
|
addNewAnnotation(evt) {
|
|
492
525
|
const eventDetail = evt.detail;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { utilities } from '@cornerstonejs/core';
|
|
2
|
+
import { addAnnotation, removeAnnotation } from '../../stateManagement';
|
|
3
|
+
import { removeContourSegmentationAnnotation } from './removeContourSegmentationAnnotation';
|
|
4
|
+
import { addContourSegmentationAnnotation } from './addContourSegmentationAnnotation';
|
|
5
|
+
const DEFAULT_CONTOUR_SEG_TOOL_NAME = 'PlanarFreehandContourSegmentationTool';
|
|
6
|
+
export default function convertContourSegmentationAnnotation(annotation) {
|
|
7
|
+
const { polyline } = annotation.data?.contour || {};
|
|
8
|
+
if (!polyline || polyline.length < 3) {
|
|
9
|
+
console.warn('Skipping creation of new annotation due to invalid polyline:', polyline);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
removeAnnotation(annotation.annotationUID);
|
|
13
|
+
removeContourSegmentationAnnotation(annotation);
|
|
14
|
+
const startPointWorld = polyline[0];
|
|
15
|
+
const endPointWorld = polyline[polyline.length - 1];
|
|
16
|
+
const newAnnotation = {
|
|
17
|
+
metadata: {
|
|
18
|
+
...annotation.metadata,
|
|
19
|
+
toolName: DEFAULT_CONTOUR_SEG_TOOL_NAME,
|
|
20
|
+
originalToolName: annotation.metadata.originalToolName || annotation.metadata.toolName,
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
cachedStats: {},
|
|
24
|
+
handles: {
|
|
25
|
+
points: [startPointWorld, endPointWorld],
|
|
26
|
+
textBox: annotation.data.handles.textBox
|
|
27
|
+
? { ...annotation.data.handles.textBox }
|
|
28
|
+
: undefined,
|
|
29
|
+
},
|
|
30
|
+
contour: {
|
|
31
|
+
...annotation.data.contour,
|
|
32
|
+
},
|
|
33
|
+
spline: annotation.data.spline,
|
|
34
|
+
segmentation: {
|
|
35
|
+
...annotation.data.segmentation,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
annotationUID: utilities.uuidv4(),
|
|
39
|
+
highlighted: true,
|
|
40
|
+
invalidated: true,
|
|
41
|
+
isLocked: false,
|
|
42
|
+
isVisible: undefined,
|
|
43
|
+
interpolationUID: annotation.interpolationUID,
|
|
44
|
+
interpolationCompleted: annotation.interpolationCompleted,
|
|
45
|
+
};
|
|
46
|
+
addAnnotation(newAnnotation, annotation.metadata.FrameOfReferenceUID);
|
|
47
|
+
addContourSegmentationAnnotation(newAnnotation);
|
|
48
|
+
return newAnnotation;
|
|
49
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import areSameSegment from './areSameSegment';
|
|
2
|
+
import convertContourSegmentationAnnotation from './convertContourSegmentation';
|
|
2
3
|
import { addition, subtraction } from './logicalOperators';
|
|
3
4
|
export { default as isContourSegmentationAnnotation } from './isContourSegmentationAnnotation';
|
|
4
5
|
export { addContourSegmentationAnnotation } from './addContourSegmentationAnnotation';
|
|
@@ -7,5 +8,5 @@ export { findAllIntersectingContours } from './getIntersectingAnnotations';
|
|
|
7
8
|
export { processMultipleIntersections } from './mergeMultipleAnnotations';
|
|
8
9
|
export { contourSegmentationOperation } from './contourSegmentationOperation';
|
|
9
10
|
export * from './sharedOperations';
|
|
10
|
-
export { addition, subtraction, areSameSegment };
|
|
11
|
+
export { addition, subtraction, areSameSegment, convertContourSegmentationAnnotation, };
|
|
11
12
|
export { unifyPolylineSets, unifyMultiplePolylineSets, unifyAnnotationPolylines, subtractPolylineSets, subtractMultiplePolylineSets, subtractAnnotationPolylines, } from './unifyPolylineSets';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import areSameSegment from './areSameSegment';
|
|
2
|
+
import convertContourSegmentationAnnotation from './convertContourSegmentation';
|
|
2
3
|
import { addition, subtraction } from './logicalOperators';
|
|
3
4
|
export { default as isContourSegmentationAnnotation } from './isContourSegmentationAnnotation';
|
|
4
5
|
export { addContourSegmentationAnnotation } from './addContourSegmentationAnnotation';
|
|
@@ -7,5 +8,5 @@ export { findAllIntersectingContours } from './getIntersectingAnnotations';
|
|
|
7
8
|
export { processMultipleIntersections } from './mergeMultipleAnnotations';
|
|
8
9
|
export { contourSegmentationOperation } from './contourSegmentationOperation';
|
|
9
10
|
export * from './sharedOperations';
|
|
10
|
-
export { addition, subtraction, areSameSegment };
|
|
11
|
+
export { addition, subtraction, areSameSegment, convertContourSegmentationAnnotation, };
|
|
11
12
|
export { unifyPolylineSets, unifyMultiplePolylineSets, unifyAnnotationPolylines, subtractPolylineSets, subtractMultiplePolylineSets, subtractAnnotationPolylines, } from './unifyPolylineSets';
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.
|
|
1
|
+
export declare const version = "3.20.0";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '3.
|
|
1
|
+
export const version = '3.20.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"canvas": "^3.1.0"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
|
-
"@cornerstonejs/core": "^3.
|
|
111
|
+
"@cornerstonejs/core": "^3.20.0",
|
|
112
112
|
"@kitware/vtk.js": "32.12.1",
|
|
113
113
|
"@types/d3-array": "^3.0.4",
|
|
114
114
|
"@types/d3-interpolate": "^3.0.1",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"type": "individual",
|
|
128
128
|
"url": "https://ohif.org/donate"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "85e1da960eb87095a984c3a4a26a979a4ae5ffd4"
|
|
131
131
|
}
|