@cornerstonejs/tools 1.56.2 → 1.57.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/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +3 -3
- package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -1
- package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LengthTool.js +4 -10
- package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +4 -0
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/base/BaseTool.js +1 -1
- package/dist/cjs/tools/base/BaseTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourBaseTool.js +5 -11
- package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/cjs/types/AnnotationTypes.d.ts +2 -7
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +0 -8
- package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js +4 -0
- package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js +4 -1
- package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/interpolate.js +7 -4
- package/dist/cjs/utilities/contours/interpolation/interpolate.js.map +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.d.ts +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js +12 -45
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsWithinSlice.js.map +1 -1
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js +1 -1
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
- package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js +2 -2
- package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js.map +1 -1
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +3 -3
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -1
- package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/LengthTool.js +4 -6
- package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +4 -0
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/base/BaseTool.js +1 -1
- package/dist/esm/tools/base/BaseTool.js.map +1 -1
- package/dist/esm/tools/base/ContourBaseTool.js +5 -7
- package/dist/esm/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js +4 -0
- package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/getInterpolationData.js +4 -1
- package/dist/esm/utilities/contours/interpolation/getInterpolationData.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/interpolate.js +7 -4
- package/dist/esm/utilities/contours/interpolation/interpolate.js.map +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js +13 -45
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js.map +1 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +1 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js +2 -2
- package/dist/esm/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js.map +1 -1
- package/dist/types/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts.map +1 -1
- package/dist/types/tools/annotation/CobbAngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -1
- package/dist/types/types/AnnotationTypes.d.ts +2 -7
- package/dist/types/types/AnnotationTypes.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +0 -8
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/getInterpolationData.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/interpolate.d.ts.map +1 -1
- package/dist/types/utilities/planar/filterAnnotationsForDisplay.d.ts +1 -1
- package/dist/types/utilities/planar/filterAnnotationsForDisplay.d.ts.map +1 -1
- package/dist/types/utilities/planar/filterAnnotationsWithinSlice.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/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.ts +10 -3
- package/src/tools/annotation/CobbAngleTool.ts +2 -3
- package/src/tools/annotation/LengthTool.ts +8 -8
- package/src/tools/annotation/PlanarFreehandROITool.ts +6 -0
- package/src/tools/base/BaseTool.ts +1 -1
- package/src/tools/base/ContourBaseTool.ts +5 -7
- package/src/types/AnnotationTypes.ts +5 -27
- package/src/types/ToolSpecificAnnotationTypes.ts +0 -8
- package/src/utilities/contours/interpolation/findAnnotationForInterpolation.ts +4 -0
- package/src/utilities/contours/interpolation/getInterpolationData.ts +5 -2
- package/src/utilities/contours/interpolation/interpolate.ts +8 -4
- package/src/utilities/planar/filterAnnotationsForDisplay.ts +20 -70
- package/src/utilities/planar/filterAnnotationsWithinSlice.ts +0 -1
- package/src/utilities/segmentation/InterpolationManager/InterpolationManager.ts +1 -1
- package/src/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.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.57.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": "f0b7bf4653169cad680753b9d79556b5998b5758"
|
|
63
63
|
}
|
|
@@ -43,8 +43,10 @@ export default async function contourSegmentationCompletedListener(
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const viewport = getViewport(sourceAnnotation);
|
|
46
|
-
const contourSegmentationAnnotations =
|
|
47
|
-
|
|
46
|
+
const contourSegmentationAnnotations = getValidContourSegmentationAnnotations(
|
|
47
|
+
viewport,
|
|
48
|
+
sourceAnnotation
|
|
49
|
+
);
|
|
48
50
|
|
|
49
51
|
if (!contourSegmentationAnnotations.length) {
|
|
50
52
|
return;
|
|
@@ -143,6 +145,7 @@ function convertContourPolylineToCanvasSpace(
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
function getValidContourSegmentationAnnotations(
|
|
148
|
+
viewport: Types.IViewport,
|
|
146
149
|
sourceAnnotation: ContourSegmentationAnnotation
|
|
147
150
|
): ContourSegmentationAnnotation[] {
|
|
148
151
|
const { annotationUID: sourceAnnotationUID } = sourceAnnotation;
|
|
@@ -155,10 +158,14 @@ function getValidContourSegmentationAnnotations(
|
|
|
155
158
|
targetAnnotation.annotationUID !== sourceAnnotationUID &&
|
|
156
159
|
contourSegUtils.isContourSegmentationAnnotation(targetAnnotation) &&
|
|
157
160
|
contourSegUtils.areSameSegment(targetAnnotation, sourceAnnotation) &&
|
|
158
|
-
|
|
161
|
+
viewport.isReferenceViewable(targetAnnotation.metadata)
|
|
159
162
|
) as ContourSegmentationAnnotation[];
|
|
160
163
|
}
|
|
161
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Finds other contours on the same slice which intersect the source polyline,
|
|
167
|
+
* represented as canvas points.
|
|
168
|
+
*/
|
|
162
169
|
function findIntersectingContour(
|
|
163
170
|
viewport: Types.IViewport,
|
|
164
171
|
sourcePolyline: Types.Point2[],
|
|
@@ -796,7 +796,7 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
796
796
|
data.cachedStats[targetId].points.canvas;
|
|
797
797
|
const { arc1Angle, arc2Angle } = data.cachedStats[targetId];
|
|
798
798
|
|
|
799
|
-
if (this.configuration.showArcLines){
|
|
799
|
+
if (this.configuration.showArcLines) {
|
|
800
800
|
lineUID = 'arc1';
|
|
801
801
|
|
|
802
802
|
drawLineSvg(
|
|
@@ -826,7 +826,6 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
826
826
|
);
|
|
827
827
|
}
|
|
828
828
|
|
|
829
|
-
|
|
830
829
|
if (!data.cachedStats[targetId]?.angle) {
|
|
831
830
|
continue;
|
|
832
831
|
}
|
|
@@ -880,7 +879,7 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
880
879
|
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
881
880
|
};
|
|
882
881
|
|
|
883
|
-
if (this.configuration.showArcLines){
|
|
882
|
+
if (this.configuration.showArcLines) {
|
|
884
883
|
const arc1TextBoxUID = 'arcAngle1';
|
|
885
884
|
|
|
886
885
|
const arc1TextLine = [
|
|
@@ -138,9 +138,11 @@ class LengthTool extends AnnotationTool {
|
|
|
138
138
|
hideElementCursor(element);
|
|
139
139
|
this.isDrawing = true;
|
|
140
140
|
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
const {
|
|
142
|
+
viewPlaneNormal,
|
|
143
|
+
viewUp,
|
|
144
|
+
position: cameraPosition,
|
|
145
|
+
} = viewport.getCamera();
|
|
144
146
|
const referencedImageId = this.getReferencedImageId(
|
|
145
147
|
viewport,
|
|
146
148
|
worldPos,
|
|
@@ -148,17 +150,15 @@ class LengthTool extends AnnotationTool {
|
|
|
148
150
|
viewUp
|
|
149
151
|
);
|
|
150
152
|
|
|
151
|
-
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
152
|
-
|
|
153
153
|
const annotation = {
|
|
154
154
|
highlighted: true,
|
|
155
155
|
invalidated: true,
|
|
156
156
|
metadata: {
|
|
157
|
+
...viewport.getViewReference({ points: [worldPos] }),
|
|
157
158
|
toolName: this.getToolName(),
|
|
158
|
-
viewPlaneNormal: <Types.Point3>[...viewPlaneNormal],
|
|
159
|
-
viewUp: <Types.Point3>[...viewUp],
|
|
160
|
-
FrameOfReferenceUID,
|
|
161
159
|
referencedImageId,
|
|
160
|
+
viewUp,
|
|
161
|
+
cameraPosition,
|
|
162
162
|
},
|
|
163
163
|
data: {
|
|
164
164
|
handles: {
|
|
@@ -531,6 +531,11 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
531
531
|
const worldPos = evt.detail.currentPoints.world;
|
|
532
532
|
const contourAnnotation = super.createAnnotation(evt);
|
|
533
533
|
|
|
534
|
+
const onInterpolationComplete = (annotation) => {
|
|
535
|
+
// Clear out the handles because they aren't used for straight freeform
|
|
536
|
+
annotation.data.handles.points.length = 0;
|
|
537
|
+
};
|
|
538
|
+
|
|
534
539
|
return <PlanarFreehandROIAnnotation>csUtils.deepMerge(contourAnnotation, {
|
|
535
540
|
data: {
|
|
536
541
|
contour: {
|
|
@@ -539,6 +544,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
539
544
|
label: '',
|
|
540
545
|
cachedStats: {},
|
|
541
546
|
},
|
|
547
|
+
onInterpolationComplete,
|
|
542
548
|
});
|
|
543
549
|
}
|
|
544
550
|
|
|
@@ -243,7 +243,7 @@ abstract class BaseTool implements IBaseTool {
|
|
|
243
243
|
* @returns targetId
|
|
244
244
|
*/
|
|
245
245
|
protected getTargetId(viewport: Types.IViewport): string | undefined {
|
|
246
|
-
const targetId = viewport.
|
|
246
|
+
const targetId = viewport.getReferenceId?.();
|
|
247
247
|
if (targetId) {
|
|
248
248
|
return targetId;
|
|
249
249
|
}
|
|
@@ -110,7 +110,7 @@ abstract class ContourBaseTool extends AnnotationTool {
|
|
|
110
110
|
const { viewport } = enabledElement;
|
|
111
111
|
|
|
112
112
|
const camera = viewport.getCamera();
|
|
113
|
-
const { viewPlaneNormal, viewUp } = camera;
|
|
113
|
+
const { viewPlaneNormal, viewUp, position: cameraPosition } = camera;
|
|
114
114
|
|
|
115
115
|
const referencedImageId = this.getReferencedImageId(
|
|
116
116
|
viewport,
|
|
@@ -119,19 +119,17 @@ abstract class ContourBaseTool extends AnnotationTool {
|
|
|
119
119
|
viewUp
|
|
120
120
|
);
|
|
121
121
|
|
|
122
|
-
const
|
|
123
|
-
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
122
|
+
const viewReference = viewport.getViewReference({ points: [worldPos] });
|
|
124
123
|
|
|
125
124
|
return <ContourAnnotation>{
|
|
126
125
|
highlighted: true,
|
|
127
126
|
invalidated: true,
|
|
128
127
|
metadata: {
|
|
129
128
|
toolName: this.getToolName(),
|
|
130
|
-
|
|
131
|
-
viewUp: <Types.Point3>[...viewUp],
|
|
132
|
-
FrameOfReferenceUID,
|
|
129
|
+
...viewReference,
|
|
133
130
|
referencedImageId,
|
|
134
|
-
|
|
131
|
+
viewUp,
|
|
132
|
+
cameraPosition,
|
|
135
133
|
},
|
|
136
134
|
data: {
|
|
137
135
|
handles: {
|
|
@@ -28,41 +28,19 @@ type Annotation = {
|
|
|
28
28
|
/** If the annotation is auto generated from other annotations*/
|
|
29
29
|
autoGenerated?: boolean;
|
|
30
30
|
/** Metadata for annotation */
|
|
31
|
-
metadata: {
|
|
32
|
-
/**
|
|
33
|
-
* The position of the camera in world space
|
|
34
|
-
*/
|
|
35
|
-
cameraPosition?: Types.Point3;
|
|
36
|
-
/**
|
|
37
|
-
* The focal point of the camera in world space
|
|
38
|
-
*/
|
|
39
|
-
cameraFocalPoint?: Types.Point3;
|
|
40
|
-
/**
|
|
41
|
-
* The normal on which the tool was drawn
|
|
42
|
-
*/
|
|
43
|
-
viewPlaneNormal?: Types.Point3;
|
|
44
|
-
/**
|
|
45
|
-
* The viewUp on which the tool was drawn.
|
|
46
|
-
*/
|
|
47
|
-
viewUp?: Types.Point3;
|
|
48
|
-
/**
|
|
49
|
-
* The FrameOfReferenceUID
|
|
50
|
-
*/
|
|
51
|
-
FrameOfReferenceUID: string;
|
|
31
|
+
metadata: Types.ViewReference & {
|
|
52
32
|
/**
|
|
53
33
|
* The registered name of the tool
|
|
54
34
|
*/
|
|
55
35
|
toolName: string;
|
|
56
36
|
/**
|
|
57
|
-
*
|
|
58
|
-
* or when annotating in a VolumeViewport on a viewPlane that corresponds to
|
|
59
|
-
* original slice-based image data.
|
|
37
|
+
* The position of the camera in world space.
|
|
60
38
|
*/
|
|
61
|
-
|
|
39
|
+
cameraPosition?: Types.Point3;
|
|
62
40
|
/**
|
|
63
|
-
*
|
|
41
|
+
* The viewUp for the view position
|
|
64
42
|
*/
|
|
65
|
-
|
|
43
|
+
viewUp?: Types.Point3;
|
|
66
44
|
};
|
|
67
45
|
/**
|
|
68
46
|
* Data for annotation, Derivatives need to define their own data types.
|
|
@@ -262,15 +262,7 @@ export type PlanarFreehandContourSegmentationAnnotation =
|
|
|
262
262
|
|
|
263
263
|
export type InterpolationROIAnnotation = ContourAnnotation & {
|
|
264
264
|
metadata: {
|
|
265
|
-
cameraPosition?: Types.Point3;
|
|
266
|
-
cameraFocalPoint?: Types.Point3;
|
|
267
|
-
viewPlaneNormal?: Types.Point3;
|
|
268
|
-
viewUp?: Types.Point3;
|
|
269
265
|
annotationUID?: string;
|
|
270
|
-
FrameOfReferenceUID: string;
|
|
271
|
-
referencedImageId?: string;
|
|
272
|
-
toolName: string;
|
|
273
|
-
referencedSliceIndex?: number;
|
|
274
266
|
};
|
|
275
267
|
interpolationUID?: string;
|
|
276
268
|
/**
|
|
@@ -30,6 +30,10 @@ function findAnnotationsForInterpolation(
|
|
|
30
30
|
},
|
|
31
31
|
]);
|
|
32
32
|
const rangeToInterpolate = getRangeToInterpolate(interpolationData);
|
|
33
|
+
if (!rangeToInterpolate) {
|
|
34
|
+
console.warn('No annotations found to interpolate', interpolationData);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
33
37
|
const sliceEdited = _getSlicePositionOfToolData(
|
|
34
38
|
interpolationData,
|
|
35
39
|
toolData.annotationUID
|
|
@@ -43,10 +43,13 @@ export default function getInterpolationData(
|
|
|
43
43
|
viewport.element
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
+
if (!annotations) {
|
|
47
|
+
return interpolationDatas;
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
for (let i = 0; i < sliceData.numberOfSlices; i++) {
|
|
47
51
|
const imageAnnotations = annotations.filter(
|
|
48
|
-
(x) =>
|
|
49
|
-
(x as InterpolationROIAnnotation).metadata.referencedSliceIndex === i
|
|
52
|
+
(x) => x.metadata.sliceIndex === i
|
|
50
53
|
);
|
|
51
54
|
|
|
52
55
|
if (!imageAnnotations?.length) {
|
|
@@ -76,7 +76,11 @@ function interpolate(viewportData: InterpolationViewportData) {
|
|
|
76
76
|
function startInterpolation(viewportData: InterpolationViewportData) {
|
|
77
77
|
const toolData = viewportData.annotation;
|
|
78
78
|
const { interpolationData, interpolationList } =
|
|
79
|
-
findAnnotationsForInterpolation(toolData, viewportData);
|
|
79
|
+
findAnnotationsForInterpolation(toolData, viewportData) || {};
|
|
80
|
+
|
|
81
|
+
if (!interpolationData || !interpolationList) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
80
84
|
|
|
81
85
|
const eventData = {
|
|
82
86
|
toolName: toolData.metadata.toolName,
|
|
@@ -247,9 +251,9 @@ function _addInterpolatedContour(
|
|
|
247
251
|
referencedToolData
|
|
248
252
|
);
|
|
249
253
|
|
|
250
|
-
const targetId = viewport.
|
|
254
|
+
const targetId = viewport.getReferenceId({ sliceIndex });
|
|
251
255
|
interpolatedAnnotation.metadata.referencedImageId = targetId;
|
|
252
|
-
interpolatedAnnotation.metadata.
|
|
256
|
+
interpolatedAnnotation.metadata.sliceIndex = sliceIndex;
|
|
253
257
|
annotationState.state.addAnnotation(interpolatedAnnotation, viewport.element);
|
|
254
258
|
referencedToolData.onInterpolationComplete?.(
|
|
255
259
|
interpolatedAnnotation,
|
|
@@ -289,7 +293,7 @@ function _editInterpolatedContour(
|
|
|
289
293
|
const annotation = annotations[i] as InterpolationROIAnnotation;
|
|
290
294
|
if (
|
|
291
295
|
annotation.interpolationUID === referencedToolData.interpolationUID &&
|
|
292
|
-
annotation.metadata.
|
|
296
|
+
annotation.metadata.sliceIndex === sliceIndex
|
|
293
297
|
) {
|
|
294
298
|
toolDataIndex = i;
|
|
295
299
|
break;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StackViewport,
|
|
3
3
|
VolumeViewport,
|
|
4
|
-
VideoViewport,
|
|
5
4
|
Types,
|
|
6
5
|
utilities as csUtils,
|
|
7
6
|
} from '@cornerstonejs/core';
|
|
8
7
|
|
|
9
8
|
import filterAnnotationsWithinSlice from './filterAnnotationsWithinSlice';
|
|
10
9
|
import type { Annotations } from '../../types';
|
|
11
|
-
import annotationFrameRange from '../annotationFrameRange';
|
|
12
|
-
|
|
13
|
-
const baseUrlExtractor = /(videoId:|imageId:|volumeId:)([a-zA-Z]*:)/;
|
|
14
10
|
|
|
15
11
|
/**
|
|
16
12
|
* Given the viewport and the annotations, it filters the annotations array and only
|
|
@@ -20,71 +16,10 @@ const baseUrlExtractor = /(videoId:|imageId:|volumeId:)([a-zA-Z]*:)/;
|
|
|
20
16
|
*/
|
|
21
17
|
export default function filterAnnotationsForDisplay(
|
|
22
18
|
viewport: Types.IViewport,
|
|
23
|
-
annotations: Annotations
|
|
19
|
+
annotations: Annotations,
|
|
20
|
+
filterOptions: Types.ReferenceCompatibleOptions = {}
|
|
24
21
|
): Annotations {
|
|
25
|
-
if (viewport instanceof
|
|
26
|
-
// 1. Get the currently displayed imageId from the StackViewport
|
|
27
|
-
const imageId = viewport.getCurrentImageId();
|
|
28
|
-
|
|
29
|
-
// 2. remove the dataLoader scheme since it might be an annotation that was
|
|
30
|
-
// created on the volumeViewport initially and has the volumeLoader scheme
|
|
31
|
-
// but shares the same imageId
|
|
32
|
-
const colonIndex = imageId.indexOf(':');
|
|
33
|
-
const imageURI = imageId.substring(colonIndex + 1);
|
|
34
|
-
|
|
35
|
-
// 3. Filter annotation in the frame of reference by the referenced image ID property
|
|
36
|
-
// Note: With the current implementation drawing on the stack (PT stack) will not
|
|
37
|
-
// show the annotation on a volume that does not share the same imageURIs (CT Volume),
|
|
38
|
-
// and we don't have a proper way to check distance either since a stack can be
|
|
39
|
-
// composed of multiple unrelated images
|
|
40
|
-
return annotations.filter((annotation) => {
|
|
41
|
-
if (!annotation.isVisible) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// The referenced image id can be a targetId, so handle removing the
|
|
46
|
-
// imageId portion to make the base comparison work.
|
|
47
|
-
const imageId = annotation.metadata.referencedImageId?.replace(
|
|
48
|
-
'imageId:',
|
|
49
|
-
''
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
if (imageId === undefined) {
|
|
53
|
-
// This annotation was not drawn on a non-coplanar reformat, and such does
|
|
54
|
-
// not have a referenced imageId.
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const colonIndex = imageId.indexOf(':');
|
|
59
|
-
const referenceImageURI = imageId.substring(colonIndex + 1);
|
|
60
|
-
return referenceImageURI === imageURI;
|
|
61
|
-
});
|
|
62
|
-
} else if (viewport instanceof VideoViewport) {
|
|
63
|
-
const frameOfReferenceUID: string = viewport.getFrameOfReferenceUID();
|
|
64
|
-
|
|
65
|
-
return annotations.filter((annotation) => {
|
|
66
|
-
if (!annotation.isVisible) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
if (annotation.metadata.FrameOfReferenceUID !== frameOfReferenceUID) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
const testURI = annotation.metadata.referencedImageId.replace(
|
|
73
|
-
baseUrlExtractor,
|
|
74
|
-
''
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
if (!viewport.hasImageURI(testURI)) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
const range = annotationFrameRange.getFrameRange(annotation);
|
|
81
|
-
const frameNumber = viewport.getFrameNumber();
|
|
82
|
-
if (Array.isArray(range)) {
|
|
83
|
-
return frameNumber >= range[0] && frameNumber <= range[1];
|
|
84
|
-
}
|
|
85
|
-
return Math.abs(frameNumber - range) < 1;
|
|
86
|
-
});
|
|
87
|
-
} else if (viewport instanceof VolumeViewport) {
|
|
22
|
+
if (viewport instanceof VolumeViewport) {
|
|
88
23
|
const camera = viewport.getCamera();
|
|
89
24
|
|
|
90
25
|
const { spacingInNormalDirection } =
|
|
@@ -96,7 +31,22 @@ export default function filterAnnotationsForDisplay(
|
|
|
96
31
|
camera,
|
|
97
32
|
spacingInNormalDirection
|
|
98
33
|
);
|
|
99
|
-
} else {
|
|
100
|
-
throw new Error(`Viewport Type ${viewport.type} not supported`);
|
|
101
34
|
}
|
|
35
|
+
if (viewport instanceof StackViewport) {
|
|
36
|
+
// 1. Get the currently displayed imageId from the StackViewport
|
|
37
|
+
const imageId = viewport.getCurrentImageId();
|
|
38
|
+
|
|
39
|
+
// 2. remove the dataLoader scheme since it might be an annotation that was
|
|
40
|
+
// created on the volumeViewport initially and has the volumeLoader scheme
|
|
41
|
+
// but shares the same imageId
|
|
42
|
+
const colonIndex = imageId.indexOf(':');
|
|
43
|
+
|
|
44
|
+
filterOptions.imageURI = imageId.substring(colonIndex + 1);
|
|
45
|
+
}
|
|
46
|
+
return annotations.filter((annotation) => {
|
|
47
|
+
if (!annotation.isVisible) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return viewport.isReferenceViewable(annotation.metadata, filterOptions);
|
|
51
|
+
});
|
|
102
52
|
}
|
|
@@ -2,7 +2,6 @@ import { vec3 } from 'gl-matrix';
|
|
|
2
2
|
import { CONSTANTS, metaData } from '@cornerstonejs/core';
|
|
3
3
|
import type { Types } from '@cornerstonejs/core';
|
|
4
4
|
import { Annotations, Annotation } from '../../types';
|
|
5
|
-
import { debug } from 'console';
|
|
6
5
|
|
|
7
6
|
const { EPSILON } = CONSTANTS;
|
|
8
7
|
|
|
@@ -21,7 +21,7 @@ export default function deleteRelatedAnnotations(
|
|
|
21
21
|
{ key: 'interpolationUID', value: viewportData.interpolationUID },
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
|
-
const referencedSliceIndex = annotation.metadata.
|
|
24
|
+
const referencedSliceIndex = annotation.metadata.sliceIndex as number;
|
|
25
25
|
let minInterpolation = -1;
|
|
26
26
|
let maxInterpolation = viewportData.sliceData.numberOfSlices;
|
|
27
27
|
for (const [sliceIndex, annotations] of interpolationAnnotations.entries()) {
|
|
@@ -87,7 +87,7 @@ export default function deleteRelatedAnnotations(
|
|
|
87
87
|
viewport: viewportData.viewport,
|
|
88
88
|
sliceData: {
|
|
89
89
|
numberOfSlices: viewportData.sliceData.numberOfSlices,
|
|
90
|
-
imageIndex: nextAnnotation.metadata.
|
|
90
|
+
imageIndex: nextAnnotation.metadata.sliceIndex as number,
|
|
91
91
|
},
|
|
92
92
|
annotation: nextAnnotation,
|
|
93
93
|
interpolationUID: nextAnnotation.interpolationUID,
|