@cornerstonejs/tools 5.8.1 → 5.10.2
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/config.js +3 -1
- package/dist/esm/cursors/setCursorForElement.js +3 -1
- package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDownActivate.js +3 -1
- package/dist/esm/eventDispatchers/touchEventHandlers/touchStartActivate.js +3 -1
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +3 -1
- package/dist/esm/stateManagement/annotation/AnnotationRenderingEngine.js +3 -1
- package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +4 -2
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +9 -3
- package/dist/esm/stateManagement/segmentation/addColorLUT.js +3 -1
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +3 -1
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +2 -0
- package/dist/esm/stateManagement/segmentation/internalAddRepresentationData.js +3 -1
- package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -1
- package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +3 -1
- package/dist/esm/stateManagement/segmentation/segmentIndex.js +3 -1
- package/dist/esm/stateManagement/segmentation/utilities/convertContourHoles.js +9 -7
- package/dist/esm/stateManagement/segmentation/utilities/decimateContours.js +6 -4
- package/dist/esm/stateManagement/segmentation/utilities/getPolylineMap.js +3 -1
- package/dist/esm/stateManagement/segmentation/utilities/removeContourHoles.js +5 -3
- package/dist/esm/stateManagement/segmentation/utilities/removeContourIslands.js +5 -3
- package/dist/esm/stateManagement/segmentation/utilities/smoothContours.js +6 -4
- package/dist/esm/store/SynchronizerManager/Synchronizer.js +4 -2
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +17 -15
- package/dist/esm/store/ToolGroupManager/createToolGroup.js +3 -1
- package/dist/esm/store/filterToolsWithAnnotationsForElement.js +3 -1
- package/dist/esm/tools/AdvancedMagnifyTool.js +3 -1
- package/dist/esm/tools/CrosshairsTool.js +4 -2
- package/dist/esm/tools/MIPJumpToClickTool.js +3 -1
- package/dist/esm/tools/OrientationControllerTool.js +6 -4
- package/dist/esm/tools/OverlayGridTool.js +5 -3
- package/dist/esm/tools/ReferenceCursors.js +3 -1
- package/dist/esm/tools/ReferenceLinesTool.js +3 -1
- package/dist/esm/tools/SculptorTool.js +7 -5
- package/dist/esm/tools/SegmentationIntersectionTool.js +3 -1
- package/dist/esm/tools/VolumeCroppingControlTool.js +5 -3
- package/dist/esm/tools/VolumeCroppingTool.js +5 -3
- package/dist/esm/tools/WindowLevelRegionTool.js +3 -1
- package/dist/esm/tools/annotation/AngleTool.js +3 -1
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +3 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +3 -1
- package/dist/esm/tools/annotation/CircleROITool.js +30 -33
- package/dist/esm/tools/annotation/CobbAngleTool.js +3 -1
- package/dist/esm/tools/annotation/DragProbeTool.js +3 -1
- package/dist/esm/tools/annotation/ETDRSGridTool.js +3 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +35 -38
- package/dist/esm/tools/annotation/HeightTool.js +3 -1
- package/dist/esm/tools/annotation/KeyImageTool.js +3 -1
- package/dist/esm/tools/annotation/LabelTool.js +3 -1
- package/dist/esm/tools/annotation/LengthTool.js +4 -2
- package/dist/esm/tools/annotation/LivewireContourTool.js +3 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +13 -2
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +28 -81
- package/dist/esm/tools/annotation/ProbeTool.js +3 -1
- package/dist/esm/tools/annotation/RectangleROITool.js +31 -20
- package/dist/esm/tools/annotation/SplineROITool.js +3 -1
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +3 -1
- package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +5 -3
- package/dist/esm/tools/annotation/VideoRedactionTool.js +3 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +3 -1
- package/dist/esm/tools/base/AnnotationTool.js +3 -1
- package/dist/esm/tools/base/ContourBaseTool.js +3 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +4 -2
- package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +3 -1
- package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +3 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +4 -2
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +4 -2
- package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +3 -1
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +6 -4
- package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +3 -1
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +3 -1
- package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -1
- package/dist/esm/tools/segmentation/PaintFillTool.js +3 -1
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +3 -1
- package/dist/esm/tools/segmentation/RectangleROIThresholdTool.js +3 -1
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +3 -1
- package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +3 -1
- package/dist/esm/tools/segmentation/SegmentSelectTool.d.ts +6 -1
- package/dist/esm/tools/segmentation/SegmentSelectTool.js +30 -4
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +3 -1
- package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +3 -1
- package/dist/esm/tools/segmentation/strategies/compositions/index.js +1 -1
- package/dist/esm/types/SegmentationStateTypes.d.ts +4 -0
- package/dist/esm/utilities/calibrateImageSpacing.js +3 -1
- package/dist/esm/utilities/cine/playClip.js +3 -1
- package/dist/esm/utilities/contourSegmentation/applyContourStroke.js +3 -1
- package/dist/esm/utilities/contourSegmentation/contourSegmentationOperation.js +4 -2
- package/dist/esm/utilities/contourSegmentation/convertContourSegmentation.js +3 -1
- package/dist/esm/utilities/contourSegmentation/logicalOperators.js +6 -4
- package/dist/esm/utilities/contourSegmentation/mergeMultipleAnnotations.js +3 -1
- package/dist/esm/utilities/contourSegmentation/sharedOperations.js +3 -1
- package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +3 -1
- package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js +3 -1
- package/dist/esm/utilities/contours/interpolation/interpolate.js +3 -1
- package/dist/esm/utilities/dynamicVolume/generateImageFromTimeData.js +4 -2
- package/dist/esm/utilities/dynamicVolume/getDataInTime.js +3 -1
- package/dist/esm/utilities/index.d.ts +2 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/livewire/LivewireScissors.js +3 -1
- package/dist/esm/utilities/math/basic/Calculator.js +3 -1
- package/dist/esm/utilities/math/polyline/addCanvasPointsToArray.js +3 -1
- package/dist/esm/utilities/math/polyline/combinePolyline.js +4 -2
- package/dist/esm/utilities/math/polyline/getSubPixelSpacingAndXYDirections.js +12 -6
- package/dist/esm/utilities/math/polyline/intersectPolylines.js +4 -2
- package/dist/esm/utilities/math/polyline/subtractPolylines.js +4 -2
- package/dist/esm/utilities/sampleAreaAnnotationVoxels.d.ts +44 -0
- package/dist/esm/utilities/sampleAreaAnnotationVoxels.js +63 -0
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +5 -3
- package/dist/esm/utilities/segmentation/growCut/runFloodFillSegmentation.js +10 -5
- package/dist/esm/utilities/segmentation/growCut/runGrowCut.js +3 -1
- package/dist/esm/utilities/segmentation/growCut/runGrowCutForSphere.js +3 -1
- package/dist/esm/utilities/segmentation/growCut/runOneClickGrowCut.js +10 -8
- package/dist/esm/utilities/segmentation/isLineInSegment.js +3 -1
- package/dist/esm/utilities/segmentation/islandRemoval.js +3 -1
- package/dist/esm/utilities/segmentation/segmentContourAction.js +4 -2
- package/dist/esm/utilities/segmentation/utilsForWorker.js +4 -2
- package/dist/esm/utilities/spatial/areViewportsSpatiallyLinked.js +2 -1
- package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js +5 -3
- package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +4 -2
- package/dist/esm/utilities/triggerAnnotationRenderForToolGroupIds.js +4 -2
- package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +4 -2
- package/dist/esm/utilities/voi/colorbar/Colorbar.js +3 -1
- package/dist/esm/utilities/voi/windowlevel/extractWindowLevelRegionToolData.js +3 -1
- package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.js +4 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/workers/computeWorker.js +5 -3
- package/package.json +4 -5
- package/LICENSE +0 -21
package/dist/esm/config.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { eventTarget, triggerEvent } from '@cornerstonejs/core';
|
|
2
2
|
import Events from './enums/Events.js';
|
|
3
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
4
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('config');
|
|
3
5
|
let config = {};
|
|
4
6
|
export function getConfig() {
|
|
5
7
|
return config;
|
|
@@ -13,7 +15,7 @@ export function getAddOns() {
|
|
|
13
15
|
let polysegInitialized = false;
|
|
14
16
|
export function getPolySeg() {
|
|
15
17
|
if (!config.addons?.polySeg) {
|
|
16
|
-
|
|
18
|
+
cs3dLogger.warn('PolySeg add-on not configured. This will prevent automatic conversion between segmentation representations (labelmap, contour, surface). To enable these features, install @cornerstonejs/polymorphic-segmentation and register it during initialization: cornerstoneTools.init({ addons: { polySeg } }).');
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
21
|
const polyseg = config.addons.polySeg;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { setElementCursor } from './elementCursor.js';
|
|
2
2
|
import MouseCursor from './MouseCursor.js';
|
|
3
3
|
import SVGMouseCursor from './SVGMouseCursor.js';
|
|
4
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
5
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('cursors.setCursorForElement');
|
|
4
6
|
function setCursorForElement(element, cursorName) {
|
|
5
7
|
let cursor = SVGMouseCursor.getDefinedCursor(cursorName, true);
|
|
6
8
|
if (!cursor) {
|
|
7
9
|
cursor = MouseCursor.getDefinedCursor(cursorName);
|
|
8
10
|
}
|
|
9
11
|
if (!cursor) {
|
|
10
|
-
|
|
12
|
+
cs3dLogger.info(`Cursor ${cursorName} is not defined either as SVG or as a standard cursor.`);
|
|
11
13
|
cursor = MouseCursor.getDefinedCursor(cursorName);
|
|
12
14
|
}
|
|
13
15
|
setElementCursor(element, cursor);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { state } from '../../store/state.js';
|
|
2
2
|
import getActiveToolForMouseEvent from '../shared/getActiveToolForMouseEvent.js';
|
|
3
3
|
import { setAnnotationSelected } from '../../stateManagement/annotation/annotationSelection.js';
|
|
4
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
5
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('eventDispatchers.mouseEventHandlers.mouseDownActivate');
|
|
4
6
|
export default function mouseDownActivate(evt) {
|
|
5
7
|
if (state.isInteractingWithTool) {
|
|
6
8
|
return;
|
|
@@ -18,7 +20,7 @@ export default function mouseDownActivate(evt) {
|
|
|
18
20
|
setAnnotationSelected(annotation.annotationUID);
|
|
19
21
|
}
|
|
20
22
|
catch (error) {
|
|
21
|
-
|
|
23
|
+
cs3dLogger.warn('Error adding new annotation, viewport not ready:', error);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { state } from '../../store/state.js';
|
|
2
2
|
import { setAnnotationSelected } from '../../stateManagement/annotation/annotationSelection.js';
|
|
3
3
|
import getActiveToolForTouchEvent from '../shared/getActiveToolForTouchEvent.js';
|
|
4
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
5
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('eventDispatchers.touchEventHandlers.touchStartActivate');
|
|
4
6
|
export default function touchStartActivate(evt) {
|
|
5
7
|
if (state.isInteractingWithTool) {
|
|
6
8
|
return;
|
|
@@ -18,7 +20,7 @@ export default function touchStartActivate(evt) {
|
|
|
18
20
|
setAnnotationSelected(annotation.annotationUID);
|
|
19
21
|
}
|
|
20
22
|
catch (error) {
|
|
21
|
-
|
|
23
|
+
cs3dLogger.warn('Error adding new annotation, viewport not ready:', error);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
}
|
package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js
CHANGED
|
@@ -4,6 +4,8 @@ import isContourSegmentationAnnotation from '../../../utilities/contourSegmentat
|
|
|
4
4
|
import { getToolGroupForViewport } from '../../../store/ToolGroupManager/index.js';
|
|
5
5
|
import { addContourStroke, removeContourStroke, } from '../../../utilities/contourSegmentation/applyContourStroke.js';
|
|
6
6
|
import { Events } from '../../../enums/index.js';
|
|
7
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
8
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('eventListeners.annotations.contourSegmentation.contourSegmentationCompleted');
|
|
7
9
|
const DEFAULT_CONTOUR_SEG_TOOL_NAME = 'PlanarFreehandContourSegmentationTool';
|
|
8
10
|
export default async function contourSegmentationCompletedListener(evt) {
|
|
9
11
|
const sourceAnnotation = evt.detail
|
|
@@ -38,7 +40,7 @@ function isFreehandContourSegToolRegisteredForViewport(viewport, silent = false)
|
|
|
38
40
|
errorMessage = `Tool ${toolName} must be in active/passive state in ${toolGroup.id} toolGroup`;
|
|
39
41
|
}
|
|
40
42
|
if (errorMessage && !silent) {
|
|
41
|
-
|
|
43
|
+
cs3dLogger.warn(errorMessage);
|
|
42
44
|
}
|
|
43
45
|
return !errorMessage;
|
|
44
46
|
}
|
|
@@ -2,6 +2,8 @@ import { getEnabledElement, triggerEvent, getRenderingEngine, } from '@cornersto
|
|
|
2
2
|
import { Events, ToolModes } from '../../enums/index.js';
|
|
3
3
|
import { draw as drawSvg } from '../../drawingSvg/index.js';
|
|
4
4
|
import getToolsWithModesForElement from '../../utilities/getToolsWithModesForElement.js';
|
|
5
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
6
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.annotation.AnnotationRenderingEngine');
|
|
5
7
|
const { Active, Passive, Enabled } = ToolModes;
|
|
6
8
|
class AnnotationRenderingEngine {
|
|
7
9
|
constructor() {
|
|
@@ -72,7 +74,7 @@ class AnnotationRenderingEngine {
|
|
|
72
74
|
}
|
|
73
75
|
const renderingEngine = getRenderingEngine(enabledElement.renderingEngineId);
|
|
74
76
|
if (!renderingEngine) {
|
|
75
|
-
|
|
77
|
+
cs3dLogger.warn('rendering Engine has been destroyed');
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
78
80
|
const enabledTools = getToolsWithModesForElement(element, [
|
|
@@ -8,6 +8,8 @@ import PlanarFreehandContourSegmentationTool from '../../tools/annotation/Planar
|
|
|
8
8
|
import { getToolGroupForViewport } from '../../store/ToolGroupManager/index.js';
|
|
9
9
|
import { addDefaultSegmentationListener } from './segmentationEventManager.js';
|
|
10
10
|
import { getSegmentationRepresentationDisplay } from './SegmentationRepresentationDisplayRegistry.js';
|
|
11
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
12
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.SegmentationRenderingEngine');
|
|
11
13
|
const planarContourToolName = PlanarFreehandContourSegmentationTool.toolName;
|
|
12
14
|
class SegmentationRenderingEngine {
|
|
13
15
|
constructor() {
|
|
@@ -104,7 +106,7 @@ class SegmentationRenderingEngine {
|
|
|
104
106
|
const segmentation = getSegmentation(representation.segmentationId);
|
|
105
107
|
const existingRepresentation = segmentation.representationData[representation.type] !== undefined;
|
|
106
108
|
if (!display) {
|
|
107
|
-
|
|
109
|
+
cs3dLogger.warn(`No display registered for segmentation representation type ${representation.type}.`);
|
|
108
110
|
return Promise.resolve({
|
|
109
111
|
segmentationId: representation.segmentationId,
|
|
110
112
|
type: representation.type,
|
|
@@ -122,7 +124,7 @@ class SegmentationRenderingEngine {
|
|
|
122
124
|
};
|
|
123
125
|
})
|
|
124
126
|
.catch((error) => {
|
|
125
|
-
|
|
127
|
+
cs3dLogger.error(error);
|
|
126
128
|
return {
|
|
127
129
|
segmentationId: representation.segmentationId,
|
|
128
130
|
type: representation.type,
|
|
@@ -7,6 +7,8 @@ import { triggerSegmentationModified, triggerSegmentationRemoved, triggerSegment
|
|
|
7
7
|
import { segmentationStyle } from './SegmentationStyle.js';
|
|
8
8
|
import { triggerSegmentationAdded } from './events/triggerSegmentationAdded.js';
|
|
9
9
|
import { ensureLabelmapState, LabelmapImageReferenceResolver, syncLegacyLabelmapData, } from './labelmapModel/index.js';
|
|
10
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
11
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.SegmentationStateManager');
|
|
10
12
|
const initialDefaultState = {
|
|
11
13
|
colorLUT: [],
|
|
12
14
|
segmentations: [],
|
|
@@ -44,10 +46,14 @@ export default class SegmentationStateManager {
|
|
|
44
46
|
this.updateState((draftState) => {
|
|
45
47
|
const segmentation = draftState.segmentations.find((segmentation) => segmentation.segmentationId === segmentationId);
|
|
46
48
|
if (!segmentation) {
|
|
47
|
-
|
|
49
|
+
cs3dLogger.warn(`Segmentation with id ${segmentationId} not found. Update aborted.`);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
Object.assign(segmentation, payload);
|
|
53
|
+
if (payload.label !== undefined &&
|
|
54
|
+
payload.labelIsGenerated === undefined) {
|
|
55
|
+
segmentation.labelIsGenerated = false;
|
|
56
|
+
}
|
|
51
57
|
if (segmentation.representationData?.Labelmap) {
|
|
52
58
|
ensureLabelmapState(segmentation);
|
|
53
59
|
syncLegacyLabelmapData(segmentation);
|
|
@@ -93,7 +99,7 @@ export default class SegmentationStateManager {
|
|
|
93
99
|
segmentationId,
|
|
94
100
|
});
|
|
95
101
|
if (existingRepresentations.length > 0) {
|
|
96
|
-
|
|
102
|
+
cs3dLogger.debug('A segmentation representation of type', type, 'already exists in viewport', viewportId, 'for segmentation', segmentationId);
|
|
97
103
|
triggerSegmentationRepresentationModified(viewportId, segmentationId, type);
|
|
98
104
|
return;
|
|
99
105
|
}
|
|
@@ -325,7 +331,7 @@ export default class SegmentationStateManager {
|
|
|
325
331
|
addColorLUT(colorLUT, lutIndex) {
|
|
326
332
|
this.updateState((state) => {
|
|
327
333
|
if (state.colorLUT[lutIndex]) {
|
|
328
|
-
|
|
334
|
+
cs3dLogger.warn('Color LUT table already exists, overwriting');
|
|
329
335
|
}
|
|
330
336
|
state.colorLUT[lutIndex] = csUtils.deepClone(colorLUT);
|
|
331
337
|
});
|
|
@@ -2,6 +2,8 @@ import { utilities } from '@cornerstonejs/core';
|
|
|
2
2
|
import { defaultSegmentationStateManager } from './SegmentationStateManager.js';
|
|
3
3
|
import { getNextColorLUTIndex } from './getNextColorLUTIndex.js';
|
|
4
4
|
import CORNERSTONE_COLOR_LUT from '../../constants/COLOR_LUT.js';
|
|
5
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
6
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.addColorLUT');
|
|
5
7
|
const PREVIEW_COLOR_INDEX = 255;
|
|
6
8
|
const MINIMUM_COLOR_LUT_ENTRIES = PREVIEW_COLOR_INDEX + 1;
|
|
7
9
|
export function addColorLUT(colorLUT, index) {
|
|
@@ -9,7 +11,7 @@ export function addColorLUT(colorLUT, index) {
|
|
|
9
11
|
const indexToUse = index ?? getNextColorLUTIndex();
|
|
10
12
|
let colorLUTToUse = [...colorLUT];
|
|
11
13
|
if (!utilities.isEqual(colorLUTToUse[0], [0, 0, 0, 0])) {
|
|
12
|
-
|
|
14
|
+
cs3dLogger.warn('addColorLUT: [0, 0, 0, 0] color is not provided for the background color (segmentIndex =0), automatically adding it');
|
|
13
15
|
colorLUTToUse = [[0, 0, 0, 0], ...colorLUTToUse];
|
|
14
16
|
}
|
|
15
17
|
colorLUTToUse = colorLUTToUse.map((color) => {
|
|
@@ -2,6 +2,8 @@ import { addColorLUT as _addColorLUT } from '../addColorLUT.js';
|
|
|
2
2
|
import { getColorLUT as _getColorLUT } from '../getColorLUT.js';
|
|
3
3
|
import { getSegmentationRepresentations } from '../getSegmentationRepresentation.js';
|
|
4
4
|
import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents.js';
|
|
5
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
6
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.config.segmentationColor');
|
|
5
7
|
function addColorLUT(colorLUT, colorLUTIndex) {
|
|
6
8
|
if (!colorLUT) {
|
|
7
9
|
throw new Error('addColorLUT: colorLUT is required');
|
|
@@ -34,7 +36,7 @@ function getSegmentIndexColor(viewportId, segmentationId, segmentIndex) {
|
|
|
34
36
|
let colorValue = colorLUT[segmentIndex];
|
|
35
37
|
if (!colorValue) {
|
|
36
38
|
if (typeof segmentIndex !== 'number') {
|
|
37
|
-
|
|
39
|
+
cs3dLogger.warn(`Can't create colour for LUT index ${segmentIndex}`);
|
|
38
40
|
return null;
|
|
39
41
|
}
|
|
40
42
|
colorValue = colorLUT[segmentIndex] = [0, 0, 0, 0];
|
|
@@ -17,6 +17,8 @@ function normalizeSegmentationInput(segmentationInput) {
|
|
|
17
17
|
segmentationId,
|
|
18
18
|
label: config?.label ?? null,
|
|
19
19
|
fallbackLabel: config?.fallbackLabel ?? null,
|
|
20
|
+
labelIsGenerated: config?.labelIsGenerated ?? !config?.label,
|
|
21
|
+
predecessorImageId: config?.predecessorImageId,
|
|
20
22
|
cachedStats: config?.cachedStats ?? {},
|
|
21
23
|
segments: normalizedSegments,
|
|
22
24
|
segmentOrder: config?.segmentOrder ??
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { getSegmentation } from './getSegmentation.js';
|
|
2
2
|
import SegmentationRepresentations from '../../enums/SegmentationRepresentations.js';
|
|
3
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
4
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.internalAddRepresentationData');
|
|
3
5
|
function internalAddRepresentationData({ segmentationId, type, data, }) {
|
|
4
6
|
const segmentation = getSegmentation(segmentationId);
|
|
5
7
|
if (!segmentation) {
|
|
6
8
|
throw new Error(`Segmentation ${segmentationId} not found`);
|
|
7
9
|
}
|
|
8
10
|
if (segmentation.representationData[type]) {
|
|
9
|
-
|
|
11
|
+
cs3dLogger.warn(`Representation data of type ${type} already exists for segmentation ${segmentationId}, overwriting it.`);
|
|
10
12
|
}
|
|
11
13
|
switch (type) {
|
|
12
14
|
case SegmentationRepresentations.Labelmap:
|
|
@@ -8,10 +8,12 @@ import { defaultSegmentationStateManager } from './SegmentationStateManager.js';
|
|
|
8
8
|
import { isSegmentationOverlayCompatible } from './helpers/isSegmentationOverlayCompatible.js';
|
|
9
9
|
import { addDefaultSegmentationListener } from './segmentationEventManager.js';
|
|
10
10
|
import { getActiveSegmentIndex, setActiveSegmentIndex } from './segmentIndex.js';
|
|
11
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
12
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.internalAddSegmentationRepresentation');
|
|
11
13
|
function internalAddSegmentationRepresentation(viewportId, representationInput) {
|
|
12
14
|
const { segmentationId, config } = representationInput;
|
|
13
15
|
if (!isSegmentationOverlayCompatible(getEnabledElementByViewportId(viewportId)?.viewport, segmentationId, representationInput.type)) {
|
|
14
|
-
|
|
16
|
+
cs3dLogger.warn(`Skipping ${representationInput.type} representation of segmentation "${segmentationId}" on viewport "${viewportId}": the viewport is not a compatible destination for it.`);
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
19
|
const renderingConfig = {
|
|
@@ -4,6 +4,8 @@ import { getEnabledElementByViewportId } from '@cornerstonejs/core';
|
|
|
4
4
|
import { defaultSegmentationStateManager } from './SegmentationStateManager.js';
|
|
5
5
|
import { removeSegmentationListener } from './segmentationEventManager.js';
|
|
6
6
|
import { getSegmentationRepresentationDisplay } from './SegmentationRepresentationDisplayRegistry.js';
|
|
7
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
8
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.removeSegmentationRepresentations');
|
|
7
9
|
function removeSegmentationRepresentation(viewportId, specifier, immediate) {
|
|
8
10
|
return _removeSegmentationRepresentations(viewportId, specifier, immediate);
|
|
9
11
|
}
|
|
@@ -59,7 +61,7 @@ function _removeRepresentationObject(viewportId, segmentationId, type, immediate
|
|
|
59
61
|
display.removeRepresentation(viewportId, representation.segmentationId, immediate);
|
|
60
62
|
}
|
|
61
63
|
else {
|
|
62
|
-
|
|
64
|
+
cs3dLogger.warn(`No display registered for segmentation representation type ${representation.type}.`);
|
|
63
65
|
}
|
|
64
66
|
removeSegmentationListener(representation.segmentationId, representation.type);
|
|
65
67
|
});
|
|
@@ -6,10 +6,12 @@ import { triggerSegmentationModified } from './triggerSegmentationEvents.js';
|
|
|
6
6
|
import { getActiveSegmentIndex } from './getActiveSegmentIndex.js';
|
|
7
7
|
import { getSegmentationRepresentations } from './getSegmentationRepresentation.js';
|
|
8
8
|
import { ensureLabelmapState, getSegmentBinding, getLabelmaps, setSegmentBinding, syncLegacyLabelmapData, } from './helpers/labelmapSegmentationState.js';
|
|
9
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
10
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.segmentIndex');
|
|
9
11
|
function setActiveSegmentIndex(segmentationId, segmentIndex) {
|
|
10
12
|
const segmentation = getSegmentation(segmentationId);
|
|
11
13
|
if (typeof segmentIndex === 'string') {
|
|
12
|
-
|
|
14
|
+
cs3dLogger.warn('segmentIndex is a string, converting to number');
|
|
13
15
|
segmentIndex = Number(segmentIndex);
|
|
14
16
|
}
|
|
15
17
|
Object.values(segmentation.segments).forEach((segment) => {
|
|
@@ -2,35 +2,37 @@ import { findContourHoles } from '../../../utilities/contours/index.js';
|
|
|
2
2
|
import { getAnnotation, clearParentAnnotation, } from '../../annotation/annotationState.js';
|
|
3
3
|
import { getSegmentation } from '../getSegmentation.js';
|
|
4
4
|
import { extractSegmentPolylines } from './extractSegmentPolylines.js';
|
|
5
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
6
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.utilities.convertContourHoles');
|
|
5
7
|
export default function convertContourHoles(segmentationId, segmentIndex, targetSegmentationId, targetSegmentationIndex) {
|
|
6
8
|
const segmentation = getSegmentation(segmentationId);
|
|
7
9
|
if (!segmentation) {
|
|
8
|
-
|
|
10
|
+
cs3dLogger.warn(`Invalid segmentation given ${segmentationId}`);
|
|
9
11
|
return;
|
|
10
12
|
}
|
|
11
13
|
if (!segmentation.representationData.Contour) {
|
|
12
|
-
|
|
14
|
+
cs3dLogger.warn(`No contour representation found for segmentation ${segmentationId}`);
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
15
17
|
const { annotationUIDsMap } = segmentation?.representationData.Contour || {};
|
|
16
18
|
if (!annotationUIDsMap) {
|
|
17
|
-
|
|
19
|
+
cs3dLogger.warn(`No annotation map found for segmentation ${segmentationId}`);
|
|
18
20
|
return;
|
|
19
21
|
}
|
|
20
22
|
const annotationsUIDsSet = annotationUIDsMap?.get(segmentIndex);
|
|
21
23
|
if (!annotationsUIDsSet) {
|
|
22
|
-
|
|
24
|
+
cs3dLogger.warn(`Segmentation index ${segmentIndex} has no annotations in segmentation ${segmentationId}`);
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
27
|
let targetUIDsSet;
|
|
26
28
|
if (targetSegmentationId && typeof targetSegmentationIndex === 'number') {
|
|
27
29
|
const targetSegmentation = getSegmentation(targetSegmentationId);
|
|
28
30
|
if (!targetSegmentation) {
|
|
29
|
-
|
|
31
|
+
cs3dLogger.warn(`Target segmentation ${targetSegmentationId} does not exist.`);
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
34
|
if (!targetSegmentation.representationData.Contour) {
|
|
33
|
-
|
|
35
|
+
cs3dLogger.warn(`No contour representation found for target segmentation ${targetSegmentationId}`);
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
38
|
targetUIDsSet =
|
|
@@ -42,7 +44,7 @@ export default function convertContourHoles(segmentationId, segmentIndex, target
|
|
|
42
44
|
}
|
|
43
45
|
const polylinesCanvasMap = extractSegmentPolylines(segmentationId, segmentIndex);
|
|
44
46
|
if (!polylinesCanvasMap) {
|
|
45
|
-
|
|
47
|
+
cs3dLogger.warn(`Error extracting contour data from segment ${segmentIndex} in segmentation ${segmentationId}`);
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
50
|
const keys = Array.from(polylinesCanvasMap?.keys());
|
|
@@ -3,24 +3,26 @@ import { getSegmentation } from '../getSegmentation.js';
|
|
|
3
3
|
import { extractSegmentPolylines } from './extractSegmentPolylines.js';
|
|
4
4
|
import decimate from '../../../utilities/math/polyline/decimate.js';
|
|
5
5
|
import { getViewportsAssociatedToSegmentation, getViewportWithMatchingViewPlaneNormal, } from './getViewportAssociatedToSegmentation.js';
|
|
6
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
7
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.utilities.decimateContours');
|
|
6
8
|
export default function decimateContours(segmentationId, segmentIndex, options = { epsilon: 0.1 }) {
|
|
7
9
|
const segmentation = getSegmentation(segmentationId);
|
|
8
10
|
if (!segmentation) {
|
|
9
|
-
|
|
11
|
+
cs3dLogger.warn(`Invalid segmentation given ${segmentationId}`);
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
12
14
|
if (!segmentation.representationData.Contour) {
|
|
13
|
-
|
|
15
|
+
cs3dLogger.warn(`No contour representation found for segmentation ${segmentationId}`);
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
18
|
const viewports = getViewportsAssociatedToSegmentation(segmentationId);
|
|
17
19
|
if (!viewports) {
|
|
18
|
-
|
|
20
|
+
cs3dLogger.warn('No viewport associated to the segmentation found');
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
const polylinesCanvasMap = extractSegmentPolylines(segmentationId, segmentIndex);
|
|
22
24
|
if (!polylinesCanvasMap) {
|
|
23
|
-
|
|
25
|
+
cs3dLogger.warn(`Error extracting contour data from segment ${segmentIndex} in segmentation ${segmentationId}`);
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
28
|
const keys = Array.from(polylinesCanvasMap?.keys());
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getAnnotationMapFromSegmentation, } from './getAnnotationMapFromSegmentation.js';
|
|
2
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
3
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.utilities.getPolylineMap');
|
|
2
4
|
function closePolyline(polyline, closed) {
|
|
3
5
|
if (!polyline || polyline.length === 0) {
|
|
4
6
|
return [];
|
|
@@ -19,7 +21,7 @@ function closePolyline(polyline, closed) {
|
|
|
19
21
|
export function getPolylinesMap(contourRepresentationData, segmentIndex) {
|
|
20
22
|
const { annotationUIDsInSegmentMap } = getAnnotationMapFromSegmentation(contourRepresentationData);
|
|
21
23
|
if (!annotationUIDsInSegmentMap.has(segmentIndex)) {
|
|
22
|
-
|
|
24
|
+
cs3dLogger.warn(`No contour information found for segmentIndex ${segmentIndex}`);
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
27
|
const polylines = new Map();
|
|
@@ -3,19 +3,21 @@ import { getAnnotation } from '../../annotation/annotationState.js';
|
|
|
3
3
|
import { getSegmentation } from '../getSegmentation.js';
|
|
4
4
|
import { extractSegmentPolylines } from './extractSegmentPolylines.js';
|
|
5
5
|
import { removeCompleteContourAnnotation } from './removeCompleteContourAnnotation.js';
|
|
6
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
7
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.utilities.removeContourHoles');
|
|
6
8
|
export default function removeContourHoles(segmentationId, segmentIndex) {
|
|
7
9
|
const segmentation = getSegmentation(segmentationId);
|
|
8
10
|
if (!segmentation) {
|
|
9
|
-
|
|
11
|
+
cs3dLogger.warn(`Invalid segmentation given ${segmentationId}`);
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
12
14
|
if (!segmentation.representationData.Contour) {
|
|
13
|
-
|
|
15
|
+
cs3dLogger.warn(`No contour representation found for segmentation ${segmentationId}`);
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
18
|
const polylinesCanvasMap = extractSegmentPolylines(segmentationId, segmentIndex);
|
|
17
19
|
if (!polylinesCanvasMap) {
|
|
18
|
-
|
|
20
|
+
cs3dLogger.warn(`Error extracting contour data from segment ${segmentIndex} in segmentation ${segmentationId}`);
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
const keys = Array.from(polylinesCanvasMap?.keys());
|
|
@@ -3,19 +3,21 @@ import { getSegmentation } from '../getSegmentation.js';
|
|
|
3
3
|
import { extractSegmentPolylines } from './extractSegmentPolylines.js';
|
|
4
4
|
import findIslands from '../../../utilities/contours/findIslands.js';
|
|
5
5
|
import { removeCompleteContourAnnotation } from './removeCompleteContourAnnotation.js';
|
|
6
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
7
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.utilities.removeContourIslands');
|
|
6
8
|
export default function removeContourIslands(segmentationId, segmentIndex, options = { threshold: 3 }) {
|
|
7
9
|
const segmentation = getSegmentation(segmentationId);
|
|
8
10
|
if (!segmentation) {
|
|
9
|
-
|
|
11
|
+
cs3dLogger.warn(`Invalid segmentation given ${segmentationId}`);
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
12
14
|
if (!segmentation.representationData.Contour) {
|
|
13
|
-
|
|
15
|
+
cs3dLogger.warn(`No contour representation found for segmentation ${segmentationId}`);
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
18
|
const polylinesCanvasMap = extractSegmentPolylines(segmentationId, segmentIndex);
|
|
17
19
|
if (!polylinesCanvasMap) {
|
|
18
|
-
|
|
20
|
+
cs3dLogger.warn(`Error extracting contour data from segment ${segmentIndex} in segmentation ${segmentationId}`);
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
const keys = Array.from(polylinesCanvasMap?.keys());
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { getAnnotation } from '../../annotation/annotationState.js';
|
|
2
2
|
import { getSegmentation } from '../getSegmentation.js';
|
|
3
3
|
import interpolateSegmentPoints from '../../../utilities/planarFreehandROITool/interpolation/interpolateSegmentPoints.js';
|
|
4
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
5
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('stateManagement.segmentation.utilities.smoothContours');
|
|
4
6
|
export default function smoothContours(segmentationId, segmentIndex, options = { knotsRatioPercentage: 30 }) {
|
|
5
7
|
const segmentation = getSegmentation(segmentationId);
|
|
6
8
|
if (!segmentation) {
|
|
7
|
-
|
|
9
|
+
cs3dLogger.warn(`Invalid segmentation given ${segmentationId}`);
|
|
8
10
|
return;
|
|
9
11
|
}
|
|
10
12
|
if (!segmentation.representationData.Contour) {
|
|
11
|
-
|
|
13
|
+
cs3dLogger.warn(`No contour representation found for segmentation ${segmentationId}`);
|
|
12
14
|
return;
|
|
13
15
|
}
|
|
14
16
|
const contourRepresentationData = segmentation.representationData
|
|
15
17
|
.Contour;
|
|
16
18
|
const { annotationUIDsMap } = contourRepresentationData;
|
|
17
19
|
if (!annotationUIDsMap) {
|
|
18
|
-
|
|
20
|
+
cs3dLogger.warn(`No contours found for segmentation ${segmentationId}`);
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
if (!annotationUIDsMap.has(segmentIndex)) {
|
|
22
|
-
|
|
24
|
+
cs3dLogger.warn(`Error extracting contour data from segment ${segmentIndex} in segmentation ${segmentationId}`);
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
27
|
const annotationList = annotationUIDsMap.get(segmentIndex);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getRenderingEngine, getEnabledElement, eventTarget, Enums, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
2
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
3
|
+
const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('store.SynchronizerManager.Synchronizer');
|
|
2
4
|
class Synchronizer {
|
|
3
5
|
constructor(synchronizerId, eventName, eventHandler, options) {
|
|
4
6
|
this._viewportOptions = {};
|
|
@@ -59,7 +61,7 @@ class Synchronizer {
|
|
|
59
61
|
const { renderingEngineId, viewportId } = viewportInfo;
|
|
60
62
|
const viewport = getRenderingEngine(renderingEngineId).getViewport(viewportId);
|
|
61
63
|
if (!viewport) {
|
|
62
|
-
|
|
64
|
+
cs3dLogger.warn(`Synchronizer.addSource: No viewport for ${renderingEngineId} ${viewportId}`);
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
67
|
const eventSource = this._eventSource === 'element' ? viewport.element : eventTarget;
|
|
@@ -150,7 +152,7 @@ class Synchronizer {
|
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
catch (ex) {
|
|
153
|
-
|
|
155
|
+
cs3dLogger.warn(`Synchronizer, for: ${this._eventName}`, ex);
|
|
154
156
|
}
|
|
155
157
|
finally {
|
|
156
158
|
if (promises.length) {
|