@cornerstonejs/tools 2.0.0-beta.17 → 2.0.0-beta.19
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/eventListeners/segmentation/imageChangeEventListener.js +11 -14
- package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +26 -27
- package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +1 -4
- package/dist/esm/eventListeners/segmentation/segmentationModifiedEventListener.js +2 -11
- package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.js +10 -2
- package/dist/esm/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js +2 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/stateManagement/index.d.ts +3 -3
- package/dist/esm/stateManagement/index.js +2 -2
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +19 -18
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +87 -130
- package/dist/esm/stateManagement/segmentation/activeSegmentation.d.ts +4 -5
- package/dist/esm/stateManagement/segmentation/activeSegmentation.js +6 -23
- package/dist/esm/stateManagement/segmentation/addRepresentation.d.ts +3 -0
- package/dist/esm/stateManagement/segmentation/addRepresentation.js +51 -0
- package/dist/esm/stateManagement/segmentation/addRepresentations.d.ts +3 -0
- package/dist/esm/stateManagement/segmentation/addRepresentations.js +9 -0
- package/dist/esm/stateManagement/segmentation/config/index.d.ts +2 -2
- package/dist/esm/stateManagement/segmentation/config/index.js +2 -2
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.d.ts +4 -4
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +10 -10
- package/dist/esm/stateManagement/segmentation/config/segmentationConfig.d.ts +8 -8
- package/dist/esm/stateManagement/segmentation/config/segmentationConfig.js +19 -13
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.d.ts +7 -6
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +29 -54
- package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js +5 -5
- package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +3 -3
- package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +5 -5
- package/dist/esm/stateManagement/segmentation/helpers/getRepresentationRenderingConfig.d.ts +2 -0
- package/dist/esm/stateManagement/segmentation/helpers/{getRepresentationSpecificConfig.js → getRepresentationRenderingConfig.js} +1 -1
- package/dist/esm/stateManagement/segmentation/index.d.ts +3 -3
- package/dist/esm/stateManagement/segmentation/index.js +3 -3
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +2 -4
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +5 -6
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.js +4 -4
- package/dist/esm/stateManagement/segmentation/polySeg/canComputeRequestedRepresentation.js +2 -6
- package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.d.ts +2 -0
- package/dist/esm/stateManagement/segmentation/removeRepresentationsFromViewport.js +23 -0
- package/dist/esm/stateManagement/segmentation/segmentIndex.js +6 -4
- package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +23 -20
- package/dist/esm/stateManagement/segmentation/segmentationState.js +68 -95
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.d.ts +2 -2
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +4 -18
- package/dist/esm/store/ToolGroupManager/destroyToolGroup.js +0 -4
- package/dist/esm/tools/AdvancedMagnifyViewport.js +3 -3
- package/dist/esm/tools/ScaleOverlayTool.d.ts +1 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +6 -7
- package/dist/esm/tools/annotation/CircleROITool.js +14 -14
- package/dist/esm/tools/annotation/DragProbeTool.js +3 -3
- package/dist/esm/tools/annotation/EllipticalROITool.js +12 -12
- package/dist/esm/tools/annotation/LengthTool.js +2 -2
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +13 -15
- package/dist/esm/tools/annotation/ProbeTool.js +10 -10
- package/dist/esm/tools/annotation/RectangleROITool.js +12 -12
- package/dist/esm/tools/annotation/SplineROITool.js +5 -5
- package/dist/esm/tools/base/ContourSegmentationBaseTool.d.ts +0 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +42 -33
- package/dist/esm/tools/displayTools/Contour/contourDisplay.d.ts +4 -4
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +17 -30
- package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.d.ts +4 -4
- package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +20 -11
- package/dist/esm/tools/displayTools/Contour/contourHandler/utils.d.ts +0 -2
- package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +0 -11
- package/dist/esm/tools/displayTools/Contour/removeContourFromElement.d.ts +1 -1
- package/dist/esm/tools/displayTools/Contour/removeContourFromElement.js +3 -3
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +5 -5
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +51 -54
- package/dist/esm/tools/displayTools/SegmentationRenderingEngine.d.ts +19 -0
- package/dist/esm/tools/displayTools/SegmentationRenderingEngine.js +136 -0
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.d.ts +5 -5
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +14 -25
- package/dist/esm/tools/index.d.ts +1 -2
- package/dist/esm/tools/index.js +1 -2
- package/dist/esm/tools/segmentation/BrushTool.d.ts +15 -2
- package/dist/esm/tools/segmentation/BrushTool.js +13 -14
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +3 -4
- package/dist/esm/tools/segmentation/PaintFillTool.js +1 -2
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +3 -4
- package/dist/esm/tools/segmentation/SegmentSelectTool.d.ts +3 -2
- package/dist/esm/tools/segmentation/SegmentSelectTool.js +5 -5
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +4 -5
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
- package/dist/esm/types/EventTypes.d.ts +0 -3
- package/dist/esm/types/SegmentationStateTypes.d.ts +24 -23
- package/dist/esm/types/ToolSpecificAnnotationTypes.d.ts +2 -2
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/utilities/getCalibratedUnits.d.ts +6 -0
- package/dist/esm/utilities/getCalibratedUnits.js +16 -8
- package/dist/esm/utilities/getPixelValueUnits.d.ts +6 -0
- package/dist/esm/utilities/{getModalityUnit.js → getPixelValueUnits.js} +2 -2
- package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.d.ts +7 -0
- package/dist/esm/utilities/segmentation/{getSegmentAtLabelmapBorder.js → getSegmentIndexAtLabelmapBorder.js} +3 -3
- package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.d.ts +11 -0
- package/dist/esm/utilities/segmentation/{getSegmentAtWorldPoint.js → getSegmentIndexAtWorldPoint.js} +7 -7
- package/dist/esm/utilities/segmentation/index.d.ts +3 -3
- package/dist/esm/utilities/segmentation/index.js +3 -3
- package/dist/esm/utilities/segmentation/triggerSegmentationRender.d.ts +2 -17
- package/dist/esm/utilities/segmentation/triggerSegmentationRender.js +4 -106
- package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.d.ts +3 -0
- package/dist/esm/utilities/segmentation/triggerSegmentationRenderForViewports.js +6 -0
- package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -4
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.js +0 -63
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.js +0 -14
- package/dist/esm/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.d.ts +0 -2
- package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.d.ts +0 -2
- package/dist/esm/stateManagement/segmentation/removeSegmentationsFromToolGroup.js +0 -39
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.d.ts +0 -13
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +0 -101
- package/dist/esm/utilities/getModalityUnit.d.ts +0 -6
- package/dist/esm/utilities/segmentation/getSegmentAtLabelmapBorder.d.ts +0 -7
- package/dist/esm/utilities/segmentation/getSegmentAtWorldPoint.d.ts +0 -11
|
@@ -17,7 +17,7 @@ import { pointInEllipse, getCanvasEllipseCorners, } from '../../utilities/math/e
|
|
|
17
17
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
18
18
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
19
19
|
import { pointInShapeCallback } from '../../utilities/';
|
|
20
|
-
import {
|
|
20
|
+
import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
|
|
21
21
|
import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
|
|
22
22
|
import { BasicStatsCalculator } from '../../utilities/math/basic';
|
|
23
23
|
const { transformWorldToIndex } = csUtils;
|
|
@@ -428,14 +428,14 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
428
428
|
const canvasCorners = (getCanvasEllipseCorners(canvasCoordinates));
|
|
429
429
|
const { centerPointRadius } = this.configuration;
|
|
430
430
|
if (!data.cachedStats[targetId] ||
|
|
431
|
-
data.cachedStats[targetId].
|
|
431
|
+
data.cachedStats[targetId].areaUnits == null) {
|
|
432
432
|
data.cachedStats[targetId] = {
|
|
433
433
|
Modality: null,
|
|
434
434
|
area: null,
|
|
435
435
|
max: null,
|
|
436
436
|
mean: null,
|
|
437
437
|
stdDev: null,
|
|
438
|
-
|
|
438
|
+
areaUnits: null,
|
|
439
439
|
};
|
|
440
440
|
this._calculateCachedStats(annotation, viewport, renderingEngine);
|
|
441
441
|
}
|
|
@@ -592,11 +592,11 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
592
592
|
const area = Math.abs(Math.PI * (worldWidth / 2) * (worldHeight / 2)) /
|
|
593
593
|
scale /
|
|
594
594
|
scale;
|
|
595
|
-
const
|
|
595
|
+
const pixelUnitsOptions = {
|
|
596
596
|
isPreScaled: isViewportPreScaled(viewport, targetId),
|
|
597
597
|
isSuvScaled: this.isSuvScaled(viewport, targetId, annotation.metadata.referencedImageId),
|
|
598
598
|
};
|
|
599
|
-
const
|
|
599
|
+
const pixelValueUnits = getPixelValueUnits(metadata.Modality, annotation.metadata.referencedImageId, pixelUnitsOptions);
|
|
600
600
|
const pointsInShape = pointInShapeCallback(imageData, (pointLPS) => pointInEllipse(ellipseObj, pointLPS, { fast: true }), this.configuration.statsCalculator.statsCallback, boundsIJK);
|
|
601
601
|
const stats = this.configuration.statsCalculator.getStatistics();
|
|
602
602
|
cachedStats[targetId] = {
|
|
@@ -608,8 +608,8 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
608
608
|
statsArray: stats.array,
|
|
609
609
|
pointsInShape,
|
|
610
610
|
isEmptyArea,
|
|
611
|
-
|
|
612
|
-
|
|
611
|
+
areaUnits,
|
|
612
|
+
pixelValueUnits,
|
|
613
613
|
};
|
|
614
614
|
}
|
|
615
615
|
annotation.invalidated = false;
|
|
@@ -647,22 +647,22 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
647
647
|
}
|
|
648
648
|
function defaultGetTextLines(data, targetId) {
|
|
649
649
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
650
|
-
const { area, mean, stdDev, max, isEmptyArea,
|
|
650
|
+
const { area, mean, stdDev, max, isEmptyArea, areaUnits, pixelValueUnits } = cachedVolumeStats;
|
|
651
651
|
const textLines = [];
|
|
652
652
|
if (area) {
|
|
653
653
|
const areaLine = isEmptyArea
|
|
654
654
|
? `Area: Oblique not supported`
|
|
655
|
-
: `Area: ${roundNumber(area)} ${
|
|
655
|
+
: `Area: ${roundNumber(area)} ${areaUnits}`;
|
|
656
656
|
textLines.push(areaLine);
|
|
657
657
|
}
|
|
658
658
|
if (mean) {
|
|
659
|
-
textLines.push(`Mean: ${roundNumber(mean)} ${
|
|
659
|
+
textLines.push(`Mean: ${roundNumber(mean)} ${pixelValueUnits}`);
|
|
660
660
|
}
|
|
661
661
|
if (max) {
|
|
662
|
-
textLines.push(`Max: ${roundNumber(max)} ${
|
|
662
|
+
textLines.push(`Max: ${roundNumber(max)} ${pixelValueUnits}`);
|
|
663
663
|
}
|
|
664
664
|
if (stdDev) {
|
|
665
|
-
textLines.push(`Std Dev: ${roundNumber(stdDev)} ${
|
|
665
|
+
textLines.push(`Std Dev: ${roundNumber(stdDev)} ${pixelValueUnits}`);
|
|
666
666
|
}
|
|
667
667
|
return textLines;
|
|
668
668
|
}
|
|
@@ -393,14 +393,14 @@ class LengthTool extends AnnotationTool {
|
|
|
393
393
|
const index1 = transformWorldToIndex(imageData, worldPos1);
|
|
394
394
|
const index2 = transformWorldToIndex(imageData, worldPos2);
|
|
395
395
|
const handles = [index1, index2];
|
|
396
|
-
const { scale,
|
|
396
|
+
const { scale, lengthUnits } = getCalibratedLengthUnitsAndScale(image, handles);
|
|
397
397
|
const length = this._calculateLength(worldPos1, worldPos2) / scale;
|
|
398
398
|
this._isInsideVolume(index1, index2, dimensions)
|
|
399
399
|
? (this.isHandleOutsideImage = false)
|
|
400
400
|
: (this.isHandleOutsideImage = true);
|
|
401
401
|
cachedStats[targetId] = {
|
|
402
402
|
length,
|
|
403
|
-
|
|
403
|
+
lengthUnits,
|
|
404
404
|
};
|
|
405
405
|
}
|
|
406
406
|
annotation.invalidated = false;
|
|
@@ -19,7 +19,7 @@ import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
|
19
19
|
import { getLineSegmentIntersectionsCoordinates } from '../../utilities/math/polyline';
|
|
20
20
|
import pointInShapeCallback from '../../utilities/pointInShapeCallback';
|
|
21
21
|
import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
|
|
22
|
-
import {
|
|
22
|
+
import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
|
|
23
23
|
import { BasicStatsCalculator } from '../../utilities/math/basic';
|
|
24
24
|
import calculatePerimeter from '../../utilities/contours/calculatePerimeter';
|
|
25
25
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
@@ -70,8 +70,6 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
70
70
|
this.addNewAnnotation = (evt) => {
|
|
71
71
|
const eventDetail = evt.detail;
|
|
72
72
|
const { element } = eventDetail;
|
|
73
|
-
const enabledElement = getEnabledElement(element);
|
|
74
|
-
const { renderingEngine } = enabledElement;
|
|
75
73
|
const annotation = this.createAnnotation(evt);
|
|
76
74
|
this.addAnnotation(annotation, element);
|
|
77
75
|
const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
|
|
@@ -251,11 +249,11 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
251
249
|
}
|
|
252
250
|
return result;
|
|
253
251
|
}, this.configuration.statsCalculator.statsCallback, boundsIJK);
|
|
254
|
-
const
|
|
252
|
+
const pixelUnitsOptions = {
|
|
255
253
|
isPreScaled: isViewportPreScaled(viewport, targetId),
|
|
256
254
|
isSuvScaled: this.isSuvScaled(viewport, targetId, annotation.metadata.referencedImageId),
|
|
257
255
|
};
|
|
258
|
-
const
|
|
256
|
+
const pixelValueUnits = getPixelValueUnits(metadata.Modality, annotation.metadata.referencedImageId, pixelUnitsOptions);
|
|
259
257
|
const stats = this.configuration.statsCalculator.getStatistics();
|
|
260
258
|
cachedStats[targetId] = {
|
|
261
259
|
Modality: metadata.Modality,
|
|
@@ -266,8 +264,8 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
266
264
|
stdDev: stats.stdDev?.value,
|
|
267
265
|
statsArray: stats.array,
|
|
268
266
|
pointsInShape: pointsInShape,
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
areaUnits,
|
|
268
|
+
pixelValueUnits,
|
|
271
269
|
};
|
|
272
270
|
}
|
|
273
271
|
triggerAnnotationModified(annotation, enabledElement.viewport.element, ChangeTypes.StatsUpdated);
|
|
@@ -445,14 +443,14 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
445
443
|
if (!this.commonData?.movingTextBox) {
|
|
446
444
|
const { data } = annotation;
|
|
447
445
|
if (!data.cachedStats[targetId] ||
|
|
448
|
-
data.cachedStats[targetId].
|
|
446
|
+
data.cachedStats[targetId].areaUnits == null) {
|
|
449
447
|
data.cachedStats[targetId] = {
|
|
450
448
|
Modality: null,
|
|
451
449
|
area: null,
|
|
452
450
|
max: null,
|
|
453
451
|
mean: null,
|
|
454
452
|
stdDev: null,
|
|
455
|
-
|
|
453
|
+
areaUnits: null,
|
|
456
454
|
};
|
|
457
455
|
this._calculateCachedStats(annotation, viewport, renderingEngine, enabledElement);
|
|
458
456
|
}
|
|
@@ -464,25 +462,25 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
464
462
|
}
|
|
465
463
|
function defaultGetTextLines(data, targetId) {
|
|
466
464
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
467
|
-
const { area, mean, stdDev, perimeter, max, isEmptyArea,
|
|
465
|
+
const { area, mean, stdDev, perimeter, max, isEmptyArea, areaUnits, pixelValueUnits, } = cachedVolumeStats || {};
|
|
468
466
|
const textLines = [];
|
|
469
467
|
if (area) {
|
|
470
468
|
const areaLine = isEmptyArea
|
|
471
469
|
? `Area: Oblique not supported`
|
|
472
|
-
: `Area: ${roundNumber(area)} ${
|
|
470
|
+
: `Area: ${roundNumber(area)} ${areaUnits}`;
|
|
473
471
|
textLines.push(areaLine);
|
|
474
472
|
}
|
|
475
473
|
if (mean) {
|
|
476
|
-
textLines.push(`Mean: ${roundNumber(mean)} ${
|
|
474
|
+
textLines.push(`Mean: ${roundNumber(mean)} ${pixelValueUnits}`);
|
|
477
475
|
}
|
|
478
476
|
if (max) {
|
|
479
|
-
textLines.push(`Max: ${roundNumber(max)} ${
|
|
477
|
+
textLines.push(`Max: ${roundNumber(max)} ${pixelValueUnits}`);
|
|
480
478
|
}
|
|
481
479
|
if (stdDev) {
|
|
482
|
-
textLines.push(`Std Dev: ${roundNumber(stdDev)} ${
|
|
480
|
+
textLines.push(`Std Dev: ${roundNumber(stdDev)} ${pixelValueUnits}`);
|
|
483
481
|
}
|
|
484
482
|
if (perimeter) {
|
|
485
|
-
textLines.push(`Perimeter: ${roundNumber(perimeter)} ${
|
|
483
|
+
textLines.push(`Perimeter: ${roundNumber(perimeter)} ${pixelValueUnits}`);
|
|
486
484
|
}
|
|
487
485
|
return textLines;
|
|
488
486
|
}
|
|
@@ -11,7 +11,7 @@ import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters'
|
|
|
11
11
|
import { roundNumber } from '../../utilities';
|
|
12
12
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
13
13
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
14
|
-
import {
|
|
14
|
+
import { getPixelValueUnits, } from '../../utilities/getPixelValueUnits';
|
|
15
15
|
import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
|
|
16
16
|
const { transformWorldToIndex } = csUtils;
|
|
17
17
|
class ProbeTool extends AnnotationTool {
|
|
@@ -257,7 +257,7 @@ class ProbeTool extends AnnotationTool {
|
|
|
257
257
|
const targetIds = Object.keys(cachedStats);
|
|
258
258
|
for (let i = 0; i < targetIds.length; i++) {
|
|
259
259
|
const targetId = targetIds[i];
|
|
260
|
-
const
|
|
260
|
+
const pixelUnitsOptions = {
|
|
261
261
|
isPreScaled: isViewportPreScaled(viewport, targetId),
|
|
262
262
|
isSuvScaled: this.isSuvScaled(viewport, targetId, annotation.metadata.referencedImageId),
|
|
263
263
|
};
|
|
@@ -294,25 +294,25 @@ class ProbeTool extends AnnotationTool {
|
|
|
294
294
|
const viewport = viewports[0];
|
|
295
295
|
index[2] = viewport.getCurrentImageIdIndex();
|
|
296
296
|
}
|
|
297
|
-
let
|
|
297
|
+
let pixelValueUnits;
|
|
298
298
|
if (modality === 'US') {
|
|
299
299
|
const calibratedResults = getCalibratedProbeUnitsAndValue(image, [
|
|
300
300
|
index,
|
|
301
301
|
]);
|
|
302
302
|
const hasEnhancedRegionValues = calibratedResults.values.every((value) => value !== null);
|
|
303
303
|
value = hasEnhancedRegionValues ? calibratedResults.values : value;
|
|
304
|
-
|
|
304
|
+
pixelValueUnits = hasEnhancedRegionValues
|
|
305
305
|
? calibratedResults.units
|
|
306
306
|
: 'raw';
|
|
307
307
|
}
|
|
308
308
|
else {
|
|
309
|
-
|
|
309
|
+
pixelValueUnits = getPixelValueUnits(modality, annotation.metadata.referencedImageId, pixelUnitsOptions);
|
|
310
310
|
}
|
|
311
311
|
cachedStats[targetId] = {
|
|
312
312
|
index,
|
|
313
313
|
value,
|
|
314
314
|
Modality: modality,
|
|
315
|
-
|
|
315
|
+
pixelValueUnits,
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
318
|
else {
|
|
@@ -330,19 +330,19 @@ class ProbeTool extends AnnotationTool {
|
|
|
330
330
|
}
|
|
331
331
|
function defaultGetTextLines(data, targetId) {
|
|
332
332
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
333
|
-
const { index, value,
|
|
333
|
+
const { index, value, pixelValueUnits } = cachedVolumeStats;
|
|
334
334
|
if (value === undefined) {
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
const textLines = [];
|
|
338
338
|
textLines.push(`(${index[0]}, ${index[1]}, ${index[2]})`);
|
|
339
|
-
if (value instanceof Array &&
|
|
339
|
+
if (value instanceof Array && pixelValueUnits instanceof Array) {
|
|
340
340
|
for (let i = 0; i < value.length; i++) {
|
|
341
|
-
textLines.push(`${roundNumber(value[i])} ${
|
|
341
|
+
textLines.push(`${roundNumber(value[i])} ${pixelValueUnits[i]}`);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
else {
|
|
345
|
-
textLines.push(`${roundNumber(value)} ${
|
|
345
|
+
textLines.push(`${roundNumber(value)} ${pixelValueUnits}`);
|
|
346
346
|
}
|
|
347
347
|
return textLines;
|
|
348
348
|
}
|
|
@@ -16,7 +16,7 @@ import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
|
16
16
|
import getWorldWidthAndHeightFromCorners from '../../utilities/planar/getWorldWidthAndHeightFromCorners';
|
|
17
17
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
18
18
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
19
|
-
import {
|
|
19
|
+
import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
|
|
20
20
|
import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
|
|
21
21
|
import { pointInShapeCallback } from '../../utilities/';
|
|
22
22
|
import { BasicStatsCalculator } from '../../utilities/math/basic';
|
|
@@ -347,14 +347,14 @@ class RectangleROITool extends AnnotationTool {
|
|
|
347
347
|
});
|
|
348
348
|
const { viewPlaneNormal, viewUp } = viewport.getCamera();
|
|
349
349
|
if (!data.cachedStats[targetId] ||
|
|
350
|
-
data.cachedStats[targetId].
|
|
350
|
+
data.cachedStats[targetId].areaUnits == null) {
|
|
351
351
|
data.cachedStats[targetId] = {
|
|
352
352
|
Modality: null,
|
|
353
353
|
area: null,
|
|
354
354
|
max: null,
|
|
355
355
|
mean: null,
|
|
356
356
|
stdDev: null,
|
|
357
|
-
|
|
357
|
+
areaUnits: null,
|
|
358
358
|
};
|
|
359
359
|
this._calculateCachedStats(annotation, viewPlaneNormal, viewUp, renderingEngine, enabledElement);
|
|
360
360
|
}
|
|
@@ -490,11 +490,11 @@ class RectangleROITool extends AnnotationTool {
|
|
|
490
490
|
const handles = [pos1Index, pos2Index];
|
|
491
491
|
const { scale, areaUnits } = getCalibratedLengthUnitsAndScale(image, handles);
|
|
492
492
|
const area = Math.abs(worldWidth * worldHeight) / (scale * scale);
|
|
493
|
-
const
|
|
493
|
+
const pixelUnitsOptions = {
|
|
494
494
|
isPreScaled: isViewportPreScaled(viewport, targetId),
|
|
495
495
|
isSuvScaled: this.isSuvScaled(viewport, targetId, annotation.metadata.referencedImageId),
|
|
496
496
|
};
|
|
497
|
-
const
|
|
497
|
+
const pixelValueUnits = getPixelValueUnits(metadata.Modality, annotation.metadata.referencedImageId, pixelUnitsOptions);
|
|
498
498
|
const pointsInShape = pointInShapeCallback(imageData, () => true, this.configuration.statsCalculator.statsCallback, boundsIJK);
|
|
499
499
|
const stats = this.configuration.statsCalculator.getStatistics();
|
|
500
500
|
cachedStats[targetId] = {
|
|
@@ -505,8 +505,8 @@ class RectangleROITool extends AnnotationTool {
|
|
|
505
505
|
max: stats.max?.value,
|
|
506
506
|
statsArray: stats.array,
|
|
507
507
|
pointsInShape: pointsInShape,
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
areaUnits,
|
|
509
|
+
pixelValueUnits,
|
|
510
510
|
};
|
|
511
511
|
}
|
|
512
512
|
else {
|
|
@@ -529,15 +529,15 @@ class RectangleROITool extends AnnotationTool {
|
|
|
529
529
|
}
|
|
530
530
|
function defaultGetTextLines(data, targetId) {
|
|
531
531
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
532
|
-
const { area, mean, max, stdDev,
|
|
532
|
+
const { area, mean, max, stdDev, areaUnits, pixelValueUnits } = cachedVolumeStats;
|
|
533
533
|
if (mean === undefined) {
|
|
534
534
|
return;
|
|
535
535
|
}
|
|
536
536
|
const textLines = [];
|
|
537
|
-
textLines.push(`Area: ${roundNumber(area)} ${
|
|
538
|
-
textLines.push(`Mean: ${roundNumber(mean)} ${
|
|
539
|
-
textLines.push(`Max: ${roundNumber(max)} ${
|
|
540
|
-
textLines.push(`Std Dev: ${roundNumber(stdDev)} ${
|
|
537
|
+
textLines.push(`Area: ${roundNumber(area)} ${areaUnits}`);
|
|
538
|
+
textLines.push(`Mean: ${roundNumber(mean)} ${pixelValueUnits}`);
|
|
539
|
+
textLines.push(`Max: ${roundNumber(max)} ${pixelValueUnits}`);
|
|
540
|
+
textLines.push(`Std Dev: ${roundNumber(stdDev)} ${pixelValueUnits}`);
|
|
541
541
|
return textLines;
|
|
542
542
|
}
|
|
543
543
|
RectangleROITool.toolName = 'RectangleROI';
|
|
@@ -468,7 +468,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
468
468
|
cachedStats[targetId] = {
|
|
469
469
|
Modality: metadata.Modality,
|
|
470
470
|
area,
|
|
471
|
-
|
|
471
|
+
areaUnits,
|
|
472
472
|
};
|
|
473
473
|
}
|
|
474
474
|
this.triggerAnnotationModified(annotation, enabledElement, ChangeTypes.StatsUpdated);
|
|
@@ -557,11 +557,11 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
557
557
|
});
|
|
558
558
|
super.renderAnnotationInstance(renderContext);
|
|
559
559
|
if (!data.cachedStats[targetId] ||
|
|
560
|
-
data.cachedStats[targetId].
|
|
560
|
+
data.cachedStats[targetId].areaUnits == null) {
|
|
561
561
|
data.cachedStats[targetId] = {
|
|
562
562
|
Modality: null,
|
|
563
563
|
area: null,
|
|
564
|
-
|
|
564
|
+
areaUnits: null,
|
|
565
565
|
};
|
|
566
566
|
this._calculateCachedStats(annotation, element);
|
|
567
567
|
}
|
|
@@ -712,12 +712,12 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
712
712
|
}
|
|
713
713
|
function defaultGetTextLines(data, targetId) {
|
|
714
714
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
715
|
-
const { area, isEmptyArea,
|
|
715
|
+
const { area, isEmptyArea, areaUnits } = cachedVolumeStats;
|
|
716
716
|
const textLines = [];
|
|
717
717
|
if (area) {
|
|
718
718
|
const areaLine = isEmptyArea
|
|
719
719
|
? `Area: Oblique not supported`
|
|
720
|
-
: `Area: ${roundNumber(area)} ${
|
|
720
|
+
: `Area: ${roundNumber(area)} ${areaUnits}`;
|
|
721
721
|
textLines.push(areaLine);
|
|
722
722
|
}
|
|
723
723
|
return textLines;
|
|
@@ -13,6 +13,5 @@ declare abstract class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
13
13
|
}): any;
|
|
14
14
|
protected renderAnnotationInstance(renderContext: AnnotationRenderContext): boolean;
|
|
15
15
|
private _getContourSegmentationStyle;
|
|
16
|
-
private _getSegmentationRepresentation;
|
|
17
16
|
}
|
|
18
17
|
export { ContourSegmentationBaseTool as default, ContourSegmentationBaseTool };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { utilities } from '@cornerstonejs/core';
|
|
1
|
+
import { getEnabledElement, utilities } from '@cornerstonejs/core';
|
|
2
2
|
import { config as segmentationConfig, state as segmentationState, segmentLocking, segmentIndex as segmentIndexController, activeSegmentation, } from '../../stateManagement/segmentation';
|
|
3
3
|
import { SegmentationRepresentations } from '../../enums';
|
|
4
4
|
import ContourBaseTool from './ContourBaseTool';
|
|
5
5
|
import { triggerSegmentationDataModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
|
|
6
6
|
import { InterpolationManager } from '../../utilities/contours/interpolation';
|
|
7
7
|
import { addContourSegmentationAnnotation, removeContourSegmentationAnnotation, } from '../../utilities/contourSegmentation';
|
|
8
|
-
import { getToolGroupIdsWithSegmentation } from '../../stateManagement/segmentation/segmentationState';
|
|
9
8
|
import { triggerAnnotationRenderForToolGroupIds } from '../../utilities';
|
|
9
|
+
import { getActiveRepresentation, getRepresentationsBySegmentationId, getRepresentationsForViewport, getViewportIdsWithSegmentationId, } from '../../stateManagement/segmentation/segmentationState';
|
|
10
|
+
import { getToolGroupForViewport } from '../../store/ToolGroupManager';
|
|
10
11
|
class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
11
12
|
constructor(toolProps, defaultToolProps) {
|
|
12
13
|
super(toolProps, defaultToolProps);
|
|
@@ -18,20 +19,26 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
18
19
|
return true;
|
|
19
20
|
}
|
|
20
21
|
createAnnotation(evt) {
|
|
21
|
-
const
|
|
22
|
+
const eventDetail = evt.detail;
|
|
23
|
+
const { element } = eventDetail;
|
|
24
|
+
const enabledElement = getEnabledElement(element);
|
|
25
|
+
if (!enabledElement) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const { viewport } = enabledElement;
|
|
22
29
|
const contourAnnotation = super.createAnnotation(evt);
|
|
23
30
|
if (!this.isContourSegmentationTool()) {
|
|
24
31
|
return contourAnnotation;
|
|
25
32
|
}
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
33
|
+
const activeSeg = activeSegmentation.getActiveRepresentation(viewport.id);
|
|
34
|
+
if (!activeSeg) {
|
|
28
35
|
throw new Error('No active segmentation detected, create one before using scissors tool');
|
|
29
36
|
}
|
|
30
|
-
const { type: segmentationType } =
|
|
37
|
+
const { type: segmentationType } = activeSeg;
|
|
31
38
|
if (segmentationType !== SegmentationRepresentations.Contour) {
|
|
32
39
|
throw new Error(`A contour segmentation must be active`);
|
|
33
40
|
}
|
|
34
|
-
const { segmentationId } =
|
|
41
|
+
const { segmentationId } = activeSeg;
|
|
35
42
|
const segmentIndex = segmentIndexController.getActiveSegmentIndex(segmentationId);
|
|
36
43
|
return utilities.deepMerge(contourAnnotation, {
|
|
37
44
|
data: {
|
|
@@ -71,33 +78,48 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
71
78
|
if (invalidated && this.isContourSegmentationTool()) {
|
|
72
79
|
const { segmentationId } = (annotation).data.segmentation;
|
|
73
80
|
triggerSegmentationDataModified(segmentationId);
|
|
74
|
-
const
|
|
81
|
+
const viewportIds = getViewportIdsWithSegmentationId(segmentationId);
|
|
82
|
+
const toolGroupIds = viewportIds.map((viewportId) => {
|
|
83
|
+
const toolGroup = getToolGroupForViewport(viewportId);
|
|
84
|
+
return toolGroup.id;
|
|
85
|
+
});
|
|
75
86
|
triggerAnnotationRenderForToolGroupIds(toolGroupIds);
|
|
76
87
|
}
|
|
77
88
|
return renderResult;
|
|
78
89
|
}
|
|
79
90
|
_getContourSegmentationStyle(context) {
|
|
80
|
-
const { toolGroupId } = this;
|
|
81
91
|
const annotation = context.annotation;
|
|
82
92
|
const { segmentationId, segmentIndex } = annotation.data.segmentation;
|
|
83
93
|
const segmentation = segmentationState.getSegmentation(segmentationId);
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
94
|
+
const segmentationRepresentations = getRepresentationsBySegmentationId(segmentationId);
|
|
95
|
+
if (!segmentationRepresentations?.length) {
|
|
86
96
|
return {};
|
|
87
97
|
}
|
|
98
|
+
const allUIDs = segmentationRepresentations.map((rep) => rep.segmentationRepresentationUID);
|
|
99
|
+
let segmentationRepresentation;
|
|
100
|
+
if (segmentationRepresentations.length > 1) {
|
|
101
|
+
const viewportReps = getRepresentationsForViewport(context.styleSpecifier.viewportId);
|
|
102
|
+
segmentationRepresentation = viewportReps.find((rep) => rep.segmentationId === segmentationId &&
|
|
103
|
+
allUIDs.includes(rep.segmentationRepresentationUID));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
segmentationRepresentation = segmentationRepresentations[0];
|
|
107
|
+
}
|
|
88
108
|
const { segmentationRepresentationUID } = segmentationRepresentation;
|
|
89
|
-
const { active } = segmentationRepresentation;
|
|
90
109
|
const { autoGenerated } = annotation;
|
|
91
110
|
const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
|
|
92
111
|
const annotationLocked = segmentsLocked.includes(segmentIndex);
|
|
93
|
-
const segmentColor = segmentationConfig.color.
|
|
94
|
-
const
|
|
112
|
+
const segmentColor = segmentationConfig.color.getSegmentIndexColor(segmentationRepresentationUID, segmentIndex);
|
|
113
|
+
const viewportId = context.styleSpecifier.viewportId;
|
|
114
|
+
const segmentationVisible = segmentationConfig.visibility.getRepresentationVisibility(viewportId, segmentationRepresentationUID);
|
|
95
115
|
const globalConfig = segmentationConfig.getGlobalConfig();
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const
|
|
116
|
+
const getAllSegmentsConfig = segmentationConfig.getAllSegmentsConfig(segmentationRepresentationUID);
|
|
117
|
+
const segmentConfig = segmentationConfig.getSegmentIndexConfig(segmentationRepresentationUID, segmentIndex);
|
|
118
|
+
const segmentVisible = segmentationConfig.visibility.getSegmentIndexVisibility(viewportId, segmentationRepresentationUID, segmentIndex);
|
|
119
|
+
const activeSegRep = getActiveRepresentation(viewportId);
|
|
120
|
+
const isActive = activeSegRep.segmentationRepresentationUID ===
|
|
121
|
+
segmentationRepresentationUID;
|
|
122
|
+
const mergedConfig = Object.assign({}, globalConfig?.representations?.CONTOUR ?? {}, getAllSegmentsConfig?.CONTOUR ?? {}, segmentConfig?.CONTOUR ?? {});
|
|
101
123
|
let lineWidth = 1;
|
|
102
124
|
let lineDash = undefined;
|
|
103
125
|
let lineOpacity = 1;
|
|
@@ -108,7 +130,7 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
108
130
|
lineOpacity = mergedConfig.outlineOpacity ?? lineOpacity;
|
|
109
131
|
fillOpacity = mergedConfig.fillAlphaAutoGenerated ?? fillOpacity;
|
|
110
132
|
}
|
|
111
|
-
else if (
|
|
133
|
+
else if (isActive) {
|
|
112
134
|
lineWidth = mergedConfig.outlineWidthActive ?? lineWidth;
|
|
113
135
|
lineDash = mergedConfig.outlineDashActive ?? lineDash;
|
|
114
136
|
lineOpacity = mergedConfig.outlineOpacity ?? lineOpacity;
|
|
@@ -140,18 +162,5 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
140
162
|
locked: annotationLocked,
|
|
141
163
|
};
|
|
142
164
|
}
|
|
143
|
-
_getSegmentationRepresentation(segmentationId) {
|
|
144
|
-
const segmentationRepresentations = segmentationState.getSegmentationRepresentations(this.toolGroupId);
|
|
145
|
-
const validSegmentationRepresentations = segmentationRepresentations.filter((representation) => representation.segmentationId === segmentationId);
|
|
146
|
-
if (!validSegmentationRepresentations) {
|
|
147
|
-
console.warn(`No segmentation representation found for toolGroupId: ${this.toolGroupId}`);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (segmentationState.getSegmentationRepresentations(this.toolGroupId)
|
|
151
|
-
.length > 1) {
|
|
152
|
-
console.warn('Multiple segmentation representations detected for this tool group. The first one will be used.');
|
|
153
|
-
}
|
|
154
|
-
return validSegmentationRepresentations[0];
|
|
155
|
-
}
|
|
156
165
|
}
|
|
157
166
|
export { ContourSegmentationBaseTool as default, ContourSegmentationBaseTool };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StackViewport, Types } from '@cornerstonejs/core';
|
|
2
|
-
import {
|
|
3
|
-
declare function
|
|
4
|
-
declare function render(viewport: StackViewport | Types.IVolumeViewport,
|
|
2
|
+
import { ContourRepresentation } from '../../../types/SegmentationStateTypes';
|
|
3
|
+
declare function removeRepresentation(viewportId: string, segmentationRepresentationUID: string, renderImmediate?: boolean): void;
|
|
4
|
+
declare function render(viewport: StackViewport | Types.IVolumeViewport, contourRepresentation: ContourRepresentation): Promise<void>;
|
|
5
5
|
declare const _default: {
|
|
6
6
|
render: typeof render;
|
|
7
|
-
|
|
7
|
+
removeRepresentation: typeof removeRepresentation;
|
|
8
8
|
};
|
|
9
9
|
export default _default;
|
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
2
2
|
import Representations from '../../../enums/SegmentationRepresentations';
|
|
3
3
|
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
4
|
-
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
5
|
-
import removeContourFromElement from './removeContourFromElement';
|
|
6
4
|
import { deleteConfigCache } from './contourHandler/contourConfigCache';
|
|
7
5
|
import { polySeg } from '../../../stateManagement/segmentation';
|
|
8
6
|
import { handleContourSegmentation } from './contourHandler/handleContourSegmentation';
|
|
9
7
|
let polySegConversionInProgress = false;
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
function removeRepresentation(viewportId, segmentationRepresentationUID, renderImmediate = false) {
|
|
9
|
+
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
10
|
+
if (!enabledElement) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const { viewport } = enabledElement;
|
|
14
|
+
SegmentationState.removeRepresentation(segmentationRepresentationUID);
|
|
13
15
|
deleteConfigCache(segmentationRepresentationUID);
|
|
14
|
-
if (renderImmediate) {
|
|
15
|
-
|
|
16
|
-
viewportsInfo.forEach(({ viewportId, renderingEngineId }) => {
|
|
17
|
-
const enabledElement = getEnabledElementByIds(viewportId, renderingEngineId);
|
|
18
|
-
enabledElement.viewport.render();
|
|
19
|
-
});
|
|
16
|
+
if (!renderImmediate) {
|
|
17
|
+
return;
|
|
20
18
|
}
|
|
19
|
+
viewport.render();
|
|
21
20
|
}
|
|
22
|
-
async function render(viewport,
|
|
23
|
-
const { segmentationId } =
|
|
21
|
+
async function render(viewport, contourRepresentation) {
|
|
22
|
+
const { segmentationId } = contourRepresentation;
|
|
24
23
|
const segmentation = SegmentationState.getSegmentation(segmentationId);
|
|
25
24
|
if (!segmentation) {
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
27
|
let contourData = segmentation.representationData[Representations.Contour];
|
|
29
28
|
if (!contourData &&
|
|
30
|
-
polySeg.canComputeRequestedRepresentation(
|
|
29
|
+
polySeg.canComputeRequestedRepresentation(contourRepresentation.segmentationRepresentationUID) &&
|
|
31
30
|
!polySegConversionInProgress) {
|
|
32
31
|
polySegConversionInProgress = true;
|
|
33
32
|
contourData = await polySeg.computeAndAddContourRepresentation(segmentationId, {
|
|
34
|
-
segmentationRepresentationUID:
|
|
33
|
+
segmentationRepresentationUID: contourRepresentation.segmentationRepresentationUID,
|
|
35
34
|
viewport,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
@@ -39,22 +38,10 @@ async function render(viewport, representationConfig, toolGroupConfig) {
|
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
41
40
|
if (contourData?.geometryIds?.length) {
|
|
42
|
-
handleContourSegmentation(viewport, contourData.geometryIds, contourData.annotationUIDsMap,
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function _removeContourFromToolGroupViewports(toolGroupId, segmentationRepresentationUID) {
|
|
46
|
-
const toolGroup = getToolGroup(toolGroupId);
|
|
47
|
-
if (toolGroup === undefined) {
|
|
48
|
-
throw new Error(`ToolGroup with ToolGroupId ${toolGroupId} does not exist`);
|
|
49
|
-
}
|
|
50
|
-
const { viewportsInfo } = toolGroup;
|
|
51
|
-
for (const viewportInfo of viewportsInfo) {
|
|
52
|
-
const { viewportId, renderingEngineId } = viewportInfo;
|
|
53
|
-
const enabledElement = getEnabledElementByIds(viewportId, renderingEngineId);
|
|
54
|
-
removeContourFromElement(segmentationRepresentationUID, toolGroupId);
|
|
41
|
+
handleContourSegmentation(viewport, contourData.geometryIds, contourData.annotationUIDsMap, contourRepresentation);
|
|
55
42
|
}
|
|
56
43
|
}
|
|
57
44
|
export default {
|
|
58
45
|
render,
|
|
59
|
-
|
|
46
|
+
removeRepresentation,
|
|
60
47
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Types, StackViewport } from '@cornerstonejs/core';
|
|
2
|
-
import {
|
|
3
|
-
declare function handleContourSegmentation(viewport: StackViewport | Types.IVolumeViewport, geometryIds: string[], annotationUIDsMap: Map<number, Set<string>>, contourRepresentation:
|
|
4
|
-
declare function updateContourSets(viewport: Types.IVolumeViewport | StackViewport, geometryIds: string[], contourRepresentation:
|
|
5
|
-
declare function addContourSetsToElement(viewport: StackViewport | Types.IVolumeViewport, geometryIds: string[], contourRepresentation:
|
|
2
|
+
import { ContourRepresentation } from '../../../../types/SegmentationStateTypes';
|
|
3
|
+
declare function handleContourSegmentation(viewport: StackViewport | Types.IVolumeViewport, geometryIds: string[], annotationUIDsMap: Map<number, Set<string>>, contourRepresentation: ContourRepresentation): void;
|
|
4
|
+
declare function updateContourSets(viewport: Types.IVolumeViewport | StackViewport, geometryIds: string[], contourRepresentation: ContourRepresentation): void;
|
|
5
|
+
declare function addContourSetsToElement(viewport: StackViewport | Types.IVolumeViewport, geometryIds: string[], contourRepresentation: ContourRepresentation): void;
|
|
6
6
|
export { handleContourSegmentation, updateContourSets, addContourSetsToElement, };
|