@cornerstonejs/tools 1.70.5 → 1.70.7
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/Events.d.ts +2 -0
- package/dist/cjs/enums/Events.js +2 -0
- package/dist/cjs/enums/Events.js.map +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js +12 -0
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/cjs/tools/AdvancedMagnifyTool.d.ts +1 -1
- package/dist/cjs/tools/AdvancedMagnifyTool.js +35 -43
- package/dist/cjs/tools/AdvancedMagnifyTool.js.map +1 -1
- package/dist/cjs/tools/AdvancedMagnifyViewport.d.ts +1 -1
- package/dist/cjs/tools/AdvancedMagnifyViewport.js +8 -2
- package/dist/cjs/tools/AdvancedMagnifyViewport.js.map +1 -1
- package/dist/cjs/tools/AdvancedMagnifyViewportManager.d.ts +2 -1
- package/dist/cjs/tools/AdvancedMagnifyViewportManager.js +32 -3
- package/dist/cjs/tools/AdvancedMagnifyViewportManager.js.map +1 -1
- package/dist/cjs/tools/OrientationMarkerTool.d.ts +0 -2
- package/dist/cjs/tools/OrientationMarkerTool.js +47 -28
- package/dist/cjs/tools/OrientationMarkerTool.js.map +1 -1
- package/dist/cjs/tools/annotation/BidirectionalTool.js +15 -8
- package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/cjs/tools/annotation/CircleROITool.js +19 -18
- package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.d.ts +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.js +21 -20
- package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +27 -4
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/RectangleROITool.js +18 -18
- package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/SplineROITool.js +16 -2
- package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/cjs/tools/base/AnnotationTool.js +4 -1
- package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +5 -0
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/cjs/tools/segmentation/BrushTool.js +12 -1
- package/dist/cjs/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/compositions/dynamicThreshold.js +3 -0
- package/dist/cjs/tools/segmentation/strategies/compositions/dynamicThreshold.js.map +1 -1
- package/dist/cjs/tools/segmentation/strategies/compositions/preview.js +10 -2
- package/dist/cjs/tools/segmentation/strategies/compositions/preview.js.map +1 -1
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +2 -1
- package/dist/cjs/utilities/cine/playClip.d.ts +1 -1
- package/dist/cjs/utilities/cine/playClip.js +2 -5
- package/dist/cjs/utilities/cine/playClip.js.map +1 -1
- package/dist/cjs/utilities/getCalibratedUnits.d.ts +1 -5
- package/dist/cjs/utilities/getCalibratedUnits.js +13 -45
- package/dist/cjs/utilities/getCalibratedUnits.js.map +1 -1
- package/dist/cjs/utilities/index.d.ts +2 -2
- package/dist/cjs/utilities/index.js +4 -4
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js +3 -0
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/esm/enums/Events.js +2 -0
- package/dist/esm/enums/Events.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +12 -0
- package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/esm/tools/AdvancedMagnifyTool.js +35 -43
- package/dist/esm/tools/AdvancedMagnifyTool.js.map +1 -1
- package/dist/esm/tools/AdvancedMagnifyViewport.js +8 -2
- package/dist/esm/tools/AdvancedMagnifyViewport.js.map +1 -1
- package/dist/esm/tools/AdvancedMagnifyViewportManager.js +38 -4
- package/dist/esm/tools/AdvancedMagnifyViewportManager.js.map +1 -1
- package/dist/esm/tools/OrientationMarkerTool.js +48 -29
- package/dist/esm/tools/OrientationMarkerTool.js.map +1 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +16 -9
- package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/esm/tools/annotation/CircleROITool.js +21 -20
- package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +23 -22
- package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +29 -6
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/annotation/RectangleROITool.js +19 -19
- package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/SplineROITool.js +17 -3
- package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/esm/tools/base/AnnotationTool.js +4 -1
- package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +5 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/esm/tools/segmentation/BrushTool.js +13 -2
- package/dist/esm/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +3 -0
- package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js.map +1 -1
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +10 -2
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js.map +1 -1
- package/dist/esm/utilities/cine/playClip.js +2 -2
- package/dist/esm/utilities/cine/playClip.js.map +1 -1
- package/dist/esm/utilities/getCalibratedUnits.js +13 -41
- package/dist/esm/utilities/getCalibratedUnits.js.map +1 -1
- package/dist/esm/utilities/index.js +2 -2
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js +3 -0
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/types/enums/Events.d.ts +2 -0
- package/dist/types/enums/Events.d.ts.map +1 -1
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts.map +1 -1
- package/dist/types/tools/AdvancedMagnifyTool.d.ts +1 -1
- package/dist/types/tools/AdvancedMagnifyTool.d.ts.map +1 -1
- package/dist/types/tools/AdvancedMagnifyViewport.d.ts +1 -1
- package/dist/types/tools/AdvancedMagnifyViewport.d.ts.map +1 -1
- package/dist/types/tools/AdvancedMagnifyViewportManager.d.ts +2 -1
- package/dist/types/tools/AdvancedMagnifyViewportManager.d.ts.map +1 -1
- package/dist/types/tools/OrientationMarkerTool.d.ts +0 -2
- package/dist/types/tools/OrientationMarkerTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/EllipticalROITool.d.ts +1 -1
- package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/RectangleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
- package/dist/types/tools/base/AnnotationTool.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Labelmap/labelmapDisplay.d.ts.map +1 -1
- package/dist/types/tools/segmentation/BrushTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/compositions/dynamicThreshold.d.ts.map +1 -1
- package/dist/types/tools/segmentation/strategies/compositions/preview.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +2 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/utilities/cine/playClip.d.ts +1 -1
- package/dist/types/utilities/cine/playClip.d.ts.map +1 -1
- package/dist/types/utilities/getCalibratedUnits.d.ts +1 -5
- package/dist/types/utilities/getCalibratedUnits.d.ts.map +1 -1
- package/dist/types/utilities/index.d.ts +2 -2
- package/dist/types/utilities/index.d.ts.map +1 -1
- package/dist/types/utilities/planar/filterAnnotationsForDisplay.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -4
- package/src/enums/Events.ts +6 -0
- package/src/store/ToolGroupManager/ToolGroup.ts +16 -0
- package/src/tools/AdvancedMagnifyTool.ts +42 -66
- package/src/tools/AdvancedMagnifyViewport.ts +11 -3
- package/src/tools/AdvancedMagnifyViewportManager.ts +74 -3
- package/src/tools/OrientationMarkerTool.ts +74 -50
- package/src/tools/annotation/BidirectionalTool.ts +28 -15
- package/src/tools/annotation/CircleROITool.ts +24 -25
- package/src/tools/annotation/EllipticalROITool.ts +28 -39
- package/src/tools/annotation/PlanarFreehandROITool.ts +56 -11
- package/src/tools/annotation/RectangleROITool.ts +23 -23
- package/src/tools/annotation/SplineROITool.ts +36 -4
- package/src/tools/base/AnnotationTool.ts +8 -2
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +7 -0
- package/src/tools/segmentation/BrushTool.ts +17 -1
- package/src/tools/segmentation/strategies/compositions/dynamicThreshold.ts +6 -0
- package/src/tools/segmentation/strategies/compositions/preview.ts +14 -4
- package/src/types/ToolSpecificAnnotationTypes.ts +2 -1
- package/src/utilities/cine/playClip.ts +2 -2
- package/src/utilities/getCalibratedUnits.ts +18 -74
- package/src/utilities/index.ts +6 -6
- package/src/utilities/planar/filterAnnotationsForDisplay.ts +3 -0
|
@@ -7,10 +7,7 @@ import {
|
|
|
7
7
|
} from '@cornerstonejs/core';
|
|
8
8
|
import type { Types } from '@cornerstonejs/core';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
getCalibratedAreaUnits,
|
|
12
|
-
getCalibratedScale,
|
|
13
|
-
} from '../../utilities/getCalibratedUnits';
|
|
10
|
+
import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
|
|
14
11
|
import { roundNumber } from '../../utilities';
|
|
15
12
|
import throttle from '../../utilities/throttle';
|
|
16
13
|
import {
|
|
@@ -878,37 +875,35 @@ class RectangleROITool extends AnnotationTool {
|
|
|
878
875
|
}
|
|
879
876
|
|
|
880
877
|
const { dimensions, imageData, metadata } = image;
|
|
881
|
-
const scalarData =
|
|
882
|
-
'getScalarData' in image ? image.getScalarData() : image.scalarData;
|
|
883
878
|
|
|
884
|
-
const
|
|
879
|
+
const pos1Index = transformWorldToIndex(imageData, worldPos1);
|
|
885
880
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
881
|
+
pos1Index[0] = Math.floor(pos1Index[0]);
|
|
882
|
+
pos1Index[1] = Math.floor(pos1Index[1]);
|
|
883
|
+
pos1Index[2] = Math.floor(pos1Index[2]);
|
|
889
884
|
|
|
890
|
-
const
|
|
885
|
+
const pos2Index = transformWorldToIndex(imageData, worldPos2);
|
|
891
886
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
887
|
+
pos2Index[0] = Math.floor(pos2Index[0]);
|
|
888
|
+
pos2Index[1] = Math.floor(pos2Index[1]);
|
|
889
|
+
pos2Index[2] = Math.floor(pos2Index[2]);
|
|
895
890
|
|
|
896
891
|
// Check if one of the indexes are inside the volume, this then gives us
|
|
897
892
|
// Some area to do stats over.
|
|
898
893
|
|
|
899
|
-
if (this._isInsideVolume(
|
|
894
|
+
if (this._isInsideVolume(pos1Index, pos2Index, dimensions)) {
|
|
900
895
|
this.isHandleOutsideImage = false;
|
|
901
896
|
|
|
902
897
|
// Calculate index bounds to iterate over
|
|
903
898
|
|
|
904
|
-
const iMin = Math.min(
|
|
905
|
-
const iMax = Math.max(
|
|
899
|
+
const iMin = Math.min(pos1Index[0], pos2Index[0]);
|
|
900
|
+
const iMax = Math.max(pos1Index[0], pos2Index[0]);
|
|
906
901
|
|
|
907
|
-
const jMin = Math.min(
|
|
908
|
-
const jMax = Math.max(
|
|
902
|
+
const jMin = Math.min(pos1Index[1], pos2Index[1]);
|
|
903
|
+
const jMax = Math.max(pos1Index[1], pos2Index[1]);
|
|
909
904
|
|
|
910
|
-
const kMin = Math.min(
|
|
911
|
-
const kMax = Math.max(
|
|
905
|
+
const kMin = Math.min(pos1Index[2], pos2Index[2]);
|
|
906
|
+
const kMax = Math.max(pos1Index[2], pos2Index[2]);
|
|
912
907
|
|
|
913
908
|
const boundsIJK = [
|
|
914
909
|
[iMin, iMax],
|
|
@@ -922,7 +917,12 @@ class RectangleROITool extends AnnotationTool {
|
|
|
922
917
|
worldPos1,
|
|
923
918
|
worldPos2
|
|
924
919
|
);
|
|
925
|
-
|
|
920
|
+
|
|
921
|
+
const handles = [pos1Index, pos2Index];
|
|
922
|
+
const { scale, areaUnits } = getCalibratedLengthUnitsAndScale(
|
|
923
|
+
image,
|
|
924
|
+
handles
|
|
925
|
+
);
|
|
926
926
|
|
|
927
927
|
const area = Math.abs(worldWidth * worldHeight) / (scale * scale);
|
|
928
928
|
|
|
@@ -959,7 +959,7 @@ class RectangleROITool extends AnnotationTool {
|
|
|
959
959
|
max: stats.max?.value,
|
|
960
960
|
statsArray: stats.array,
|
|
961
961
|
pointsInShape: pointsInShape,
|
|
962
|
-
areaUnit:
|
|
962
|
+
areaUnit: areaUnits,
|
|
963
963
|
modalityUnit,
|
|
964
964
|
};
|
|
965
965
|
} else {
|
|
@@ -37,8 +37,7 @@ import {
|
|
|
37
37
|
throttle,
|
|
38
38
|
roundNumber,
|
|
39
39
|
triggerAnnotationRenderForViewportIds,
|
|
40
|
-
|
|
41
|
-
getCalibratedAreaUnits,
|
|
40
|
+
getCalibratedLengthUnitsAndScale,
|
|
42
41
|
} from '../../utilities';
|
|
43
42
|
import getMouseModifierKey from '../../eventDispatchers/shared/getMouseModifier';
|
|
44
43
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
@@ -1163,7 +1162,40 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
1163
1162
|
const deltaInX = vec3.distance(originalWorldPoint, deltaXPoint);
|
|
1164
1163
|
const deltaInY = vec3.distance(originalWorldPoint, deltaYPoint);
|
|
1165
1164
|
|
|
1166
|
-
const
|
|
1165
|
+
const { imageData } = image;
|
|
1166
|
+
const { scale, areaUnits } = getCalibratedLengthUnitsAndScale(
|
|
1167
|
+
image,
|
|
1168
|
+
() => {
|
|
1169
|
+
const {
|
|
1170
|
+
maxX: canvasMaxX,
|
|
1171
|
+
maxY: canvasMaxY,
|
|
1172
|
+
minX: canvasMinX,
|
|
1173
|
+
minY: canvasMinY,
|
|
1174
|
+
} = math.polyline.getAABB(canvasCoordinates);
|
|
1175
|
+
|
|
1176
|
+
const topLeftBBWorld = viewport.canvasToWorld([
|
|
1177
|
+
canvasMinX,
|
|
1178
|
+
canvasMinY,
|
|
1179
|
+
]);
|
|
1180
|
+
|
|
1181
|
+
const topLeftBBIndex = utilities.transformWorldToIndex(
|
|
1182
|
+
imageData,
|
|
1183
|
+
topLeftBBWorld
|
|
1184
|
+
);
|
|
1185
|
+
|
|
1186
|
+
const bottomRightBBWorld = viewport.canvasToWorld([
|
|
1187
|
+
canvasMaxX,
|
|
1188
|
+
canvasMaxY,
|
|
1189
|
+
]);
|
|
1190
|
+
|
|
1191
|
+
const bottomRightBBIndex = utilities.transformWorldToIndex(
|
|
1192
|
+
imageData,
|
|
1193
|
+
bottomRightBBWorld
|
|
1194
|
+
);
|
|
1195
|
+
|
|
1196
|
+
return [topLeftBBIndex, bottomRightBBIndex];
|
|
1197
|
+
}
|
|
1198
|
+
);
|
|
1167
1199
|
let area = math.polyline.getArea(canvasCoordinates) / scale / scale;
|
|
1168
1200
|
|
|
1169
1201
|
// Convert from canvas_pixels ^2 to mm^2
|
|
@@ -1172,7 +1204,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
1172
1204
|
cachedStats[targetId] = {
|
|
1173
1205
|
Modality: metadata.Modality,
|
|
1174
1206
|
area,
|
|
1175
|
-
areaUnit:
|
|
1207
|
+
areaUnit: areaUnits,
|
|
1176
1208
|
};
|
|
1177
1209
|
}
|
|
1178
1210
|
|
|
@@ -266,6 +266,7 @@ abstract class AnnotationTool extends AnnotationDisplayTool {
|
|
|
266
266
|
const { viewport } = enabledElement;
|
|
267
267
|
|
|
268
268
|
const { data } = annotation;
|
|
269
|
+
const { isCanvasAnnotation } = data;
|
|
269
270
|
const { points, textBox } = data.handles;
|
|
270
271
|
|
|
271
272
|
if (textBox) {
|
|
@@ -292,10 +293,15 @@ abstract class AnnotationTool extends AnnotationDisplayTool {
|
|
|
292
293
|
|
|
293
294
|
for (let i = 0; i < points?.length; i++) {
|
|
294
295
|
const point = points[i];
|
|
295
|
-
const annotationCanvasCoordinate =
|
|
296
|
+
const annotationCanvasCoordinate = isCanvasAnnotation
|
|
297
|
+
? point.slice(0, 2)
|
|
298
|
+
: viewport.worldToCanvas(point);
|
|
296
299
|
|
|
297
300
|
const near =
|
|
298
|
-
vec2.distance(
|
|
301
|
+
vec2.distance(
|
|
302
|
+
canvasCoords,
|
|
303
|
+
annotationCanvasCoordinate as Types.Point2
|
|
304
|
+
) < proximity;
|
|
299
305
|
|
|
300
306
|
if (near === true) {
|
|
301
307
|
data.handles.activeHandleIndex = i;
|
|
@@ -361,6 +361,13 @@ function _setLabelmapColorAndOpacity(
|
|
|
361
361
|
|
|
362
362
|
for (let i = 1; i < numColors; i++) {
|
|
363
363
|
// Start from 1 to skip the background segment index.
|
|
364
|
+
const isHidden = segmentsHidden.has(i);
|
|
365
|
+
|
|
366
|
+
if (isHidden) {
|
|
367
|
+
outlineWidths[i - 1] = 0;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
|
|
364
371
|
outlineWidths[i - 1] =
|
|
365
372
|
i === activeSegmentIndex
|
|
366
373
|
? outlineWidth + toolGroupLabelmapConfig.activeSegmentOutlineWidthDelta
|
|
@@ -2,6 +2,9 @@ import {
|
|
|
2
2
|
utilities as csUtils,
|
|
3
3
|
cache,
|
|
4
4
|
getEnabledElement,
|
|
5
|
+
StackViewport,
|
|
6
|
+
eventTarget,
|
|
7
|
+
Enums,
|
|
5
8
|
} from '@cornerstonejs/core';
|
|
6
9
|
import { vec3, vec2 } from 'gl-matrix';
|
|
7
10
|
|
|
@@ -112,7 +115,6 @@ class BrushTool extends BaseTool {
|
|
|
112
115
|
strategySpecificConfiguration: {
|
|
113
116
|
THRESHOLD: {
|
|
114
117
|
threshold: [-150, -70], // E.g. CT Fat // Only used during threshold strategies.
|
|
115
|
-
dynamicRadius: 0, // in voxel counts in each direction, only used during dynamic threshold strategies.
|
|
116
118
|
},
|
|
117
119
|
},
|
|
118
120
|
defaultStrategy: 'FILL_INSIDE_CIRCLE',
|
|
@@ -208,6 +210,20 @@ class BrushTool extends BaseTool {
|
|
|
208
210
|
] as LabelmapSegmentationDataVolume;
|
|
209
211
|
const actors = viewport.getActors();
|
|
210
212
|
|
|
213
|
+
const isStackViewport = viewport instanceof StackViewport;
|
|
214
|
+
|
|
215
|
+
if (isStackViewport) {
|
|
216
|
+
const event = new CustomEvent(Enums.Events.ERROR_EVENT, {
|
|
217
|
+
detail: {
|
|
218
|
+
type: 'Segmentation',
|
|
219
|
+
message: 'Cannot perform brush operation on the selected viewport',
|
|
220
|
+
},
|
|
221
|
+
cancelable: true,
|
|
222
|
+
});
|
|
223
|
+
eventTarget.dispatchEvent(event);
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
211
227
|
// we used to take the first actor here but we should take the one that is
|
|
212
228
|
// probably the same size as the segmentation volume
|
|
213
229
|
const volumes = actors.map((actorEntry) =>
|
|
@@ -77,9 +77,15 @@ export default {
|
|
|
77
77
|
const { configuration, viewport } = operationData;
|
|
78
78
|
const { THRESHOLD: { dynamicRadius = 0 } = {} } =
|
|
79
79
|
configuration.strategySpecificConfiguration || {};
|
|
80
|
+
|
|
81
|
+
if (dynamicRadius === 0) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
80
85
|
const { spacing } = (
|
|
81
86
|
viewport as Types.IStackViewport | Types.IVolumeViewport
|
|
82
87
|
).getImageData();
|
|
88
|
+
|
|
83
89
|
const centerCanvas = [
|
|
84
90
|
viewport.element.clientWidth / 2,
|
|
85
91
|
viewport.element.clientHeight / 2,
|
|
@@ -4,10 +4,19 @@ import { triggerSegmentationDataModified } from '../../../../stateManagement/seg
|
|
|
4
4
|
import { config as segmentationConfig } from '../../../../stateManagement/segmentation';
|
|
5
5
|
import StrategyCallbacks from '../../../../enums/StrategyCallbacks';
|
|
6
6
|
|
|
7
|
+
function lightenColor(r, g, b, a, factor = 0.4) {
|
|
8
|
+
return [
|
|
9
|
+
Math.round(r + (255 - r) * factor),
|
|
10
|
+
Math.round(g + (255 - g) * factor),
|
|
11
|
+
Math.round(b + (255 - b) * factor),
|
|
12
|
+
a,
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
|
-
* Sets up a preview to use an alternate set of
|
|
17
|
+
* Sets up a preview to use an alternate set of colors. First fills the
|
|
9
18
|
* preview segment index with the final one for all pixels, then resets
|
|
10
|
-
* the preview
|
|
19
|
+
* the preview colors.
|
|
11
20
|
* This is only activated when the preview segment index is defined, either
|
|
12
21
|
* from the initial state or from the global state.
|
|
13
22
|
*/
|
|
@@ -71,7 +80,8 @@ export default {
|
|
|
71
80
|
if (!configColor && !segmentColor) {
|
|
72
81
|
return;
|
|
73
82
|
}
|
|
74
|
-
const previewColor = configColor || segmentColor
|
|
83
|
+
const previewColor = configColor || lightenColor(...segmentColor);
|
|
84
|
+
|
|
75
85
|
segmentationConfig.color.setColorForSegmentIndex(
|
|
76
86
|
toolGroupId,
|
|
77
87
|
segmentationRepresentationUID,
|
|
@@ -88,7 +98,7 @@ export default {
|
|
|
88
98
|
previewVoxelManager: previewVoxelManager,
|
|
89
99
|
previewSegmentIndex,
|
|
90
100
|
preview,
|
|
91
|
-
} = operationData;
|
|
101
|
+
} = operationData || {};
|
|
92
102
|
if (previewSegmentIndex === undefined) {
|
|
93
103
|
return;
|
|
94
104
|
}
|
|
@@ -87,8 +87,9 @@ export interface AdvancedMagnifyAnnotation extends Annotation {
|
|
|
87
87
|
zoomFactor: number;
|
|
88
88
|
sourceViewportId: string;
|
|
89
89
|
magnifyViewportId: string;
|
|
90
|
+
isCanvasAnnotation: boolean;
|
|
90
91
|
handles: {
|
|
91
|
-
points: Types.Point3
|
|
92
|
+
points: [Types.Point3, Types.Point3, Types.Point3, Types.Point3]; // in canvas space
|
|
92
93
|
activeHandleIndex: number | null;
|
|
93
94
|
};
|
|
94
95
|
};
|
|
@@ -198,10 +198,10 @@ function playClip(
|
|
|
198
198
|
* Stops an already playing clip.
|
|
199
199
|
* @param element - HTML Element
|
|
200
200
|
*/
|
|
201
|
-
function stopClip(element: HTMLDivElement,
|
|
201
|
+
function stopClip(element: HTMLDivElement, options = {} as any): void {
|
|
202
202
|
_stopClip(element, {
|
|
203
203
|
stopDynamicCine: true,
|
|
204
|
-
|
|
204
|
+
...options,
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -21,72 +21,7 @@ const UNIT_MAPPING = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const EPS = 1e-3;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Extracts the length units and the type of calibration for those units
|
|
27
|
-
* into the response. The length units will typically be either mm or px
|
|
28
|
-
* while the calibration type can be any of a number of different calibration types.
|
|
29
|
-
*
|
|
30
|
-
* Volumetric images have no calibration type, so are just the raw mm.
|
|
31
|
-
*
|
|
32
|
-
* TODO: Handle region calibration
|
|
33
|
-
*
|
|
34
|
-
* @param handles - used to detect if the spacing information is different
|
|
35
|
-
* between various points (eg angled ERMF or US Region).
|
|
36
|
-
* Currently unused, but needed for correct US Region handling
|
|
37
|
-
* @param image - to extract the calibration from
|
|
38
|
-
* image.calibration - calibration value to extract units form
|
|
39
|
-
* @returns String containing the units and type of calibration
|
|
40
|
-
*/
|
|
41
|
-
const getCalibratedLengthUnits = (handles, image): string => {
|
|
42
|
-
const { calibration, hasPixelSpacing } = image;
|
|
43
|
-
// Anachronistic - moving to using calibration consistently, but not completed yet
|
|
44
|
-
const units = hasPixelSpacing ? 'mm' : PIXEL_UNITS;
|
|
45
|
-
if (
|
|
46
|
-
!calibration ||
|
|
47
|
-
(!calibration.type && !calibration.sequenceOfUltrasoundRegions)
|
|
48
|
-
) {
|
|
49
|
-
return units;
|
|
50
|
-
}
|
|
51
|
-
if (calibration.type === CalibrationTypes.UNCALIBRATED) {
|
|
52
|
-
return PIXEL_UNITS;
|
|
53
|
-
}
|
|
54
|
-
if (calibration.sequenceOfUltrasoundRegions) {
|
|
55
|
-
return 'US Region';
|
|
56
|
-
}
|
|
57
|
-
return `${units} ${calibration.type}`;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
24
|
const SQUARE = '\xb2';
|
|
61
|
-
/**
|
|
62
|
-
* Extracts the area units, including the squared sign plus calibration type.
|
|
63
|
-
*/
|
|
64
|
-
const getCalibratedAreaUnits = (handles, image): string => {
|
|
65
|
-
const { calibration, hasPixelSpacing } = image;
|
|
66
|
-
const units = (hasPixelSpacing ? 'mm' : PIXEL_UNITS) + SQUARE;
|
|
67
|
-
if (!calibration || !calibration.type) {
|
|
68
|
-
return units;
|
|
69
|
-
}
|
|
70
|
-
if (calibration.sequenceOfUltrasoundRegions) {
|
|
71
|
-
return 'US Region';
|
|
72
|
-
}
|
|
73
|
-
return `${units} ${calibration.type}`;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Gets the scale divisor for converting from internal spacing to
|
|
78
|
-
* image spacing for calibrated images.
|
|
79
|
-
*/
|
|
80
|
-
const getCalibratedScale = (image, handles = []) => {
|
|
81
|
-
if (image.calibration?.sequenceOfUltrasoundRegions) {
|
|
82
|
-
// image.spacing / image.us.space
|
|
83
|
-
} else if (image.calibration?.scale) {
|
|
84
|
-
return image.calibration.scale;
|
|
85
|
-
} else {
|
|
86
|
-
return 1;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
25
|
/**
|
|
91
26
|
* Extracts the calibrated length units, area units, and the scale
|
|
92
27
|
* for converting from internal spacing to image spacing.
|
|
@@ -96,10 +31,9 @@ const getCalibratedScale = (image, handles = []) => {
|
|
|
96
31
|
* @returns Object containing the units, area units, and scale
|
|
97
32
|
*/
|
|
98
33
|
const getCalibratedLengthUnitsAndScale = (image, handles) => {
|
|
99
|
-
const [imageIndex1, imageIndex2] = handles;
|
|
100
34
|
const { calibration, hasPixelSpacing } = image;
|
|
101
35
|
let units = hasPixelSpacing ? 'mm' : PIXEL_UNITS;
|
|
102
|
-
|
|
36
|
+
let areaUnits = units + SQUARE;
|
|
103
37
|
let scale = 1;
|
|
104
38
|
let calibrationType = '';
|
|
105
39
|
|
|
@@ -115,6 +49,15 @@ const getCalibratedLengthUnitsAndScale = (image, handles) => {
|
|
|
115
49
|
}
|
|
116
50
|
|
|
117
51
|
if (calibration.sequenceOfUltrasoundRegions) {
|
|
52
|
+
let imageIndex1, imageIndex2;
|
|
53
|
+
if (Array.isArray(handles) && handles.length === 2) {
|
|
54
|
+
[imageIndex1, imageIndex2] = handles;
|
|
55
|
+
} else if (typeof handles === 'function') {
|
|
56
|
+
const points = handles();
|
|
57
|
+
imageIndex1 = points[0];
|
|
58
|
+
imageIndex2 = points[1];
|
|
59
|
+
}
|
|
60
|
+
|
|
118
61
|
let regions = calibration.sequenceOfUltrasoundRegions.filter(
|
|
119
62
|
(region) =>
|
|
120
63
|
imageIndex1[0] >= region.regionLocationMinX0 &&
|
|
@@ -165,17 +108,23 @@ const getCalibratedLengthUnitsAndScale = (image, handles) => {
|
|
|
165
108
|
);
|
|
166
109
|
|
|
167
110
|
if (isSamePhysicalDelta) {
|
|
168
|
-
|
|
111
|
+
// 1 to 1 aspect ratio, we use just one of them
|
|
112
|
+
scale = 1 / (physicalDeltaX * 10);
|
|
169
113
|
calibrationType = 'US Region';
|
|
170
114
|
units = 'mm';
|
|
115
|
+
areaUnits = 'mm' + SQUARE;
|
|
171
116
|
} else {
|
|
117
|
+
// here we are showing at the aspect ratio of the physical delta
|
|
118
|
+
// if they are not the same, then we should show px, but the correct solution
|
|
119
|
+
// is to grab each point separately and scale them individually
|
|
120
|
+
// Todo: implement this
|
|
172
121
|
return { units: PIXEL_UNITS, areaUnits: PIXEL_UNITS + SQUARE, scale };
|
|
173
122
|
}
|
|
174
123
|
} else if (calibration.scale) {
|
|
175
124
|
scale = calibration.scale;
|
|
176
125
|
}
|
|
177
126
|
|
|
178
|
-
// everything except REGION/
|
|
127
|
+
// everything except REGION/Uncalibrated
|
|
179
128
|
const types = [
|
|
180
129
|
CalibrationTypes.ERMF,
|
|
181
130
|
CalibrationTypes.USER,
|
|
@@ -272,13 +221,8 @@ const getCalibratedProbeUnitsAndValue = (image, handles) => {
|
|
|
272
221
|
*/
|
|
273
222
|
const getCalibratedAspect = (image) => image.calibration?.aspect || 1;
|
|
274
223
|
|
|
275
|
-
export default getCalibratedLengthUnits;
|
|
276
|
-
|
|
277
224
|
export {
|
|
278
|
-
getCalibratedAreaUnits,
|
|
279
|
-
getCalibratedLengthUnits,
|
|
280
225
|
getCalibratedLengthUnitsAndScale,
|
|
281
|
-
getCalibratedScale,
|
|
282
226
|
getCalibratedAspect,
|
|
283
227
|
getCalibratedProbeUnitsAndValue,
|
|
284
228
|
};
|
package/src/utilities/index.ts
CHANGED
|
@@ -12,9 +12,9 @@ import isObject from './isObject';
|
|
|
12
12
|
import clip from './clip';
|
|
13
13
|
import calibrateImageSpacing from './calibrateImageSpacing';
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
getCalibratedLengthUnitsAndScale,
|
|
16
|
+
getCalibratedProbeUnitsAndValue,
|
|
17
|
+
getCalibratedAspect,
|
|
18
18
|
} from './getCalibratedUnits';
|
|
19
19
|
import triggerAnnotationRenderForViewportIds from './triggerAnnotationRenderForViewportIds';
|
|
20
20
|
import triggerAnnotationRenderForToolGroupIds from './triggerAnnotationRenderForToolGroupIds';
|
|
@@ -67,9 +67,9 @@ export {
|
|
|
67
67
|
touch,
|
|
68
68
|
triggerEvent,
|
|
69
69
|
calibrateImageSpacing,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
getCalibratedLengthUnitsAndScale,
|
|
71
|
+
getCalibratedProbeUnitsAndValue,
|
|
72
|
+
getCalibratedAspect,
|
|
73
73
|
segmentation,
|
|
74
74
|
contours,
|
|
75
75
|
triggerAnnotationRenderForViewportIds,
|
|
@@ -47,6 +47,9 @@ export default function filterAnnotationsForDisplay(
|
|
|
47
47
|
if (!annotation.isVisible) {
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
|
+
if (annotation.data.isCanvasAnnotation) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
50
53
|
return viewport.isReferenceViewable(annotation.metadata, filterOptions);
|
|
51
54
|
});
|
|
52
55
|
}
|