@cornerstonejs/tools 1.67.1 → 1.68.1
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/cjs/tools/annotation/PlanarFreehandROITool.js +11 -4
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +0 -1
- package/dist/cjs/utilities/contours/calculatePerimeter.d.ts +2 -0
- package/dist/cjs/utilities/contours/calculatePerimeter.js +19 -0
- package/dist/cjs/utilities/contours/calculatePerimeter.js.map +1 -0
- package/dist/cjs/utilities/contours/index.d.ts +2 -1
- package/dist/cjs/utilities/contours/index.js +3 -1
- package/dist/cjs/utilities/contours/index.js.map +1 -1
- package/dist/cjs/utilities/segmentation/triggerSegmentationRender.js +2 -5
- package/dist/cjs/utilities/segmentation/triggerSegmentationRender.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +11 -4
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/utilities/contours/calculatePerimeter.js +17 -0
- package/dist/esm/utilities/contours/calculatePerimeter.js.map +1 -0
- package/dist/esm/utilities/contours/index.js +2 -1
- package/dist/esm/utilities/contours/index.js.map +1 -1
- package/dist/esm/utilities/segmentation/triggerSegmentationRender.js +1 -1
- package/dist/esm/utilities/segmentation/triggerSegmentationRender.js.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +0 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/utilities/contours/calculatePerimeter.d.ts +3 -0
- package/dist/types/utilities/contours/calculatePerimeter.d.ts.map +1 -0
- package/dist/types/utilities/contours/index.d.ts +2 -1
- package/dist/types/utilities/contours/index.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/tools/annotation/PlanarFreehandROITool.ts +37 -13
- package/src/types/ToolSpecificAnnotationTypes.ts +0 -1
- package/src/utilities/contours/calculatePerimeter.ts +31 -0
- package/src/utilities/contours/index.ts +2 -0
- package/src/utilities/segmentation/triggerSegmentationRender.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.68.1",
|
|
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.
|
|
32
|
+
"@cornerstonejs/core": "^1.68.1",
|
|
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": "
|
|
62
|
+
"gitHead": "bc07d0e3bfd08cffba904f3deb5ce18b3079255d"
|
|
63
63
|
}
|
|
@@ -45,6 +45,7 @@ import pointInShapeCallback from '../../utilities/pointInShapeCallback';
|
|
|
45
45
|
import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
|
|
46
46
|
import { getModalityUnit } from '../../utilities/getModalityUnit';
|
|
47
47
|
import { BasicStatsCalculator } from '../../utilities/math/basic';
|
|
48
|
+
import calculatePerimeter from '../../utilities/contours/calculatePerimeter';
|
|
48
49
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
49
50
|
import { KeyboardBindings, ChangeTypes } from '../../enums';
|
|
50
51
|
|
|
@@ -52,6 +53,7 @@ const { pointCanProjectOnLine } = polyline;
|
|
|
52
53
|
const { EPSILON } = CONSTANTS;
|
|
53
54
|
|
|
54
55
|
const PARALLEL_THRESHOLD = 1 - EPSILON;
|
|
56
|
+
|
|
55
57
|
/**
|
|
56
58
|
* PlanarFreehandROITool lets you draw annotations that define an arbitrarily drawn region.
|
|
57
59
|
* You can use the PlanarFreehandROITool in all perpendicular views (axial, sagittal, coronal),
|
|
@@ -243,7 +245,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
243
245
|
*/
|
|
244
246
|
epsilon: 0.1,
|
|
245
247
|
},
|
|
246
|
-
calculateStats:
|
|
248
|
+
calculateStats: true,
|
|
247
249
|
getTextLines: defaultGetTextLines,
|
|
248
250
|
statsCalculator: BasicStatsCalculator,
|
|
249
251
|
},
|
|
@@ -294,7 +296,9 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
294
296
|
);
|
|
295
297
|
|
|
296
298
|
this.activateDraw(evt, annotation, viewportIdsToRender);
|
|
299
|
+
|
|
297
300
|
evt.preventDefault();
|
|
301
|
+
|
|
298
302
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
299
303
|
|
|
300
304
|
return annotation;
|
|
@@ -350,6 +354,8 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
350
354
|
} else {
|
|
351
355
|
this.activateOpenContourEdit(evt, annotation, viewportIdsToRender);
|
|
352
356
|
}
|
|
357
|
+
|
|
358
|
+
evt.preventDefault();
|
|
353
359
|
};
|
|
354
360
|
|
|
355
361
|
/**
|
|
@@ -536,16 +542,21 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
536
542
|
annotation.data.handles.points.length = 0;
|
|
537
543
|
};
|
|
538
544
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
545
|
+
const annotation = <PlanarFreehandROIAnnotation>csUtils.deepMerge(
|
|
546
|
+
contourAnnotation,
|
|
547
|
+
{
|
|
548
|
+
data: {
|
|
549
|
+
contour: {
|
|
550
|
+
polyline: [<Types.Point3>[...worldPos]],
|
|
551
|
+
},
|
|
552
|
+
label: '',
|
|
553
|
+
cachedStats: {},
|
|
543
554
|
},
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
555
|
+
onInterpolationComplete,
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
return annotation;
|
|
549
560
|
}
|
|
550
561
|
|
|
551
562
|
protected getAnnotationStyle(context) {
|
|
@@ -682,7 +693,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
682
693
|
) => {
|
|
683
694
|
const { data } = annotation;
|
|
684
695
|
const { cachedStats } = data;
|
|
685
|
-
const { polyline: points } = data.contour;
|
|
696
|
+
const { polyline: points, closed } = data.contour;
|
|
686
697
|
|
|
687
698
|
const targetIds = Object.keys(cachedStats);
|
|
688
699
|
|
|
@@ -835,6 +846,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
835
846
|
cachedStats[targetId] = {
|
|
836
847
|
Modality: metadata.Modality,
|
|
837
848
|
area,
|
|
849
|
+
perimeter: calculatePerimeter(canvasCoordinates, closed),
|
|
838
850
|
mean: stats.mean?.value,
|
|
839
851
|
max: stats.max?.value,
|
|
840
852
|
stdDev: stats.stdDev?.value,
|
|
@@ -920,8 +932,16 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
920
932
|
|
|
921
933
|
function defaultGetTextLines(data, targetId): string[] {
|
|
922
934
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
923
|
-
const {
|
|
924
|
-
|
|
935
|
+
const {
|
|
936
|
+
area,
|
|
937
|
+
mean,
|
|
938
|
+
stdDev,
|
|
939
|
+
perimeter,
|
|
940
|
+
max,
|
|
941
|
+
isEmptyArea,
|
|
942
|
+
areaUnit,
|
|
943
|
+
modalityUnit,
|
|
944
|
+
} = cachedVolumeStats || {};
|
|
925
945
|
|
|
926
946
|
const textLines: string[] = [];
|
|
927
947
|
|
|
@@ -944,6 +964,10 @@ function defaultGetTextLines(data, targetId): string[] {
|
|
|
944
964
|
textLines.push(`Std Dev: ${roundNumber(stdDev)} ${modalityUnit}`);
|
|
945
965
|
}
|
|
946
966
|
|
|
967
|
+
if (perimeter) {
|
|
968
|
+
textLines.push(`Perimeter: ${roundNumber(perimeter)} ${modalityUnit}`);
|
|
969
|
+
}
|
|
970
|
+
|
|
947
971
|
return textLines;
|
|
948
972
|
}
|
|
949
973
|
|
|
@@ -285,7 +285,6 @@ export interface CircleROIStartEndThresholdAnnotation extends Annotation {
|
|
|
285
285
|
export type PlanarFreehandROIAnnotation = ContourAnnotation & {
|
|
286
286
|
data: {
|
|
287
287
|
label?: string;
|
|
288
|
-
isOpenContour?: boolean;
|
|
289
288
|
isOpenUShapeContour?: boolean;
|
|
290
289
|
// Present if isOpenUShapeContour is true:
|
|
291
290
|
openUShapeContourVectorToPeak?: Types.Point3[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the perimeter of a polyline.
|
|
3
|
+
*
|
|
4
|
+
* @param polyline - The polyline represented as an array of points.
|
|
5
|
+
* @param closed - Indicates whether the polyline is closed or not.
|
|
6
|
+
* @returns The perimeter of the polyline.
|
|
7
|
+
*/
|
|
8
|
+
function calculatePerimeter(polyline: number[][], closed: boolean): number {
|
|
9
|
+
let perimeter = 0;
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < polyline.length - 1; i++) {
|
|
12
|
+
const point1 = polyline[i];
|
|
13
|
+
const point2 = polyline[i + 1];
|
|
14
|
+
perimeter += Math.sqrt(
|
|
15
|
+
Math.pow(point2[0] - point1[0], 2) + Math.pow(point2[1] - point1[1], 2)
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (closed) {
|
|
20
|
+
const firstPoint = polyline[0];
|
|
21
|
+
const lastPoint = polyline[polyline.length - 1];
|
|
22
|
+
perimeter += Math.sqrt(
|
|
23
|
+
Math.pow(lastPoint[0] - firstPoint[0], 2) +
|
|
24
|
+
Math.pow(lastPoint[1] - firstPoint[1], 2)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return perimeter;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default calculatePerimeter;
|
|
@@ -10,6 +10,7 @@ import updateContourPolyline from './updateContourPolyline';
|
|
|
10
10
|
import acceptAutogeneratedInterpolations from './interpolation/acceptAutogeneratedInterpolations';
|
|
11
11
|
import * as interpolation from './interpolation';
|
|
12
12
|
import findHandlePolylineIndex from './findHandlePolylineIndex';
|
|
13
|
+
import calculatePerimeter from './calculatePerimeter';
|
|
13
14
|
|
|
14
15
|
export {
|
|
15
16
|
areCoplanarContours,
|
|
@@ -24,4 +25,5 @@ export {
|
|
|
24
25
|
interpolation,
|
|
25
26
|
acceptAutogeneratedInterpolations,
|
|
26
27
|
findHandlePolylineIndex,
|
|
28
|
+
calculatePerimeter,
|
|
27
29
|
};
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getToolGroupForViewport,
|
|
12
12
|
} from '../../store/ToolGroupManager';
|
|
13
13
|
|
|
14
|
-
import SegmentationDisplayTool from '../../tools
|
|
14
|
+
import { SegmentationDisplayTool } from '../../tools';
|
|
15
15
|
import { SegmentationRenderedEventDetail } from '../../types/EventTypes';
|
|
16
16
|
|
|
17
17
|
/**
|