@cornerstonejs/tools 1.65.1 → 1.65.3
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/enums/StrategyCallbacks.d.ts +2 -1
- package/dist/cjs/enums/StrategyCallbacks.js +1 -0
- package/dist/cjs/enums/StrategyCallbacks.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/segmentation/BrushTool.js +16 -4
- package/dist/cjs/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/BrushStrategy.d.ts +3 -0
- package/dist/cjs/tools/segmentation/strategies/BrushStrategy.js +1 -0
- package/dist/cjs/tools/segmentation/strategies/BrushStrategy.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/compositions/dynamicThreshold.d.ts +1 -0
- package/dist/cjs/tools/segmentation/strategies/compositions/dynamicThreshold.js +20 -0
- package/dist/cjs/tools/segmentation/strategies/compositions/dynamicThreshold.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/compositions/index.d.ts +1 -0
- package/dist/esm/enums/StrategyCallbacks.js +1 -0
- package/dist/esm/enums/StrategyCallbacks.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/segmentation/BrushTool.js +16 -4
- package/dist/esm/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +1 -0
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +20 -0
- package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js.map +1 -1
- package/dist/types/enums/StrategyCallbacks.d.ts +2 -1
- package/dist/types/enums/StrategyCallbacks.d.ts.map +1 -1
- package/dist/types/tools/segmentation/BrushTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/BrushStrategy.d.ts +3 -0
- package/dist/types/tools/segmentation/strategies/BrushStrategy.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/compositions/dynamicThreshold.d.ts +1 -0
- package/dist/types/tools/segmentation/strategies/compositions/dynamicThreshold.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/compositions/index.d.ts +1 -0
- package/dist/types/tools/segmentation/strategies/compositions/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/enums/StrategyCallbacks.ts +3 -0
- package/src/tools/annotation/PlanarFreehandROITool.ts +1 -1
- package/src/tools/segmentation/BrushTool.ts +21 -5
- package/src/tools/segmentation/strategies/BrushStrategy.ts +4 -0
- package/src/tools/segmentation/strategies/compositions/dynamicThreshold.ts +43 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.65.
|
|
3
|
+
"version": "1.65.3",
|
|
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.65.
|
|
32
|
+
"@cornerstonejs/core": "^1.65.3",
|
|
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": "7059912b7d083525acdc48af7d0d38eec27efa64"
|
|
63
63
|
}
|
|
@@ -108,6 +108,7 @@ class BrushTool extends BaseTool {
|
|
|
108
108
|
strategySpecificConfiguration: {
|
|
109
109
|
THRESHOLD: {
|
|
110
110
|
threshold: [-150, -70], // E.g. CT Fat // Only used during threshold strategies.
|
|
111
|
+
dynamicRadius: 0, // in voxel counts in each direction, only used during dynamic threshold strategies.
|
|
111
112
|
},
|
|
112
113
|
},
|
|
113
114
|
defaultStrategy: 'FILL_INSIDE_CIRCLE',
|
|
@@ -126,8 +127,6 @@ class BrushTool extends BaseTool {
|
|
|
126
127
|
// The time to consider a mouse click a drag when moved less than dragMoveDistance
|
|
127
128
|
dragTimeMs: 500,
|
|
128
129
|
},
|
|
129
|
-
// Whether to show a center circle/position. Set to null to not show
|
|
130
|
-
centerRadius: 2,
|
|
131
130
|
actions: {
|
|
132
131
|
[StrategyCallbacks.AcceptPreview]: {
|
|
133
132
|
method: StrategyCallbacks.AcceptPreview,
|
|
@@ -584,6 +583,18 @@ class BrushTool extends BaseTool {
|
|
|
584
583
|
rightCursorInWorld,
|
|
585
584
|
];
|
|
586
585
|
|
|
586
|
+
const activeStrategy = this.configuration.activeStrategy;
|
|
587
|
+
const strategy = this.configuration.strategies[activeStrategy];
|
|
588
|
+
|
|
589
|
+
// Note: i don't think this is the best way to implement this
|
|
590
|
+
// but don't think we have a better way to do it for now
|
|
591
|
+
if (typeof strategy.computeInnerCircleRadius === 'function') {
|
|
592
|
+
strategy.computeInnerCircleRadius({
|
|
593
|
+
configuration: this.configuration,
|
|
594
|
+
viewport,
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
|
|
587
598
|
data.invalidated = false;
|
|
588
599
|
}
|
|
589
600
|
|
|
@@ -776,15 +787,20 @@ class BrushTool extends BaseTool {
|
|
|
776
787
|
}
|
|
777
788
|
);
|
|
778
789
|
|
|
779
|
-
const
|
|
780
|
-
|
|
790
|
+
const activeStrategy = this.configuration.activeStrategy;
|
|
791
|
+
const { dynamicRadiusInCanvas } = this.configuration
|
|
792
|
+
.strategySpecificConfiguration[activeStrategy] || {
|
|
793
|
+
dynamicRadiusInCanvas: 0,
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
if (dynamicRadiusInCanvas) {
|
|
781
797
|
const circleUID1 = '1';
|
|
782
798
|
drawCircleSvg(
|
|
783
799
|
svgDrawingHelper,
|
|
784
800
|
annotationUID,
|
|
785
801
|
circleUID1,
|
|
786
802
|
center as Types.Point2,
|
|
787
|
-
|
|
803
|
+
dynamicRadiusInCanvas,
|
|
788
804
|
{
|
|
789
805
|
color,
|
|
790
806
|
}
|
|
@@ -34,6 +34,7 @@ export type InitializedOperationData = LabelmapToolOperationDataAny & {
|
|
|
34
34
|
previewSegmentIndex?: number;
|
|
35
35
|
|
|
36
36
|
brushStrategy: BrushStrategy;
|
|
37
|
+
configuration?: Record<string, any>;
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
export type StrategyFunction = (
|
|
@@ -110,6 +111,9 @@ export default class BrushStrategy {
|
|
|
110
111
|
StrategyCallbacks.Preview,
|
|
111
112
|
false
|
|
112
113
|
),
|
|
114
|
+
[StrategyCallbacks.ComputeInnerCircleRadius]: addListMethod(
|
|
115
|
+
StrategyCallbacks.ComputeInnerCircleRadius
|
|
116
|
+
),
|
|
113
117
|
// Add other exposed fields below
|
|
114
118
|
// initializers is exposed on the function to allow extension of the composition object
|
|
115
119
|
compositions: null,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
3
|
import type { InitializedOperationData } from '../BrushStrategy';
|
|
3
4
|
import type BoundsIJK from '../../../../types/BoundsIJK';
|
|
4
5
|
import StrategyCallbacks from '../../../../enums/StrategyCallbacks';
|
|
@@ -65,4 +66,46 @@ export default {
|
|
|
65
66
|
}
|
|
66
67
|
strategySpecificConfiguration.THRESHOLD.threshold = null;
|
|
67
68
|
},
|
|
69
|
+
/**
|
|
70
|
+
* It computes the inner circle radius in canvas coordinates and stores it
|
|
71
|
+
* in the strategySpecificConfiguration. This is used to show the user
|
|
72
|
+
* the area that is used to compute the threshold.
|
|
73
|
+
*/
|
|
74
|
+
[StrategyCallbacks.ComputeInnerCircleRadius]: (
|
|
75
|
+
operationData: InitializedOperationData
|
|
76
|
+
) => {
|
|
77
|
+
const { configuration, viewport } = operationData;
|
|
78
|
+
const { THRESHOLD: { dynamicRadius = 0 } = {} } =
|
|
79
|
+
configuration.strategySpecificConfiguration || {};
|
|
80
|
+
const { spacing } = (
|
|
81
|
+
viewport as Types.IStackViewport | Types.IVolumeViewport
|
|
82
|
+
).getImageData();
|
|
83
|
+
const centerCanvas = [
|
|
84
|
+
viewport.element.clientWidth / 2,
|
|
85
|
+
viewport.element.clientHeight / 2,
|
|
86
|
+
] as Types.Point2;
|
|
87
|
+
const radiusInWorld = dynamicRadius * spacing[0];
|
|
88
|
+
const centerCursorInWorld = viewport.canvasToWorld(centerCanvas);
|
|
89
|
+
|
|
90
|
+
const offSetCenterInWorld = centerCursorInWorld.map(
|
|
91
|
+
(coord) => coord + radiusInWorld
|
|
92
|
+
) as Types.Point3;
|
|
93
|
+
|
|
94
|
+
const offSetCenterCanvas = viewport.worldToCanvas(offSetCenterInWorld);
|
|
95
|
+
const dynamicRadiusInCanvas = Math.abs(
|
|
96
|
+
centerCanvas[0] - offSetCenterCanvas[0]
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// this is a bit of a hack, since we have switched to using THRESHOLD
|
|
100
|
+
// as strategy but really strategy names are CIRCLE_THRESHOLD and SPHERE_THRESHOLD
|
|
101
|
+
// and we can't really change the name of the strategy in the configuration
|
|
102
|
+
const { strategySpecificConfiguration, activeStrategy } = configuration;
|
|
103
|
+
|
|
104
|
+
if (!strategySpecificConfiguration[activeStrategy]) {
|
|
105
|
+
strategySpecificConfiguration[activeStrategy] = {};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
strategySpecificConfiguration[activeStrategy].dynamicRadiusInCanvas =
|
|
109
|
+
dynamicRadiusInCanvas;
|
|
110
|
+
},
|
|
68
111
|
};
|