@cornerstonejs/tools 0.56.1 → 0.56.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tools/CrosshairsTool.d.ts +1 -0
- package/dist/cjs/tools/CrosshairsTool.js +4 -1
- package/dist/cjs/tools/CrosshairsTool.js.map +1 -1
- package/dist/esm/tools/CrosshairsTool.d.ts +1 -0
- package/dist/esm/tools/CrosshairsTool.js +4 -1
- package/dist/esm/tools/CrosshairsTool.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +5 -4
- package/src/constants/COLOR_LUT.ts +262 -0
- package/src/constants/index.ts +3 -0
- package/src/cursors/ImageMouseCursor.ts +39 -0
- package/src/cursors/MouseCursor.ts +114 -0
- package/src/cursors/SVGCursorDescriptor.ts +462 -0
- package/src/cursors/SVGMouseCursor.ts +145 -0
- package/src/cursors/elementCursor.ts +69 -0
- package/src/cursors/index.ts +24 -0
- package/src/cursors/setCursorForElement.ts +33 -0
- package/src/drawingSvg/_getHash.ts +9 -0
- package/src/drawingSvg/_setAttributesIfNecessary.ts +13 -0
- package/src/drawingSvg/_setNewAttributesIfValid.ts +10 -0
- package/src/drawingSvg/clearByToolType.ts +26 -0
- package/src/drawingSvg/draw.ts +16 -0
- package/src/drawingSvg/drawArrow.ts +82 -0
- package/src/drawingSvg/drawCircle.ts +62 -0
- package/src/drawingSvg/drawEllipse.ts +71 -0
- package/src/drawingSvg/drawHandles.ts +87 -0
- package/src/drawingSvg/drawLine.ts +70 -0
- package/src/drawingSvg/drawLink.ts +76 -0
- package/src/drawingSvg/drawLinkedTextBox.ts +64 -0
- package/src/drawingSvg/drawPolyline.ts +80 -0
- package/src/drawingSvg/drawRect.ts +70 -0
- package/src/drawingSvg/drawTextBox.ts +213 -0
- package/src/drawingSvg/getSvgDrawingHelper.ts +98 -0
- package/src/drawingSvg/index.ts +23 -0
- package/src/enums/AnnotationStyleStates.ts +22 -0
- package/src/enums/Events.ts +242 -0
- package/src/enums/SegmentationRepresentations.ts +12 -0
- package/src/enums/ToolBindings.ts +37 -0
- package/src/enums/ToolModes.ts +31 -0
- package/src/enums/Touch.ts +8 -0
- package/src/enums/index.js +16 -0
- package/src/eventDispatchers/annotationModifiedEventDispatcher.ts +41 -0
- package/src/eventDispatchers/cameraModifiedEventDispatcher.ts +41 -0
- package/src/eventDispatchers/imageRenderedEventDispatcher.ts +37 -0
- package/src/eventDispatchers/imageSpacingCalibratedEventDispatcher.ts +50 -0
- package/src/eventDispatchers/index.js +15 -0
- package/src/eventDispatchers/keyboardEventHandlers/index.js +4 -0
- package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +29 -0
- package/src/eventDispatchers/keyboardEventHandlers/keyUp.ts +33 -0
- package/src/eventDispatchers/keyboardToolEventDispatcher.ts +28 -0
- package/src/eventDispatchers/mouseEventHandlers/index.js +19 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseClick.ts +13 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDoubleClick.ts +13 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDown.ts +196 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDownActivate.ts +35 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDrag.ts +25 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseMove.ts +70 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseUp.ts +9 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseWheel.ts +13 -0
- package/src/eventDispatchers/mouseToolEventDispatcher.ts +64 -0
- package/src/eventDispatchers/shared/customCallbackHandler.ts +73 -0
- package/src/eventDispatchers/shared/getActiveToolForKeyboardEvent.ts +58 -0
- package/src/eventDispatchers/shared/getActiveToolForMouseEvent.ts +61 -0
- package/src/eventDispatchers/shared/getActiveToolForTouchEvent.ts +64 -0
- package/src/eventDispatchers/shared/getMouseModifier.ts +30 -0
- package/src/eventDispatchers/shared/getToolsWithModesForMouseEvent.ts +56 -0
- package/src/eventDispatchers/shared/getToolsWithModesForTouchEvent.ts +54 -0
- package/src/eventDispatchers/touchEventHandlers/index.js +15 -0
- package/src/eventDispatchers/touchEventHandlers/touchDrag.ts +23 -0
- package/src/eventDispatchers/touchEventHandlers/touchEnd.ts +9 -0
- package/src/eventDispatchers/touchEventHandlers/touchPress.ts +13 -0
- package/src/eventDispatchers/touchEventHandlers/touchStart.ts +174 -0
- package/src/eventDispatchers/touchEventHandlers/touchStartActivate.ts +36 -0
- package/src/eventDispatchers/touchEventHandlers/touchTap.ts +9 -0
- package/src/eventDispatchers/touchToolEventDispatcher.ts +51 -0
- package/src/eventListeners/annotations/annotationModifiedListener.ts +22 -0
- package/src/eventListeners/annotations/annotationSelectionListener.ts +29 -0
- package/src/eventListeners/annotations/index.ts +4 -0
- package/src/eventListeners/index.ts +28 -0
- package/src/eventListeners/keyboard/index.ts +16 -0
- package/src/eventListeners/keyboard/keyDownListener.ts +99 -0
- package/src/eventListeners/mouse/getMouseEventPoints.ts +66 -0
- package/src/eventListeners/mouse/index.ts +55 -0
- package/src/eventListeners/mouse/mouseDoubleClickListener.ts +55 -0
- package/src/eventListeners/mouse/mouseDownListener.ts +519 -0
- package/src/eventListeners/mouse/mouseMoveListener.ts +33 -0
- package/src/eventListeners/segmentation/index.ts +11 -0
- package/src/eventListeners/segmentation/segmentationDataModifiedEventListener.ts +61 -0
- package/src/eventListeners/segmentation/segmentationModifiedEventListener.ts +32 -0
- package/src/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.ts +15 -0
- package/src/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.ts +16 -0
- package/src/eventListeners/touch/getTouchEventPoints.ts +75 -0
- package/src/eventListeners/touch/index.ts +37 -0
- package/src/eventListeners/touch/preventGhostClick.js +72 -0
- package/src/eventListeners/touch/touchStartListener.ts +499 -0
- package/src/eventListeners/wheel/index.ts +27 -0
- package/src/eventListeners/wheel/normalizeWheel.ts +69 -0
- package/src/eventListeners/wheel/wheelListener.ts +51 -0
- package/src/index.ts +133 -0
- package/src/init.ts +187 -0
- package/src/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.ts +399 -0
- package/src/stateManagement/annotation/annotationLocking.ts +178 -0
- package/src/stateManagement/annotation/annotationSelection.ts +163 -0
- package/src/stateManagement/annotation/annotationState.ts +180 -0
- package/src/stateManagement/annotation/annotationVisibility.ts +156 -0
- package/src/stateManagement/annotation/config/ToolStyle.ts +265 -0
- package/src/stateManagement/annotation/config/getFont.ts +36 -0
- package/src/stateManagement/annotation/config/getState.ts +26 -0
- package/src/stateManagement/annotation/config/helpers.ts +55 -0
- package/src/stateManagement/annotation/config/index.ts +5 -0
- package/src/stateManagement/annotation/helpers/state.ts +83 -0
- package/src/stateManagement/annotation/index.ts +15 -0
- package/src/stateManagement/index.js +40 -0
- package/src/stateManagement/segmentation/SegmentationStateManager.ts +491 -0
- package/src/stateManagement/segmentation/activeSegmentation.ts +60 -0
- package/src/stateManagement/segmentation/addSegmentationRepresentations.ts +77 -0
- package/src/stateManagement/segmentation/addSegmentations.ts +27 -0
- package/src/stateManagement/segmentation/config/index.ts +29 -0
- package/src/stateManagement/segmentation/config/segmentationColor.ts +132 -0
- package/src/stateManagement/segmentation/config/segmentationConfig.ts +195 -0
- package/src/stateManagement/segmentation/config/segmentationVisibility.ts +171 -0
- package/src/stateManagement/segmentation/helpers/index.ts +3 -0
- package/src/stateManagement/segmentation/helpers/normalizeSegmentationInput.ts +35 -0
- package/src/stateManagement/segmentation/helpers/validateSegmentationInput.ts +41 -0
- package/src/stateManagement/segmentation/index.ts +22 -0
- package/src/stateManagement/segmentation/removeSegmentationsFromToolGroup.ts +85 -0
- package/src/stateManagement/segmentation/segmentIndex.ts +38 -0
- package/src/stateManagement/segmentation/segmentLocking.ts +72 -0
- package/src/stateManagement/segmentation/segmentationState.ts +429 -0
- package/src/stateManagement/segmentation/triggerSegmentationEvents.ts +157 -0
- package/src/store/SynchronizerManager/Synchronizer.ts +344 -0
- package/src/store/SynchronizerManager/createSynchronizer.ts +41 -0
- package/src/store/SynchronizerManager/destroy.ts +14 -0
- package/src/store/SynchronizerManager/destroySynchronizer.ts +25 -0
- package/src/store/SynchronizerManager/getAllSynchronizers.ts +12 -0
- package/src/store/SynchronizerManager/getSynchronizer.ts +13 -0
- package/src/store/SynchronizerManager/getSynchronizersForViewport.ts +44 -0
- package/src/store/SynchronizerManager/index.js +15 -0
- package/src/store/ToolGroupManager/ToolGroup.ts +679 -0
- package/src/store/ToolGroupManager/createToolGroup.ts +33 -0
- package/src/store/ToolGroupManager/destroy.ts +24 -0
- package/src/store/ToolGroupManager/destroyToolGroup.ts +26 -0
- package/src/store/ToolGroupManager/getAllToolGroups.ts +12 -0
- package/src/store/ToolGroupManager/getToolGroup.ts +14 -0
- package/src/store/ToolGroupManager/getToolGroupForViewport.ts +44 -0
- package/src/store/ToolGroupManager/getToolGroupsWithToolName.ts +33 -0
- package/src/store/ToolGroupManager/index.ts +17 -0
- package/src/store/addEnabledElement.ts +137 -0
- package/src/store/addTool.ts +56 -0
- package/src/store/cancelActiveManipulations.ts +30 -0
- package/src/store/filterMoveableAnnotationTools.ts +61 -0
- package/src/store/filterToolsWithAnnotationsForElement.ts +51 -0
- package/src/store/filterToolsWithMoveableHandles.ts +51 -0
- package/src/store/index.ts +29 -0
- package/src/store/removeEnabledElement.ts +132 -0
- package/src/store/state.ts +57 -0
- package/src/store/svgNodeCache.ts +7 -0
- package/src/synchronizers/callbacks/areViewportsCoplanar .ts +12 -0
- package/src/synchronizers/callbacks/cameraSyncCallback.ts +33 -0
- package/src/synchronizers/callbacks/stackImageSyncCallback.ts +157 -0
- package/src/synchronizers/callbacks/voiSyncCallback.ts +51 -0
- package/src/synchronizers/callbacks/zoomPanSyncCallback.ts +43 -0
- package/src/synchronizers/index.ts +11 -0
- package/src/synchronizers/synchronizers/createCameraPositionSynchronizer.ts +25 -0
- package/src/synchronizers/synchronizers/createStackImageSynchronizer.ts +25 -0
- package/src/synchronizers/synchronizers/createVOISynchronizer.ts +24 -0
- package/src/synchronizers/synchronizers/createZoomPanSynchronizer.ts +25 -0
- package/src/synchronizers/synchronizers/index.ts +11 -0
- package/src/tools/CrosshairsTool.ts +2693 -0
- package/src/tools/MIPJumpToClickTool.ts +99 -0
- package/src/tools/MagnifyTool.ts +319 -0
- package/src/tools/PanTool.ts +58 -0
- package/src/tools/PlanarRotateTool.ts +77 -0
- package/src/tools/ReferenceCursors.ts +466 -0
- package/src/tools/ReferenceLinesTool.ts +279 -0
- package/src/tools/ScaleOverlayTool.ts +685 -0
- package/src/tools/StackScrollTool.ts +97 -0
- package/src/tools/StackScrollToolMouseWheelTool.ts +58 -0
- package/src/tools/TrackballRotateTool.ts +141 -0
- package/src/tools/VolumeRotateMouseWheelTool.ts +86 -0
- package/src/tools/WindowLevelTool.ts +260 -0
- package/src/tools/ZoomTool.ts +293 -0
- package/src/tools/annotation/AngleTool.ts +835 -0
- package/src/tools/annotation/ArrowAnnotateTool.ts +820 -0
- package/src/tools/annotation/BidirectionalTool.ts +1350 -0
- package/src/tools/annotation/CircleROITool.ts +1070 -0
- package/src/tools/annotation/CobbAngleTool.ts +815 -0
- package/src/tools/annotation/DragProbeTool.ts +213 -0
- package/src/tools/annotation/EllipticalROITool.ts +1223 -0
- package/src/tools/annotation/LengthTool.ts +861 -0
- package/src/tools/annotation/PlanarFreehandROITool.ts +636 -0
- package/src/tools/annotation/ProbeTool.ts +681 -0
- package/src/tools/annotation/RectangleROITool.ts +1028 -0
- package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +488 -0
- package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +462 -0
- package/src/tools/annotation/planarFreehandROITool/editLoopCommon.ts +331 -0
- package/src/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.ts +74 -0
- package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +612 -0
- package/src/tools/annotation/planarFreehandROITool/openContourEndEditLoop.ts +74 -0
- package/src/tools/annotation/planarFreehandROITool/renderMethods.ts +407 -0
- package/src/tools/base/AnnotationDisplayTool.ts +228 -0
- package/src/tools/base/AnnotationTool.ts +307 -0
- package/src/tools/base/BaseTool.ts +215 -0
- package/src/tools/base/index.ts +4 -0
- package/src/tools/displayTools/Contour/addContourToElement.ts +135 -0
- package/src/tools/displayTools/Contour/contourDisplay.ts +252 -0
- package/src/tools/displayTools/Contour/index.ts +3 -0
- package/src/tools/displayTools/Contour/removeContourFromElement.ts +35 -0
- package/src/tools/displayTools/Labelmap/addLabelmapToElement.ts +57 -0
- package/src/tools/displayTools/Labelmap/index.ts +4 -0
- package/src/tools/displayTools/Labelmap/labelmapConfig.ts +37 -0
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +461 -0
- package/src/tools/displayTools/Labelmap/removeLabelmapFromElement.ts +27 -0
- package/src/tools/displayTools/Labelmap/validateRepresentationData.ts +30 -0
- package/src/tools/displayTools/SegmentationDisplayTool.ts +198 -0
- package/src/tools/index.ts +84 -0
- package/src/tools/segmentation/BrushTool.ts +474 -0
- package/src/tools/segmentation/CircleScissorsTool.ts +365 -0
- package/src/tools/segmentation/PaintFillTool.ts +370 -0
- package/src/tools/segmentation/RectangleROIStartEndThresholdTool.ts +471 -0
- package/src/tools/segmentation/RectangleROIThresholdTool.ts +281 -0
- package/src/tools/segmentation/RectangleScissorsTool.ts +382 -0
- package/src/tools/segmentation/SphereScissorsTool.ts +368 -0
- package/src/tools/segmentation/strategies/eraseCircle.ts +30 -0
- package/src/tools/segmentation/strategies/eraseRectangle.ts +81 -0
- package/src/tools/segmentation/strategies/eraseSphere.ts +27 -0
- package/src/tools/segmentation/strategies/fillCircle.ts +185 -0
- package/src/tools/segmentation/strategies/fillRectangle.ts +110 -0
- package/src/tools/segmentation/strategies/fillSphere.ts +88 -0
- package/src/tools/segmentation/strategies/index.ts +9 -0
- package/src/types/AnnotationGroupSelector.ts +7 -0
- package/src/types/AnnotationStyle.ts +42 -0
- package/src/types/AnnotationTypes.ts +109 -0
- package/src/types/BoundsIJK.ts +5 -0
- package/src/types/CINETypes.ts +32 -0
- package/src/types/ContourTypes.ts +26 -0
- package/src/types/CursorTypes.ts +12 -0
- package/src/types/EventTypes.ts +657 -0
- package/src/types/FloodFillTypes.ts +19 -0
- package/src/types/IAnnotationManager.ts +89 -0
- package/src/types/IDistance.ts +16 -0
- package/src/types/IPoints.ts +18 -0
- package/src/types/ISetToolModeOptions.ts +29 -0
- package/src/types/ISynchronizerEventHandler.ts +11 -0
- package/src/types/IToolClassReference.ts +5 -0
- package/src/types/IToolGroup.ts +72 -0
- package/src/types/ITouchPoints.ts +14 -0
- package/src/types/InteractionTypes.ts +6 -0
- package/src/types/InternalToolTypes.ts +19 -0
- package/src/types/JumpToSliceOptions.ts +7 -0
- package/src/types/LabelmapTypes.ts +41 -0
- package/src/types/PlanarBoundingBox.ts +8 -0
- package/src/types/SVGDrawingHelper.ts +10 -0
- package/src/types/ScrollOptions.ts +9 -0
- package/src/types/SegmentationStateTypes.ts +248 -0
- package/src/types/ToolHandle.ts +26 -0
- package/src/types/ToolProps.ts +16 -0
- package/src/types/ToolSpecificAnnotationTypes.ts +311 -0
- package/src/types/index.ts +115 -0
- package/src/utilities/boundingBox/extend2DBoundingBoxInViewAxis.ts +29 -0
- package/src/utilities/boundingBox/getBoundingBoxAroundShape.ts +57 -0
- package/src/utilities/boundingBox/index.ts +4 -0
- package/src/utilities/calibrateImageSpacing.ts +46 -0
- package/src/utilities/cine/events.ts +9 -0
- package/src/utilities/cine/index.ts +5 -0
- package/src/utilities/cine/playClip.ts +435 -0
- package/src/utilities/cine/state.ts +18 -0
- package/src/utilities/clip.js +30 -0
- package/src/utilities/debounce.js +217 -0
- package/src/utilities/drawing/getTextBoxCoordsCanvas.ts +45 -0
- package/src/utilities/drawing/index.ts +3 -0
- package/src/utilities/dynamicVolume/getDataInTime.ts +110 -0
- package/src/utilities/dynamicVolume/index.ts +2 -0
- package/src/utilities/getAnnotationNearPoint.ts +130 -0
- package/src/utilities/getModalityUnit.ts +11 -0
- package/src/utilities/getToolsWithModesForElement.ts +52 -0
- package/src/utilities/index.ts +68 -0
- package/src/utilities/isObject.js +29 -0
- package/src/utilities/math/angle/angleBetweenLines.ts +29 -0
- package/src/utilities/math/circle/_types.ts +6 -0
- package/src/utilities/math/circle/getCanvasCircleCorners.ts +23 -0
- package/src/utilities/math/circle/getCanvasCircleRadius.ts +16 -0
- package/src/utilities/math/circle/index.ts +4 -0
- package/src/utilities/math/ellipse/getCanvasEllipseCorners.ts +26 -0
- package/src/utilities/math/ellipse/index.ts +4 -0
- package/src/utilities/math/ellipse/pointInEllipse.ts +38 -0
- package/src/utilities/math/ellipse/pointInEllipsoidWithConstraint.ts +35 -0
- package/src/utilities/math/index.ts +8 -0
- package/src/utilities/math/line/distanceToPoint.ts +24 -0
- package/src/utilities/math/line/distanceToPointSquared.ts +44 -0
- package/src/utilities/math/line/index.ts +5 -0
- package/src/utilities/math/line/intersectLine.ts +92 -0
- package/src/utilities/math/midPoint.ts +24 -0
- package/src/utilities/math/point/distanceToPoint.ts +22 -0
- package/src/utilities/math/point/index.ts +3 -0
- package/src/utilities/math/polyline/addCanvasPointsToArray.ts +62 -0
- package/src/utilities/math/polyline/calculateAreaOfPoints.ts +23 -0
- package/src/utilities/math/polyline/getIntersectionWithPolyline.ts +182 -0
- package/src/utilities/math/polyline/getSubPixelSpacingAndXYDirections.ts +99 -0
- package/src/utilities/math/polyline/index.ts +19 -0
- package/src/utilities/math/polyline/planarFreehandROIInternalTypes.ts +36 -0
- package/src/utilities/math/polyline/pointCanProjectOnLine.ts +57 -0
- package/src/utilities/math/polyline/pointsAreWithinCloseContourProximity.ts +15 -0
- package/src/utilities/math/rectangle/distanceToPoint.ts +82 -0
- package/src/utilities/math/rectangle/index.ts +3 -0
- package/src/utilities/math/sphere/index.ts +3 -0
- package/src/utilities/math/sphere/pointInSphere.ts +31 -0
- package/src/utilities/math/vec2/findClosestPoint.ts +40 -0
- package/src/utilities/math/vec2/index.ts +4 -0
- package/src/utilities/math/vec2/liangBarksyClip.ts +84 -0
- package/src/utilities/orientation/getOrientationStringLPS.ts +52 -0
- package/src/utilities/orientation/index.ts +4 -0
- package/src/utilities/orientation/invertOrientationStringLPS.ts +21 -0
- package/src/utilities/planar/filterAnnotationsForDisplay.ts +68 -0
- package/src/utilities/planar/filterAnnotationsWithinSlice.ts +85 -0
- package/src/utilities/planar/getPointInLineOfSightWithCriteria.ts +104 -0
- package/src/utilities/planar/getWorldWidthAndHeightFromCorners.ts +51 -0
- package/src/utilities/planar/getWorldWidthAndHeightFromTwoPoints.ts +51 -0
- package/src/utilities/planar/index.ts +18 -0
- package/src/utilities/planarFreehandROITool/index.ts +7 -0
- package/src/utilities/planarFreehandROITool/interpolateAnnotation.ts +87 -0
- package/src/utilities/planarFreehandROITool/interpolatePoints.ts +214 -0
- package/src/utilities/planarFreehandROITool/interpolation/algorithms/bspline.ts +55 -0
- package/src/utilities/planarFreehandROITool/interpolation/interpolateSegmentPoints.ts +90 -0
- package/src/utilities/pointInShapeCallback.ts +138 -0
- package/src/utilities/pointInSurroundingSphereCallback.ts +188 -0
- package/src/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.ts +76 -0
- package/src/utilities/rectangleROITool/index.ts +3 -0
- package/src/utilities/scroll.ts +62 -0
- package/src/utilities/segmentation/brushSizeForToolGroup.ts +72 -0
- package/src/utilities/segmentation/brushThresholdForToolGroup.ts +65 -0
- package/src/utilities/segmentation/createLabelmapVolumeForViewport.ts +74 -0
- package/src/utilities/segmentation/createMergedLabelmapForIndex.ts +65 -0
- package/src/utilities/segmentation/floodFill.ts +194 -0
- package/src/utilities/segmentation/getDefaultRepresentationConfig.ts +20 -0
- package/src/utilities/segmentation/index.ts +33 -0
- package/src/utilities/segmentation/isValidRepresentationConfig.ts +22 -0
- package/src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts +91 -0
- package/src/utilities/segmentation/thresholdSegmentationByRange.ts +129 -0
- package/src/utilities/segmentation/thresholdVolumeByRange.ts +150 -0
- package/src/utilities/segmentation/triggerSegmentationRender.ts +206 -0
- package/src/utilities/segmentation/utilities.ts +116 -0
- package/src/utilities/stackPrefetch/index.ts +8 -0
- package/src/utilities/stackPrefetch/stackPrefetch.ts +405 -0
- package/src/utilities/stackPrefetch/state.ts +17 -0
- package/src/utilities/throttle.js +69 -0
- package/src/utilities/touch/index.ts +246 -0
- package/src/utilities/triggerAnnotationRender.ts +237 -0
- package/src/utilities/triggerAnnotationRenderForViewportIds.ts +18 -0
- package/src/utilities/viewport/index.ts +5 -0
- package/src/utilities/viewport/isViewportPreScaled.ts +24 -0
- package/src/utilities/viewport/jumpToSlice.ts +73 -0
- package/src/utilities/viewport/jumpToWorld.ts +58 -0
- package/src/utilities/viewportFilters/filterViewportsWithFrameOfReferenceUID.ts +28 -0
- package/src/utilities/viewportFilters/filterViewportsWithParallelNormals.ts +26 -0
- package/src/utilities/viewportFilters/filterViewportsWithSameOrientation.ts +15 -0
- package/src/utilities/viewportFilters/filterViewportsWithToolEnabled.ts +72 -0
- package/src/utilities/viewportFilters/getViewportIdsWithToolToRender.ts +45 -0
- package/src/utilities/viewportFilters/index.ts +11 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { utilities } from '@cornerstonejs/core';
|
|
2
|
+
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
3
|
+
import { Color } from '../../../types/SegmentationStateTypes';
|
|
4
|
+
import { ColorLUT } from '../../../types/SegmentationStateTypes';
|
|
5
|
+
import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* addColorLUT - Adds a new color LUT to the state at the given colorLUTIndex.
|
|
9
|
+
* If no colorLUT is provided, a new color LUT is generated.
|
|
10
|
+
*
|
|
11
|
+
* @param colorLUTIndex - the index of the colorLUT in the state
|
|
12
|
+
* @param colorLUT - An array of The colorLUT to set.
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
function addColorLUT(colorLUT: ColorLUT, colorLUTIndex: number): void {
|
|
16
|
+
if (!colorLUT) {
|
|
17
|
+
throw new Error('addColorLUT: colorLUT is required');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Append the "zero" (no label) color to the front of the LUT, if necessary.
|
|
21
|
+
if (!utilities.isEqual(colorLUT[0], [0, 0, 0, 0])) {
|
|
22
|
+
console.warn(
|
|
23
|
+
'addColorLUT: [0, 0, 0, 0] color is not provided for the background color (segmentIndex =0), automatically adding it'
|
|
24
|
+
);
|
|
25
|
+
colorLUT.unshift([0, 0, 0, 0]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
SegmentationState.addColorLUT(colorLUT, colorLUTIndex);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* It sets the toolGroup's segmentationRepresentation to use the provided
|
|
33
|
+
* colorLUT at the given colorLUTIndex.
|
|
34
|
+
* @param toolGroupId - the id of the toolGroup that renders the representation
|
|
35
|
+
* @param segmentationRepresentationUID - the representationUID for the segmentation
|
|
36
|
+
* @param colorLUTIndex - the index of the colorLUT to use
|
|
37
|
+
*/
|
|
38
|
+
function setColorLUT(
|
|
39
|
+
toolGroupId: string,
|
|
40
|
+
segmentationRepresentationUID: string,
|
|
41
|
+
colorLUTIndex: number
|
|
42
|
+
): void {
|
|
43
|
+
const segRepresentation =
|
|
44
|
+
SegmentationState.getSegmentationRepresentationByUID(
|
|
45
|
+
toolGroupId,
|
|
46
|
+
segmentationRepresentationUID
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (!segRepresentation) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`setColorLUT: could not find segmentation representation with UID ${segmentationRepresentationUID}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!SegmentationState.getColorLUT(colorLUTIndex)) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`setColorLUT: could not find colorLUT with index ${colorLUTIndex}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
segRepresentation.colorLUTIndex = colorLUTIndex;
|
|
62
|
+
|
|
63
|
+
triggerSegmentationRepresentationModified(
|
|
64
|
+
toolGroupId,
|
|
65
|
+
segmentationRepresentationUID
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Given a tool group UID, a segmentation representationUID, and a segment index, return the
|
|
71
|
+
* color for that segment. It can be used for segmentation tools that need to
|
|
72
|
+
* display the color of their annotation.
|
|
73
|
+
*
|
|
74
|
+
* @param toolGroupId - The Id of the tool group that owns the segmentation representation.
|
|
75
|
+
* @param segmentationRepresentationUID - The uid of the segmentation representation
|
|
76
|
+
* @param segmentIndex - The index of the segment in the segmentation
|
|
77
|
+
* @returns A color.
|
|
78
|
+
*/
|
|
79
|
+
function getColorForSegmentIndex(
|
|
80
|
+
toolGroupId: string,
|
|
81
|
+
segmentationRepresentationUID: string,
|
|
82
|
+
segmentIndex: number
|
|
83
|
+
): Color {
|
|
84
|
+
const segmentationRepresentation =
|
|
85
|
+
SegmentationState.getSegmentationRepresentationByUID(
|
|
86
|
+
toolGroupId,
|
|
87
|
+
segmentationRepresentationUID
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (!segmentationRepresentation) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`segmentation representation with UID ${segmentationRepresentationUID} does not exist for tool group ${toolGroupId}`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const { colorLUTIndex } = segmentationRepresentation;
|
|
97
|
+
|
|
98
|
+
// get colorLUT
|
|
99
|
+
const colorLUT = SegmentationState.getColorLUT(colorLUTIndex);
|
|
100
|
+
return colorLUT[segmentIndex];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function setColorForSegmentIndex(
|
|
104
|
+
toolGroupId: string,
|
|
105
|
+
segmentationRepresentationUID: string,
|
|
106
|
+
segmentIndex: number,
|
|
107
|
+
color: Color
|
|
108
|
+
): void {
|
|
109
|
+
// Get the reference to the color in the colorLUT.
|
|
110
|
+
const colorReference = getColorForSegmentIndex(
|
|
111
|
+
toolGroupId,
|
|
112
|
+
segmentationRepresentationUID,
|
|
113
|
+
segmentIndex
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// Modify the values by reference
|
|
117
|
+
for (let i = 0; i < color.length; i++) {
|
|
118
|
+
colorReference[i] = color[i];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
triggerSegmentationRepresentationModified(
|
|
122
|
+
toolGroupId,
|
|
123
|
+
segmentationRepresentationUID
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export {
|
|
128
|
+
getColorForSegmentIndex,
|
|
129
|
+
addColorLUT,
|
|
130
|
+
setColorLUT,
|
|
131
|
+
setColorForSegmentIndex,
|
|
132
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
|
|
2
|
+
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
RepresentationConfig,
|
|
6
|
+
SegmentationRepresentationConfig,
|
|
7
|
+
SegmentSpecificRepresentationConfig,
|
|
8
|
+
} from '../../../types/SegmentationStateTypes';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* It returns the global segmentation config.
|
|
12
|
+
* @returns The global segmentation config containing the representations
|
|
13
|
+
* config for each representation type and renderInactiveSegmentations flag.
|
|
14
|
+
*/
|
|
15
|
+
function getGlobalConfig(): SegmentationRepresentationConfig {
|
|
16
|
+
return SegmentationState.getGlobalConfig();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Set the global segmentation config
|
|
21
|
+
* @param segmentationConfig - SegmentationConfig
|
|
22
|
+
*/
|
|
23
|
+
function setGlobalConfig(
|
|
24
|
+
segmentationConfig: SegmentationRepresentationConfig
|
|
25
|
+
): void {
|
|
26
|
+
SegmentationState.setGlobalConfig(segmentationConfig);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Given a representation type, return the corresponding global representation config
|
|
31
|
+
* @param representationType - The type of representation to query
|
|
32
|
+
* @returns A representation configuration object.
|
|
33
|
+
*/
|
|
34
|
+
function getGlobalRepresentationConfig(
|
|
35
|
+
representationType: SegmentationRepresentations
|
|
36
|
+
): RepresentationConfig['LABELMAP'] {
|
|
37
|
+
const globalConfig = getGlobalConfig();
|
|
38
|
+
return globalConfig.representations[representationType];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Set the global configuration for a given representation type. It fires
|
|
43
|
+
* a SEGMENTATION_MODIFIED event.
|
|
44
|
+
*
|
|
45
|
+
* @triggers SEGMENTATION_MODIFIED
|
|
46
|
+
* @param representationType - The type of representation to set config for
|
|
47
|
+
* @param config - The configuration for the representation.
|
|
48
|
+
*/
|
|
49
|
+
function setGlobalRepresentationConfig(
|
|
50
|
+
representationType: SegmentationRepresentations,
|
|
51
|
+
config: RepresentationConfig['LABELMAP']
|
|
52
|
+
): void {
|
|
53
|
+
const globalConfig = getGlobalConfig();
|
|
54
|
+
|
|
55
|
+
setGlobalConfig({
|
|
56
|
+
...globalConfig,
|
|
57
|
+
representations: {
|
|
58
|
+
...globalConfig.representations,
|
|
59
|
+
[representationType]: {
|
|
60
|
+
...globalConfig.representations[representationType],
|
|
61
|
+
...config,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the toolGroup specific segmentation config
|
|
69
|
+
* @param toolGroupId - The Id of the tool group
|
|
70
|
+
* @returns A SegmentationConfig object.
|
|
71
|
+
*/
|
|
72
|
+
function getToolGroupSpecificConfig(
|
|
73
|
+
toolGroupId: string
|
|
74
|
+
): SegmentationRepresentationConfig {
|
|
75
|
+
return SegmentationState.getToolGroupSpecificConfig(toolGroupId);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sets the tool group specific configuration for the segmentation
|
|
80
|
+
* representation. This will apply to all segmentation representations.
|
|
81
|
+
* @param toolGroupId - The tool group id where the segmentation representation belongs to.
|
|
82
|
+
* @param segmentationRepresentationConfig - This is the configuration object that you will use to set the default values for
|
|
83
|
+
* the segmentation representation.
|
|
84
|
+
*/
|
|
85
|
+
function setToolGroupSpecificConfig(
|
|
86
|
+
toolGroupId: string,
|
|
87
|
+
segmentationRepresentationConfig: SegmentationRepresentationConfig
|
|
88
|
+
): void {
|
|
89
|
+
SegmentationState.setToolGroupSpecificConfig(
|
|
90
|
+
toolGroupId,
|
|
91
|
+
segmentationRepresentationConfig
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Give the segmentation representation UID, return the corresponding config
|
|
97
|
+
* which is shared by all segments in the segmentation representation. This is
|
|
98
|
+
* an optional level of configuration that can be set by the user, by default
|
|
99
|
+
* it will fallback to the toolGroup specific config, if not set, it will fallback
|
|
100
|
+
* to the global config.
|
|
101
|
+
*
|
|
102
|
+
* @param segmentationRepresentationUID - The uid of the segmentation representation
|
|
103
|
+
* @param config - The configuration for the representation. This is an object
|
|
104
|
+
* only containing the representation type as key and the config as value.
|
|
105
|
+
* @returns - The configuration for the representation.
|
|
106
|
+
*/
|
|
107
|
+
function getSegmentationRepresentationSpecificConfig(
|
|
108
|
+
toolGroupId: string,
|
|
109
|
+
segmentationRepresentationUID: string
|
|
110
|
+
): RepresentationConfig {
|
|
111
|
+
return SegmentationState.getSegmentationRepresentationSpecificConfig(
|
|
112
|
+
toolGroupId,
|
|
113
|
+
segmentationRepresentationUID
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Set the segmentation representation specific configuration for the
|
|
119
|
+
* segmentation representation. This will apply to all segments in the
|
|
120
|
+
* segmentation representation and has higher priority than the toolGroup
|
|
121
|
+
* specific config.
|
|
122
|
+
*
|
|
123
|
+
* @param segmentationRepresentationUID - The uid of the segmentation representation
|
|
124
|
+
* @param config - The configuration for the representation. This is an object
|
|
125
|
+
* only containing the representation type as key and the config as value.
|
|
126
|
+
*/
|
|
127
|
+
function setSegmentationRepresentationSpecificConfig(
|
|
128
|
+
toolGroupId: string,
|
|
129
|
+
segmentationRepresentationUID: string,
|
|
130
|
+
config: RepresentationConfig
|
|
131
|
+
): void {
|
|
132
|
+
SegmentationState.setSegmentationRepresentationSpecificConfig(
|
|
133
|
+
toolGroupId,
|
|
134
|
+
segmentationRepresentationUID,
|
|
135
|
+
config
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Get the segment specific configuration for the segmentation representation.
|
|
141
|
+
*
|
|
142
|
+
* @param toolGroupId - The tool group id where the segmentation representation belongs to.
|
|
143
|
+
* @param segmentationRepresentationUID - The uid of the segmentation representation
|
|
144
|
+
* @param segmentIndex - The index of the segment
|
|
145
|
+
* @returns - The configuration for the segment index in the segmentation representation that is shown in the toolGroup's viewport
|
|
146
|
+
*/
|
|
147
|
+
function getSegmentSpecificConfig(
|
|
148
|
+
toolGroupId: string,
|
|
149
|
+
segmentationRepresentationUID: string,
|
|
150
|
+
segmentIndex: number
|
|
151
|
+
): RepresentationConfig {
|
|
152
|
+
return SegmentationState.getSegmentSpecificRepresentationConfig(
|
|
153
|
+
toolGroupId,
|
|
154
|
+
segmentationRepresentationUID,
|
|
155
|
+
segmentIndex
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Set the segment specific configuration for the segmentation representation.
|
|
161
|
+
* This configuration, if specified, has higher priority than the segmentation representation specific config,
|
|
162
|
+
* and the toolGroup specific config. The order of priority is: segment specific config > segmentation representation specific config > toolGroup specific config > global config
|
|
163
|
+
* @param toolGroupId - The tool group id where the segmentation representation belongs to.
|
|
164
|
+
* @param segmentationRepresentationUID - The uid of the segmentation representation
|
|
165
|
+
* @param segmentIndex - The index of the segment
|
|
166
|
+
* @param config - The configuration for the representation. This is an object
|
|
167
|
+
*/
|
|
168
|
+
function setSegmentSpecificConfig(
|
|
169
|
+
toolGroupId: string,
|
|
170
|
+
segmentationRepresentationUID: string,
|
|
171
|
+
config: SegmentSpecificRepresentationConfig
|
|
172
|
+
): void {
|
|
173
|
+
SegmentationState.setSegmentSpecificRepresentationConfig(
|
|
174
|
+
toolGroupId,
|
|
175
|
+
segmentationRepresentationUID,
|
|
176
|
+
config
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export {
|
|
181
|
+
// Global
|
|
182
|
+
getGlobalConfig,
|
|
183
|
+
setGlobalConfig,
|
|
184
|
+
getGlobalRepresentationConfig,
|
|
185
|
+
setGlobalRepresentationConfig,
|
|
186
|
+
// ToolGroup Specific
|
|
187
|
+
getToolGroupSpecificConfig,
|
|
188
|
+
setToolGroupSpecificConfig,
|
|
189
|
+
// segmentation representation specific config
|
|
190
|
+
getSegmentationRepresentationSpecificConfig,
|
|
191
|
+
setSegmentationRepresentationSpecificConfig,
|
|
192
|
+
// segment specific config
|
|
193
|
+
getSegmentSpecificConfig,
|
|
194
|
+
setSegmentSpecificConfig,
|
|
195
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { cache } from '@cornerstonejs/core';
|
|
2
|
+
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
3
|
+
import { getSegmentationRepresentations } from '../../../stateManagement/segmentation/segmentationState';
|
|
4
|
+
import { ToolGroupSpecificRepresentation } from '../../../types/SegmentationStateTypes';
|
|
5
|
+
import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents';
|
|
6
|
+
|
|
7
|
+
function getSegmentationIndices(segmentationId) {
|
|
8
|
+
const volume = cache.getVolume(segmentationId);
|
|
9
|
+
const scalarData = volume.getScalarData();
|
|
10
|
+
|
|
11
|
+
const keySet = {};
|
|
12
|
+
scalarData.forEach((it) => (keySet[it] = it));
|
|
13
|
+
return Object.keys(keySet).map((it) => parseInt(it, 10));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Set the visibility of a segmentation representation for a given tool group. It fires
|
|
18
|
+
* a SEGMENTATION_REPRESENTATION_MODIFIED event. Visibility true will show all segments
|
|
19
|
+
* and visibility false will hide all segments"
|
|
20
|
+
*
|
|
21
|
+
* @triggers SEGMENTATION_REPRESENTATION_MODIFIED
|
|
22
|
+
* @param toolGroupId - The Id of the tool group that contains the segmentation.
|
|
23
|
+
* @param segmentationRepresentationUID - The id of the segmentation representation to modify its visibility.
|
|
24
|
+
* @param visibility - boolean
|
|
25
|
+
*/
|
|
26
|
+
function setSegmentationVisibility(
|
|
27
|
+
toolGroupId: string,
|
|
28
|
+
segmentationRepresentationUID: string,
|
|
29
|
+
visibility: boolean
|
|
30
|
+
): void {
|
|
31
|
+
const toolGroupSegmentationRepresentations =
|
|
32
|
+
getSegmentationRepresentations(toolGroupId);
|
|
33
|
+
|
|
34
|
+
if (!toolGroupSegmentationRepresentations) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const representation = toolGroupSegmentationRepresentations.find(
|
|
39
|
+
(representation: ToolGroupSpecificRepresentation) =>
|
|
40
|
+
representation.segmentationRepresentationUID ===
|
|
41
|
+
segmentationRepresentationUID
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (!representation) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { segmentsHidden, segmentationId } = representation;
|
|
49
|
+
|
|
50
|
+
const indices = getSegmentationIndices(segmentationId);
|
|
51
|
+
|
|
52
|
+
// if visibility is set to be true, we need to remove all the segments
|
|
53
|
+
// from the segmentsHidden set, otherwise we need to add all the segments
|
|
54
|
+
// to the segmentsHidden set
|
|
55
|
+
if (visibility) {
|
|
56
|
+
segmentsHidden.clear();
|
|
57
|
+
} else {
|
|
58
|
+
indices.forEach((index) => {
|
|
59
|
+
segmentsHidden.add(index);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
triggerSegmentationRepresentationModified(
|
|
64
|
+
toolGroupId,
|
|
65
|
+
representation.segmentationRepresentationUID
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get the visibility of a segmentation data for a given tool group.
|
|
71
|
+
*
|
|
72
|
+
* @param toolGroupId - The Id of the tool group that the segmentation
|
|
73
|
+
* data belongs to.
|
|
74
|
+
* @param segmentationRepresentationUID - The id of the segmentation data to get
|
|
75
|
+
* @returns A boolean value that indicates whether the segmentation data is visible or
|
|
76
|
+
* not on the toolGroup
|
|
77
|
+
*/
|
|
78
|
+
function getSegmentationVisibility(
|
|
79
|
+
toolGroupId: string,
|
|
80
|
+
segmentationRepresentationUID: string
|
|
81
|
+
): boolean | undefined {
|
|
82
|
+
const toolGroupSegmentationRepresentations =
|
|
83
|
+
getSegmentationRepresentations(toolGroupId);
|
|
84
|
+
|
|
85
|
+
const representation = toolGroupSegmentationRepresentations.find(
|
|
86
|
+
(representation: ToolGroupSpecificRepresentation) =>
|
|
87
|
+
representation.segmentationRepresentationUID ===
|
|
88
|
+
segmentationRepresentationUID
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (!representation) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const { segmentsHidden } = representation;
|
|
96
|
+
|
|
97
|
+
return segmentsHidden.size === 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Set the visibility of the given segment indices to the given visibility. This
|
|
102
|
+
* is a helper to set the visibility of multiple segments at once and reduces
|
|
103
|
+
* the number of events fired.
|
|
104
|
+
*
|
|
105
|
+
* @param toolGroupId - The tool group id of the segmentation representation.
|
|
106
|
+
* @param segmentationRepresentationUID - The UID of the segmentation
|
|
107
|
+
* representation.
|
|
108
|
+
* @param segmentIndices - The indices of the segments to be hidden/shown.
|
|
109
|
+
* @param visibility - The visibility to set the segments to.
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
function setSegmentsVisibility(
|
|
113
|
+
toolGroupId: string,
|
|
114
|
+
segmentationRepresentationUID: string,
|
|
115
|
+
segmentIndices: number[],
|
|
116
|
+
visibility: boolean
|
|
117
|
+
): void {
|
|
118
|
+
const segRepresentation =
|
|
119
|
+
SegmentationState.getSegmentationRepresentationByUID(
|
|
120
|
+
toolGroupId,
|
|
121
|
+
segmentationRepresentationUID
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
if (!segRepresentation) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
segmentIndices.forEach((segmentIndex) => {
|
|
129
|
+
visibility
|
|
130
|
+
? segRepresentation.segmentsHidden.delete(segmentIndex)
|
|
131
|
+
: segRepresentation.segmentsHidden.add(segmentIndex);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
triggerSegmentationRepresentationModified(
|
|
135
|
+
toolGroupId,
|
|
136
|
+
segmentationRepresentationUID
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function setSegmentVisibility(
|
|
141
|
+
toolGroupId: string,
|
|
142
|
+
segmentationRepresentationUID: string,
|
|
143
|
+
segmentIndex: number,
|
|
144
|
+
visibility: boolean
|
|
145
|
+
): void {
|
|
146
|
+
const segRepresentation =
|
|
147
|
+
SegmentationState.getSegmentationRepresentationByUID(
|
|
148
|
+
toolGroupId,
|
|
149
|
+
segmentationRepresentationUID
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
if (!segRepresentation) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
visibility
|
|
157
|
+
? segRepresentation.segmentsHidden.delete(segmentIndex)
|
|
158
|
+
: segRepresentation.segmentsHidden.add(segmentIndex);
|
|
159
|
+
|
|
160
|
+
triggerSegmentationRepresentationModified(
|
|
161
|
+
toolGroupId,
|
|
162
|
+
segmentationRepresentationUID
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
setSegmentationVisibility,
|
|
168
|
+
getSegmentationVisibility,
|
|
169
|
+
setSegmentVisibility,
|
|
170
|
+
setSegmentsVisibility,
|
|
171
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SegmentationPublicInput,
|
|
3
|
+
Segmentation,
|
|
4
|
+
} from '../../../types/SegmentationStateTypes';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* It takes in a segmentation input and returns a segmentation with default values
|
|
8
|
+
* @param segmentationInput - The input to the segmentation.
|
|
9
|
+
* @returns A Segmentation object.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function normalizeSegmentationInput(
|
|
13
|
+
segmentationInput: SegmentationPublicInput
|
|
14
|
+
): Segmentation {
|
|
15
|
+
const { segmentationId, representation } = segmentationInput;
|
|
16
|
+
|
|
17
|
+
// Todo: we should be able to let the user pass in non-default values for
|
|
18
|
+
// cachedStats, label, activeSegmentIndex, etc.
|
|
19
|
+
return {
|
|
20
|
+
segmentationId,
|
|
21
|
+
cachedStats: {},
|
|
22
|
+
segmentLabels: {},
|
|
23
|
+
label: null,
|
|
24
|
+
segmentsLocked: new Set(),
|
|
25
|
+
type: representation.type,
|
|
26
|
+
activeSegmentIndex: 1,
|
|
27
|
+
representationData: {
|
|
28
|
+
[representation.type]: {
|
|
29
|
+
...representation.data,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default normalizeSegmentationInput;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as Enums from '../../../enums';
|
|
2
|
+
import { SegmentationPublicInput } from '../../../types/SegmentationStateTypes';
|
|
3
|
+
import validateLabelmap from '../../../tools/displayTools/Labelmap/validateRepresentationData';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the segmentationInputArray is valid meaning it contains
|
|
7
|
+
* correct representationProps for the representation type that is being used.
|
|
8
|
+
*
|
|
9
|
+
* @param segmentationInputArray - Array of segmentation inputs
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function validateSegmentationInput(
|
|
13
|
+
segmentationInputArray: SegmentationPublicInput[]
|
|
14
|
+
): void {
|
|
15
|
+
if (!segmentationInputArray || !segmentationInputArray.length) {
|
|
16
|
+
throw new Error('The segmentationInputArray is undefined or empty array');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
segmentationInputArray.forEach((segmentationInput) => {
|
|
20
|
+
if (segmentationInput.segmentationId === undefined) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
'The segmentationInput.segmentationId is undefined, please provide a valid segmentationId'
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (segmentationInput.representation === undefined) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
'The segmentationInput.representation is undefined, please provide a valid representation'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
segmentationInput.representation.type ===
|
|
34
|
+
Enums.SegmentationRepresentations.Labelmap
|
|
35
|
+
) {
|
|
36
|
+
validateLabelmap(segmentationInput);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default validateSegmentationInput;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import removeSegmentationsFromToolGroup from './removeSegmentationsFromToolGroup';
|
|
2
|
+
import addSegmentations from './addSegmentations';
|
|
3
|
+
import addSegmentationRepresentations from './addSegmentationRepresentations';
|
|
4
|
+
|
|
5
|
+
import * as activeSegmentation from './activeSegmentation';
|
|
6
|
+
import * as segmentLocking from './segmentLocking';
|
|
7
|
+
import * as state from './segmentationState';
|
|
8
|
+
import * as config from './config';
|
|
9
|
+
import * as segmentIndex from './segmentIndex';
|
|
10
|
+
import * as triggerSegmentationEvents from './triggerSegmentationEvents';
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
state,
|
|
14
|
+
addSegmentations,
|
|
15
|
+
activeSegmentation,
|
|
16
|
+
addSegmentationRepresentations,
|
|
17
|
+
removeSegmentationsFromToolGroup,
|
|
18
|
+
segmentLocking,
|
|
19
|
+
config,
|
|
20
|
+
segmentIndex,
|
|
21
|
+
triggerSegmentationEvents,
|
|
22
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
|
|
2
|
+
import { labelmapDisplay } from '../../tools/displayTools/Labelmap';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getSegmentationRepresentations,
|
|
6
|
+
getSegmentationRepresentationByUID,
|
|
7
|
+
} from './segmentationState';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Remove the segmentation representation (representation) from the viewports of the toolGroup.
|
|
11
|
+
* @param toolGroupId - The Id of the toolGroup to remove the segmentation from.
|
|
12
|
+
* @param segmentationRepresentationUIDs - The UIDs of the segmentation representations to remove.
|
|
13
|
+
* @param immediate - if True the viewport will be re-rendered immediately.
|
|
14
|
+
*/
|
|
15
|
+
function removeSegmentationsFromToolGroup(
|
|
16
|
+
toolGroupId: string,
|
|
17
|
+
segmentationRepresentationUIDs?: string[] | undefined,
|
|
18
|
+
immediate?: boolean
|
|
19
|
+
): void {
|
|
20
|
+
const toolGroupSegRepresentations =
|
|
21
|
+
getSegmentationRepresentations(toolGroupId);
|
|
22
|
+
|
|
23
|
+
if (
|
|
24
|
+
!toolGroupSegRepresentations ||
|
|
25
|
+
toolGroupSegRepresentations.length === 0
|
|
26
|
+
) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const toolGroupSegRepresentationUIDs = toolGroupSegRepresentations.map(
|
|
31
|
+
(representation) => representation.segmentationRepresentationUID
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
let segRepresentationUIDsToRemove = segmentationRepresentationUIDs;
|
|
35
|
+
if (segRepresentationUIDsToRemove) {
|
|
36
|
+
// make sure the segmentationDataUIDs that are going to be removed belong
|
|
37
|
+
// to the toolGroup
|
|
38
|
+
const invalidSegRepresentationUIDs = segmentationRepresentationUIDs.filter(
|
|
39
|
+
(segRepresentationUID) =>
|
|
40
|
+
!toolGroupSegRepresentationUIDs.includes(segRepresentationUID)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (invalidSegRepresentationUIDs.length > 0) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`The following segmentationRepresentationUIDs are not part of the toolGroup: ${JSON.stringify(
|
|
46
|
+
invalidSegRepresentationUIDs
|
|
47
|
+
)}`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
// remove all segmentation representations
|
|
52
|
+
segRepresentationUIDsToRemove = toolGroupSegRepresentationUIDs;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
segRepresentationUIDsToRemove.forEach((segmentationDataUID) => {
|
|
56
|
+
_removeSegmentation(toolGroupId, segmentationDataUID, immediate);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _removeSegmentation(
|
|
61
|
+
toolGroupId: string,
|
|
62
|
+
segmentationRepresentationUID: string,
|
|
63
|
+
immediate?: boolean
|
|
64
|
+
): void {
|
|
65
|
+
const segmentationRepresentation = getSegmentationRepresentationByUID(
|
|
66
|
+
toolGroupId,
|
|
67
|
+
segmentationRepresentationUID
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const { type } = segmentationRepresentation;
|
|
71
|
+
|
|
72
|
+
if (type === SegmentationRepresentations.Labelmap) {
|
|
73
|
+
labelmapDisplay.removeSegmentationRepresentation(
|
|
74
|
+
toolGroupId,
|
|
75
|
+
segmentationRepresentationUID,
|
|
76
|
+
immediate
|
|
77
|
+
);
|
|
78
|
+
} else if (type === SegmentationRepresentations.Contour) {
|
|
79
|
+
console.debug('Contour representation is not supported yet, ignoring...');
|
|
80
|
+
} else {
|
|
81
|
+
throw new Error(`The representation ${type} is not supported yet`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default removeSegmentationsFromToolGroup;
|