@cornerstonejs/tools 5.0.0-beta.1 → 5.0.0
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.d.ts +4 -0
- package/dist/esm/drawingSvg/drawPath.d.ts +3 -0
- package/dist/esm/drawingSvg/drawPath.js +4 -1
- package/dist/esm/eventListeners/keyboard/keyDownListener.js +2 -2
- package/dist/esm/eventListeners/mouse/getMouseEventPoints.d.ts +1 -1
- package/dist/esm/eventListeners/mouse/getMouseEventPoints.js +19 -1
- package/dist/esm/eventListeners/mouse/mouseDoubleClickListener.js +8 -1
- package/dist/esm/eventListeners/mouse/mouseDownListener.js +37 -5
- package/dist/esm/eventListeners/mouse/mouseMoveListener.js +3 -0
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +60 -92
- package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +49 -21
- package/dist/esm/eventListeners/segmentation/labelmap/performStackLabelmapUpdate.js +7 -13
- package/dist/esm/eventListeners/segmentation/labelmap/performVolumeLabelmapUpdate.js +44 -18
- package/dist/esm/eventListeners/touch/getTouchEventPoints.js +27 -4
- package/dist/esm/eventListeners/touch/touchStartListener.js +27 -9
- package/dist/esm/eventListeners/wheel/wheelListener.js +5 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/init.js +2 -0
- package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +10 -4
- package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +23 -20
- package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.d.ts +12 -0
- package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.js +7 -0
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -10
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +28 -149
- package/dist/esm/stateManagement/segmentation/addColorLUT.js +7 -1
- package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.js +16 -1
- package/dist/esm/stateManagement/segmentation/helpers/clearSegmentValue.js +9 -7
- package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.js +3 -2
- package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.d.ts +5 -0
- package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.js +58 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.d.ts +52 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.js +246 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.d.ts +1 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.js +1 -0
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +12 -1
- package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -3
- package/dist/esm/stateManagement/segmentation/labelmapModel/index.d.ts +9 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/index.js +7 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.d.ts +54 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.js +224 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.d.ts +6 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.js +39 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.d.ts +23 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.js +269 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.d.ts +15 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.js +160 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.d.ts +4 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.js +42 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.d.ts +11 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.js +73 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.d.ts +17 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.js +75 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.d.ts +5 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.js +106 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentModel.d.ts +11 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentModel.js +19 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentationModel.d.ts +12 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentationModel.js +23 -0
- package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +6 -10
- package/dist/esm/stateManagement/segmentation/segmentIndex.js +24 -0
- package/dist/esm/stateManagement/segmentation/segmentationEventManager.js +2 -9
- package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
- package/dist/esm/stateManagement/segmentation/segmentationState.js +4 -1
- package/dist/esm/store/SynchronizerManager/Synchronizer.d.ts +3 -1
- package/dist/esm/store/state.js +2 -1
- package/dist/esm/synchronizers/callbacks/imageSliceSyncCallback.js +12 -3
- package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +5 -2
- package/dist/esm/synchronizers/callbacks/zoomPanSyncCallback.js +51 -3
- package/dist/esm/synchronizers/synchronizers/createPresentationViewSynchronizer.d.ts +1 -1
- package/dist/esm/tools/AdvancedMagnifyTool.js +4 -1
- package/dist/esm/tools/CrosshairsTool.d.ts +4 -0
- package/dist/esm/tools/CrosshairsTool.js +95 -41
- package/dist/esm/tools/MagnifyTool.js +3 -1
- package/dist/esm/tools/OrientationControllerTool.d.ts +45 -0
- package/dist/esm/tools/OrientationControllerTool.js +454 -0
- package/dist/esm/tools/OrientationMarkerTool.js +4 -4
- package/dist/esm/tools/PanTool.js +26 -3
- package/dist/esm/tools/PlanarRotateTool.js +19 -4
- package/dist/esm/tools/ReferenceCursors.js +7 -1
- package/dist/esm/tools/SculptorTool/CircleSculptCursor.js +1 -1
- package/dist/esm/tools/TrackballRotateTool.js +3 -2
- package/dist/esm/tools/VolumeCroppingControlTool.d.ts +10 -35
- package/dist/esm/tools/VolumeCroppingControlTool.js +179 -699
- package/dist/esm/tools/VolumeCroppingTool.d.ts +34 -32
- package/dist/esm/tools/VolumeCroppingTool.js +813 -532
- package/dist/esm/tools/WindowLevelTool.d.ts +2 -1
- package/dist/esm/tools/WindowLevelTool.js +48 -4
- package/dist/esm/tools/ZoomTool.d.ts +8 -0
- package/dist/esm/tools/ZoomTool.js +92 -11
- package/dist/esm/tools/annotation/AngleTool.js +38 -32
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +30 -28
- package/dist/esm/tools/annotation/BidirectionalTool.js +51 -49
- package/dist/esm/tools/annotation/CircleROITool.d.ts +1 -0
- package/dist/esm/tools/annotation/CircleROITool.js +89 -51
- package/dist/esm/tools/annotation/CobbAngleTool.js +1 -1
- package/dist/esm/tools/annotation/DragProbeTool.js +1 -1
- package/dist/esm/tools/annotation/ETDRSGridTool.js +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +46 -39
- package/dist/esm/tools/annotation/HeightTool.js +1 -1
- package/dist/esm/tools/annotation/KeyImageTool.js +11 -11
- package/dist/esm/tools/annotation/LabelTool.js +37 -35
- package/dist/esm/tools/annotation/LengthTool.js +35 -33
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +6 -4
- package/dist/esm/tools/annotation/LivewireContourTool.js +4 -8
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +6 -4
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +3 -4
- package/dist/esm/tools/annotation/ProbeTool.js +66 -56
- package/dist/esm/tools/annotation/RectangleROITool.js +48 -37
- package/dist/esm/tools/annotation/RegionSegmentPlusTool.js +1 -1
- package/dist/esm/tools/annotation/RegionSegmentTool.js +1 -1
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +1 -1
- package/dist/esm/tools/annotation/SplineROITool.js +60 -56
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +1 -1
- package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +57 -55
- package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
- package/dist/esm/tools/base/AnnotationDisplayTool.js +9 -6
- package/dist/esm/tools/base/AnnotationTool.js +2 -1
- package/dist/esm/tools/base/BaseTool.js +16 -10
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -1
- package/dist/esm/tools/base/GrowCutBaseTool.js +2 -2
- package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -4
- package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +15 -85
- package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.d.ts +5 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.js +191 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +4 -3
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +48 -209
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.d.ts +3 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.js +51 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.d.ts +4 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.js +3 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.d.ts +14 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +143 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.d.ts +40 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.js +79 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.d.ts +3 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.js +18 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.d.ts +9 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.js +56 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.d.ts +11 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.js +35 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.d.ts +48 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.js +0 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.d.ts +13 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.js +34 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.d.ts +2 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.js +1 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.d.ts +8 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.js +18 -0
- package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js +2 -2
- package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.d.ts +3 -0
- package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.js +16 -0
- package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.d.ts +2 -0
- package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +135 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.d.ts +16 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.js +267 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.d.ts +27 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.js +185 -0
- package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.d.ts +1 -0
- package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.js +16 -0
- package/dist/esm/tools/index.d.ts +2 -1
- package/dist/esm/tools/index.js +2 -1
- package/dist/esm/tools/segmentation/BrushTool.d.ts +9 -2
- package/dist/esm/tools/segmentation/BrushTool.js +123 -26
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +19 -36
- package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +2 -3
- package/dist/esm/tools/segmentation/LabelmapBaseTool.js +77 -46
- package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -3
- package/dist/esm/tools/segmentation/PaintFillTool.js +11 -4
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +2 -0
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +16 -8
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +13 -6
- package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +63 -61
- package/dist/esm/tools/segmentation/SegmentSelectTool.js +4 -4
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +11 -31
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +7 -0
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +47 -24
- package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +49 -21
- package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +2 -2
- package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +5 -1
- package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +2 -2
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
- package/dist/esm/tools/segmentation/strategies/compositions/setValue.js +14 -6
- package/dist/esm/tools/segmentation/strategies/fillCircle.d.ts +3 -1
- package/dist/esm/tools/segmentation/strategies/fillCircle.js +38 -31
- package/dist/esm/tools/segmentation/strategies/fillSphere.js +11 -3
- package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.d.ts +4 -0
- package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.js +23 -0
- package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +1 -1
- package/dist/esm/tools/segmentation/strategies/utils/handleUseSegmentCenterIndex.js +12 -11
- package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.d.ts +4 -0
- package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.js +41 -0
- package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.d.ts +3 -0
- package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.js +31 -0
- package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.d.ts +3 -0
- package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.js +38 -0
- package/dist/esm/tools/segmentation/utils/LazyBrushEditController.d.ts +19 -0
- package/dist/esm/tools/segmentation/utils/LazyBrushEditController.js +55 -0
- package/dist/esm/tools/segmentation/utils/lazyBrushPreview.d.ts +3 -0
- package/dist/esm/tools/segmentation/utils/lazyBrushPreview.js +34 -0
- package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.d.ts +3 -0
- package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.js +42 -0
- package/dist/esm/types/ISynchronizerEventHandler.d.ts +2 -1
- package/dist/esm/types/LabelmapToolOperationData.d.ts +5 -0
- package/dist/esm/types/LabelmapTypes.d.ts +29 -6
- package/dist/esm/types/SegmentationStateTypes.d.ts +6 -0
- package/dist/esm/utilities/calibrateImageSpacing.js +17 -2
- package/dist/esm/utilities/contours/AnnotationToPointData.js +1 -1
- package/dist/esm/utilities/draw3D/addLine3DBetweenPoints.d.ts +7 -0
- package/dist/esm/utilities/draw3D/addLine3DBetweenPoints.js +34 -0
- package/dist/esm/utilities/draw3D/calculateAdaptiveSphereRadius.d.ts +6 -0
- package/dist/esm/utilities/draw3D/calculateAdaptiveSphereRadius.js +7 -0
- package/dist/esm/utilities/draw3D/index.d.ts +2 -0
- package/dist/esm/utilities/draw3D/index.js +2 -0
- package/dist/esm/utilities/drawing/getTextBoxCoordsCanvas.js +22 -14
- package/dist/esm/utilities/getCenterAndRadiusInCanvas.d.ts +6 -0
- package/dist/esm/utilities/getCenterAndRadiusInCanvas.js +26 -0
- package/dist/esm/utilities/getEllipseWorldCoordinates.d.ts +2 -0
- package/dist/esm/utilities/getEllipseWorldCoordinates.js +26 -0
- package/dist/esm/utilities/getSphereBoundsInfo.js +5 -1
- package/dist/esm/utilities/getViewportICamera.d.ts +4 -0
- package/dist/esm/utilities/getViewportICamera.js +23 -0
- package/dist/esm/utilities/getViewportsForAnnotation.js +5 -1
- package/dist/esm/utilities/index.d.ts +2 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/interactionDragCoordinator.d.ts +5 -0
- package/dist/esm/utilities/interactionDragCoordinator.js +16 -0
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +9 -7
- package/dist/esm/utilities/pointInSurroundingSphereCallback.js +8 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +121 -118
- package/dist/esm/utilities/segmentation/SegmentStatsCalculator.js +5 -4
- package/dist/esm/utilities/segmentation/VolumetricCalculator.js +1 -1
- package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js +1 -1
- package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentation.js +1 -1
- package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentationVolume.js +11 -2
- package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +36 -17
- package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +42 -25
- package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -30
- package/dist/esm/utilities/segmentation/index.d.ts +2 -1
- package/dist/esm/utilities/segmentation/index.js +2 -1
- package/dist/esm/utilities/segmentation/utilsForWorker.js +6 -2
- package/dist/esm/utilities/segmentation/validateLabelmap.js +1 -1
- package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +0 -1
- package/dist/esm/utilities/touch/index.js +3 -2
- package/dist/esm/utilities/viewportCapabilities.d.ts +16 -0
- package/dist/esm/utilities/viewportCapabilities.js +18 -0
- package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.d.ts +1 -1
- package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.js +12 -4
- package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.d.ts +1 -1
- package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.js +11 -4
- package/dist/esm/utilities/viewportFilters/getViewportIdsWithToolToRender.js +1 -1
- package/dist/esm/utilities/viewportPresentation.d.ts +3 -0
- package/dist/esm/utilities/viewportPresentation.js +26 -0
- package/dist/esm/utilities/volumeCropping/computePlanePlaneIntersection.d.ts +6 -0
- package/dist/esm/utilities/volumeCropping/computePlanePlaneIntersection.js +37 -0
- package/dist/esm/utilities/volumeCropping/constants.d.ts +31 -0
- package/dist/esm/utilities/volumeCropping/constants.js +31 -0
- package/dist/esm/utilities/volumeCropping/copyClippingPlanes.d.ts +2 -0
- package/dist/esm/utilities/volumeCropping/copyClippingPlanes.js +6 -0
- package/dist/esm/utilities/volumeCropping/extractVolumeDirectionVectors.d.ts +9 -0
- package/dist/esm/utilities/volumeCropping/extractVolumeDirectionVectors.js +9 -0
- package/dist/esm/utilities/volumeCropping/findLineBoundsIntersection.d.ts +5 -0
- package/dist/esm/utilities/volumeCropping/findLineBoundsIntersection.js +50 -0
- package/dist/esm/utilities/volumeCropping/getColorKeyForPlaneIndex.d.ts +1 -0
- package/dist/esm/utilities/volumeCropping/getColorKeyForPlaneIndex.js +13 -0
- package/dist/esm/utilities/volumeCropping/getOrientationFromNormal.d.ts +2 -0
- package/dist/esm/utilities/volumeCropping/getOrientationFromNormal.js +19 -0
- package/dist/esm/utilities/volumeCropping/index.d.ts +9 -0
- package/dist/esm/utilities/volumeCropping/index.js +9 -0
- package/dist/esm/utilities/volumeCropping/parseCornerKey.d.ts +8 -0
- package/dist/esm/utilities/volumeCropping/parseCornerKey.js +11 -0
- package/dist/esm/utilities/volumeCropping/types.d.ts +5 -0
- package/dist/esm/utilities/volumeCropping/types.js +0 -0
- package/dist/esm/utilities/vtkjs/AnnotatedRhombicuboctahedronActor/index.d.ts +31 -0
- package/dist/esm/utilities/vtkjs/AnnotatedRhombicuboctahedronActor/index.js +391 -0
- package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.d.ts +69 -0
- package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.js +804 -0
- package/dist/esm/utilities/vtkjs/RhombicuboctahedronSource/index.d.ts +7 -0
- package/dist/esm/utilities/vtkjs/RhombicuboctahedronSource/index.js +144 -0
- package/dist/esm/utilities/vtkjs/index.d.ts +3 -0
- package/dist/esm/utilities/vtkjs/index.js +3 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +10 -9
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { utilities as csUtils } from '@cornerstonejs/core';
|
|
2
3
|
import { state as annotationState } from '../../../stateManagement/annotation';
|
|
3
4
|
import getInterpolationDataCollection from '../../contours/interpolation/getInterpolationDataCollection';
|
|
@@ -11,8 +12,7 @@ const ChangeTypesForInterpolation = [
|
|
|
11
12
|
ChangeTypes.HandlesUpdated,
|
|
12
13
|
ChangeTypes.InterpolationUpdated,
|
|
13
14
|
];
|
|
14
|
-
|
|
15
|
-
static { this.toolNames = []; }
|
|
15
|
+
class InterpolationManager {
|
|
16
16
|
static addTool(toolName) {
|
|
17
17
|
if (!this.toolNames.includes(toolName)) {
|
|
18
18
|
this.toolNames.push(toolName);
|
|
@@ -25,7 +25,7 @@ export default class InterpolationManager {
|
|
|
25
25
|
}
|
|
26
26
|
static acceptAutoGenerated(annotationGroupSelector, selector = {}) {
|
|
27
27
|
const { toolNames, segmentationId, segmentIndex, sliceIndex } = selector;
|
|
28
|
-
for (const toolName of toolNames ||
|
|
28
|
+
for (const toolName of toolNames || _a.toolNames) {
|
|
29
29
|
const annotations = annotationState.getAnnotations(toolName, annotationGroupSelector);
|
|
30
30
|
if (!annotations?.length) {
|
|
31
31
|
continue;
|
|
@@ -55,124 +55,127 @@ export default class InterpolationManager {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
annotation.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const filterData = [
|
|
88
|
-
{
|
|
89
|
-
key: 'segmentIndex',
|
|
90
|
-
value: annotation.data.segmentation.segmentIndex,
|
|
91
|
-
parentKey: (annotation) => annotation.data.segmentation,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
key: 'viewPlaneNormal',
|
|
95
|
-
value: annotation.metadata.viewPlaneNormal,
|
|
96
|
-
parentKey: (annotation) => annotation.metadata,
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: 'viewUp',
|
|
100
|
-
value: annotation.metadata.viewUp,
|
|
101
|
-
parentKey: (annotation) => annotation.metadata,
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
let interpolationAnnotations = getInterpolationDataCollection(viewportData, filterData);
|
|
105
|
-
const { sliceIndex } = annotation.metadata;
|
|
106
|
-
const skipUIDs = new Set();
|
|
107
|
-
interpolationAnnotations.forEach((interpolationAnnotation) => {
|
|
108
|
-
if (interpolationAnnotation.interpolationCompleted ||
|
|
109
|
-
interpolationAnnotation.metadata.sliceIndex === sliceIndex) {
|
|
110
|
-
const { interpolationUID } = interpolationAnnotation;
|
|
111
|
-
skipUIDs.add(interpolationUID);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
interpolationAnnotations = interpolationAnnotations.filter((interpolationAnnotation) => !skipUIDs.has(interpolationAnnotation.interpolationUID));
|
|
115
|
-
annotation.interpolationUID =
|
|
116
|
-
interpolationAnnotations[0]?.interpolationUID || uuidv4();
|
|
117
|
-
viewportData.interpolationUID = annotation.interpolationUID;
|
|
118
|
-
interpolate(viewportData);
|
|
119
|
-
}; }
|
|
120
|
-
static { this.handleAnnotationUpdate = (evt) => {
|
|
121
|
-
const annotation = evt.detail.annotation;
|
|
122
|
-
const { changeType = ChangeTypes.HandlesUpdated } = evt.detail;
|
|
123
|
-
if (!annotation?.metadata) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const { toolName, originalToolName } = annotation.metadata;
|
|
127
|
-
if ((!this.toolNames.includes(toolName) &&
|
|
128
|
-
!this.toolNames.includes(originalToolName)) ||
|
|
129
|
-
!ChangeTypesForInterpolation.includes(changeType)) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const viewport = getViewportForAnnotation(annotation);
|
|
133
|
-
if (!viewport) {
|
|
134
|
-
console.warn('Unable to find matching viewport for annotation interpolation', annotation);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (annotation.autoGenerated) {
|
|
138
|
-
addContourSegmentationAnnotation(annotation);
|
|
139
|
-
annotation.autoGenerated = false;
|
|
140
|
-
}
|
|
141
|
-
const sliceData = getSliceData(viewport);
|
|
142
|
-
const viewportData = {
|
|
143
|
-
viewport,
|
|
144
|
-
sliceData,
|
|
145
|
-
annotation,
|
|
146
|
-
interpolationUID: annotation.interpolationUID,
|
|
147
|
-
isInterpolationUpdate: changeType === ChangeTypes.InterpolationUpdated,
|
|
148
|
-
};
|
|
58
|
+
}
|
|
59
|
+
_a = InterpolationManager;
|
|
60
|
+
InterpolationManager.toolNames = [];
|
|
61
|
+
InterpolationManager.handleAnnotationCompleted = (evt) => {
|
|
62
|
+
const annotation = evt.detail.annotation;
|
|
63
|
+
if (!annotation?.metadata) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const { toolName, originalToolName } = annotation.metadata;
|
|
67
|
+
if (!_a.toolNames.includes(toolName) &&
|
|
68
|
+
!_a.toolNames.includes(originalToolName)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const viewport = getViewportForAnnotation(annotation);
|
|
72
|
+
if (!viewport) {
|
|
73
|
+
console.warn('Unable to find viewport for', annotation);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const sliceData = getSliceData(viewport);
|
|
77
|
+
const viewportData = {
|
|
78
|
+
viewport,
|
|
79
|
+
sliceData,
|
|
80
|
+
annotation,
|
|
81
|
+
interpolationUID: annotation.interpolationUID,
|
|
82
|
+
};
|
|
83
|
+
const hasInterpolationUID = !!annotation.interpolationUID;
|
|
84
|
+
annotation.autoGenerated = false;
|
|
85
|
+
if (hasInterpolationUID) {
|
|
86
|
+
deleteRelatedAnnotations(viewportData);
|
|
149
87
|
interpolate(viewportData);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const filterData = [
|
|
91
|
+
{
|
|
92
|
+
key: 'segmentIndex',
|
|
93
|
+
value: annotation.data.segmentation.segmentIndex,
|
|
94
|
+
parentKey: (annotation) => annotation.data.segmentation,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: 'viewPlaneNormal',
|
|
98
|
+
value: annotation.metadata.viewPlaneNormal,
|
|
99
|
+
parentKey: (annotation) => annotation.metadata,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
key: 'viewUp',
|
|
103
|
+
value: annotation.metadata.viewUp,
|
|
104
|
+
parentKey: (annotation) => annotation.metadata,
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
let interpolationAnnotations = getInterpolationDataCollection(viewportData, filterData);
|
|
108
|
+
const { sliceIndex } = annotation.metadata;
|
|
109
|
+
const skipUIDs = new Set();
|
|
110
|
+
interpolationAnnotations.forEach((interpolationAnnotation) => {
|
|
111
|
+
if (interpolationAnnotation.interpolationCompleted ||
|
|
112
|
+
interpolationAnnotation.metadata.sliceIndex === sliceIndex) {
|
|
113
|
+
const { interpolationUID } = interpolationAnnotation;
|
|
114
|
+
skipUIDs.add(interpolationUID);
|
|
164
115
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
116
|
+
});
|
|
117
|
+
interpolationAnnotations = interpolationAnnotations.filter((interpolationAnnotation) => !skipUIDs.has(interpolationAnnotation.interpolationUID));
|
|
118
|
+
annotation.interpolationUID =
|
|
119
|
+
interpolationAnnotations[0]?.interpolationUID || uuidv4();
|
|
120
|
+
viewportData.interpolationUID = annotation.interpolationUID;
|
|
121
|
+
interpolate(viewportData);
|
|
122
|
+
};
|
|
123
|
+
InterpolationManager.handleAnnotationUpdate = (evt) => {
|
|
124
|
+
const annotation = evt.detail.annotation;
|
|
125
|
+
const { changeType = ChangeTypes.HandlesUpdated } = evt.detail;
|
|
126
|
+
if (!annotation?.metadata) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const { toolName, originalToolName } = annotation.metadata;
|
|
130
|
+
if ((!_a.toolNames.includes(toolName) &&
|
|
131
|
+
!_a.toolNames.includes(originalToolName)) ||
|
|
132
|
+
!ChangeTypesForInterpolation.includes(changeType)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const viewport = getViewportForAnnotation(annotation);
|
|
136
|
+
if (!viewport) {
|
|
137
|
+
console.warn('Unable to find matching viewport for annotation interpolation', annotation);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (annotation.autoGenerated) {
|
|
141
|
+
addContourSegmentationAnnotation(annotation);
|
|
172
142
|
annotation.autoGenerated = false;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
143
|
+
}
|
|
144
|
+
const sliceData = getSliceData(viewport);
|
|
145
|
+
const viewportData = {
|
|
146
|
+
viewport,
|
|
147
|
+
sliceData,
|
|
148
|
+
annotation,
|
|
149
|
+
interpolationUID: annotation.interpolationUID,
|
|
150
|
+
isInterpolationUpdate: changeType === ChangeTypes.InterpolationUpdated,
|
|
151
|
+
};
|
|
152
|
+
interpolate(viewportData);
|
|
153
|
+
};
|
|
154
|
+
InterpolationManager.handleAnnotationDelete = (evt) => {
|
|
155
|
+
const annotation = evt.detail.annotation;
|
|
156
|
+
if (!annotation?.metadata) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const { toolName } = annotation.metadata;
|
|
160
|
+
if (!_a.toolNames.includes(toolName) || annotation.autoGenerated) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const viewport = getViewportForAnnotation(annotation);
|
|
164
|
+
if (!viewport) {
|
|
165
|
+
console.warn("No viewport, can't delete interpolated results", annotation);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const sliceData = getSliceData(viewport);
|
|
169
|
+
const viewportData = {
|
|
170
|
+
viewport,
|
|
171
|
+
sliceData,
|
|
172
|
+
annotation,
|
|
173
|
+
interpolationUID: annotation.interpolationUID,
|
|
174
|
+
};
|
|
175
|
+
annotation.autoGenerated = false;
|
|
176
|
+
deleteRelatedAnnotations(viewportData);
|
|
177
|
+
};
|
|
178
|
+
export default InterpolationManager;
|
|
176
179
|
function getSliceData(viewport) {
|
|
177
180
|
const sliceData = {
|
|
178
181
|
numberOfSlices: viewport.getNumberOfSlices(),
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { InstanceVolumetricCalculator } from './VolumetricCalculator';
|
|
2
|
-
|
|
3
|
-
static { this.calculators = new Map(); }
|
|
4
|
-
static { this.indices = []; }
|
|
5
|
-
static { this.mode = 'collective'; }
|
|
2
|
+
class SegmentStatsCalculator {
|
|
6
3
|
static statsInit(options) {
|
|
7
4
|
const { storePointData, indices, mode } = options;
|
|
8
5
|
this.mode = mode;
|
|
@@ -42,3 +39,7 @@ export default class SegmentStatsCalculator {
|
|
|
42
39
|
return calculator.getStatistics(options);
|
|
43
40
|
}
|
|
44
41
|
}
|
|
42
|
+
SegmentStatsCalculator.calculators = new Map();
|
|
43
|
+
SegmentStatsCalculator.indices = [];
|
|
44
|
+
SegmentStatsCalculator.mode = 'collective';
|
|
45
|
+
export default SegmentStatsCalculator;
|
|
@@ -59,7 +59,6 @@ function volumetricGetStatistics(state, stats, options) {
|
|
|
59
59
|
return stats;
|
|
60
60
|
}
|
|
61
61
|
export class VolumetricCalculator extends BasicStatsCalculator {
|
|
62
|
-
static { this.volumetricState = createVolumetricState(); }
|
|
63
62
|
static statsInit(options) {
|
|
64
63
|
super.statsInit(options);
|
|
65
64
|
this.volumetricState = createVolumetricState();
|
|
@@ -79,6 +78,7 @@ export class VolumetricCalculator extends BasicStatsCalculator {
|
|
|
79
78
|
return volumetricGetStatistics(this.volumetricState, stats, optionsWithUnit);
|
|
80
79
|
}
|
|
81
80
|
}
|
|
81
|
+
VolumetricCalculator.volumetricState = createVolumetricState();
|
|
82
82
|
export class InstanceVolumetricCalculator extends InstanceBasicStatsCalculator {
|
|
83
83
|
constructor(options) {
|
|
84
84
|
super(options);
|
|
@@ -15,7 +15,7 @@ export default async function createLabelmapVolumeForViewport(input) {
|
|
|
15
15
|
segmentationId = `${uid}-based-segmentation-${options?.volumeId ?? csUtils.uuidv4().slice(0, 8)}`;
|
|
16
16
|
}
|
|
17
17
|
if (options) {
|
|
18
|
-
const properties =
|
|
18
|
+
const properties = csUtils.deepClone(options);
|
|
19
19
|
await volumeLoader.createLocalVolume(segmentationId, properties);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
@@ -17,7 +17,7 @@ export function getReferenceVolumeForSegmentation(segmentationId) {
|
|
|
17
17
|
}
|
|
18
18
|
referenceImageIds = imageIds.map((imageId) => cache.getImage(imageId).referencedImageId);
|
|
19
19
|
}
|
|
20
|
-
else if (
|
|
20
|
+
else if (labelmap.volumeId) {
|
|
21
21
|
const { volumeId, referencedVolumeId } = labelmap;
|
|
22
22
|
if (referencedVolumeId) {
|
|
23
23
|
const refVolume = cache.getVolume(referencedVolumeId);
|
|
@@ -11,9 +11,18 @@ export function getReferenceVolumeForSegmentationVolume(segmentationVolumeId) {
|
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
13
|
const imageIds = segmentationVolume.imageIds;
|
|
14
|
-
const
|
|
14
|
+
const segmentationImageId = imageIds?.[0];
|
|
15
|
+
if (!segmentationImageId) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const image = cache.getImage(segmentationImageId);
|
|
19
|
+
if (!image) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
15
22
|
const referencedImageId = image.referencedImageId;
|
|
16
|
-
let volumeInfo =
|
|
23
|
+
let volumeInfo = referencedImageId
|
|
24
|
+
? cache.getVolumeContainingImageId(referencedImageId)
|
|
25
|
+
: undefined;
|
|
17
26
|
if (!volumeInfo?.volume) {
|
|
18
27
|
volumeInfo = cache.getVolumeContainingImageId(image.imageId);
|
|
19
28
|
}
|
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
import { BaseVolumeViewport, cache, utilities } from '@cornerstonejs/core';
|
|
2
2
|
import { getSegmentation, getCurrentLabelmapImageIdForViewport, } from '../../stateManagement/segmentation/segmentationState';
|
|
3
3
|
import { getLabelmapActorEntry } from '../../stateManagement/segmentation/helpers';
|
|
4
|
+
import getViewportLabelmapRenderMode from '../../stateManagement/segmentation/helpers/getViewportLabelmapRenderMode';
|
|
5
|
+
import { getLabelmaps, getOrCreateLabelmapVolume, getSegmentIndexForLabelValue, } from '../../stateManagement/segmentation/helpers/labelmapSegmentationState';
|
|
4
6
|
export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { viewport, searchRadius }) {
|
|
5
7
|
const segmentation = getSegmentation(segmentationId);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const viewportRenderMode = viewport
|
|
9
|
+
? getViewportLabelmapRenderMode(viewport)
|
|
10
|
+
: 'unsupported';
|
|
11
|
+
if (viewportRenderMode === 'volume' ||
|
|
12
|
+
viewport instanceof BaseVolumeViewport) {
|
|
13
|
+
for (const layer of getLabelmaps(segmentation)) {
|
|
14
|
+
const segmentationVolume = getOrCreateLabelmapVolume(layer);
|
|
15
|
+
if (!segmentationVolume) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const voxelManager = segmentationVolume.voxelManager;
|
|
19
|
+
const imageData = segmentationVolume.imageData;
|
|
20
|
+
const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
|
|
21
|
+
const labelValue = voxelManager.getAtIJK(indexIJK[0], indexIJK[1], indexIJK[2]);
|
|
22
|
+
const canvasPoint = viewport.worldToCanvas(worldPoint);
|
|
23
|
+
const onEdge = isSegmentOnEdgeCanvas(canvasPoint, labelValue, viewport, imageData, searchRadius);
|
|
24
|
+
if (onEdge && labelValue) {
|
|
25
|
+
return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
|
|
26
|
+
}
|
|
12
27
|
}
|
|
13
|
-
|
|
14
|
-
const imageData = segmentationVolume.imageData;
|
|
15
|
-
const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
|
|
16
|
-
const segmentIndex = voxelManager.getAtIJK(indexIJK[0], indexIJK[1], indexIJK[2]);
|
|
17
|
-
const canvasPoint = viewport.worldToCanvas(worldPoint);
|
|
18
|
-
const onEdge = isSegmentOnEdgeCanvas(canvasPoint, segmentIndex, viewport, imageData, searchRadius);
|
|
19
|
-
return onEdge ? segmentIndex : undefined;
|
|
28
|
+
return;
|
|
20
29
|
}
|
|
21
30
|
const segmentationImageId = getCurrentLabelmapImageIdForViewport(viewport.id, segmentationId);
|
|
31
|
+
if (!segmentationImageId) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
22
34
|
const image = cache.getImage(segmentationImageId);
|
|
23
35
|
if (!image) {
|
|
24
36
|
return;
|
|
25
37
|
}
|
|
26
|
-
const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentationId);
|
|
38
|
+
const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentationId, segmentationImageId);
|
|
27
39
|
const imageData = segmentationActorEntry?.actor.getMapper().getInputData();
|
|
28
40
|
const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
|
|
29
41
|
const dimensions = imageData.getDimensions();
|
|
@@ -32,9 +44,16 @@ export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { vi
|
|
|
32
44
|
dimensions,
|
|
33
45
|
scalarData: imageData.getPointData().getScalars().getData(),
|
|
34
46
|
}));
|
|
35
|
-
const
|
|
36
|
-
const onEdge = isSegmentOnEdgeIJK(indexIJK, dimensions, voxelManager,
|
|
37
|
-
|
|
47
|
+
const labelValue = voxelManager.getAtIJKPoint(indexIJK);
|
|
48
|
+
const onEdge = isSegmentOnEdgeIJK(indexIJK, dimensions, voxelManager, labelValue);
|
|
49
|
+
if (!onEdge || !labelValue) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const layer = getLabelmaps(segmentation).find((candidateLayer) => candidateLayer.imageIds?.includes(segmentationImageId));
|
|
53
|
+
if (!layer) {
|
|
54
|
+
return labelValue;
|
|
55
|
+
}
|
|
56
|
+
return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
|
|
38
57
|
}
|
|
39
58
|
function isSegmentOnEdge(getNeighborIndex, segmentIndex, searchRadius = 1) {
|
|
40
59
|
const neighborRange = Array.from({ length: 2 * searchRadius + 1 }, (_, i) => i - searchRadius);
|
|
@@ -4,6 +4,8 @@ import { getSegmentation, getCurrentLabelmapImageIdsForViewport, } from '../../s
|
|
|
4
4
|
import { getAnnotation } from '../../stateManagement';
|
|
5
5
|
import { isPointInsidePolyline3D } from '../math/polyline';
|
|
6
6
|
import { getLabelmapActorEntry } from '../../stateManagement/segmentation/helpers/getSegmentationActor';
|
|
7
|
+
import getViewportLabelmapRenderMode from '../../stateManagement/segmentation/helpers/getViewportLabelmapRenderMode';
|
|
8
|
+
import { getLabelmaps, getOrCreateLabelmapVolume, getSegmentIndexForLabelValue, } from '../../stateManagement/segmentation/helpers/labelmapSegmentationState';
|
|
7
9
|
export function getSegmentIndexAtWorldPoint(segmentationId, worldPoint, options = {}) {
|
|
8
10
|
const segmentation = getSegmentation(segmentationId);
|
|
9
11
|
const representationData = segmentation.representationData;
|
|
@@ -21,37 +23,52 @@ export function getSegmentIndexAtWorldPoint(segmentationId, worldPoint, options
|
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
export function getSegmentIndexAtWorldForLabelmap(segmentation, worldPoint, { viewport }) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const viewportRenderMode = viewport
|
|
27
|
+
? getViewportLabelmapRenderMode(viewport)
|
|
28
|
+
: 'unsupported';
|
|
29
|
+
if (viewportRenderMode === 'volume' ||
|
|
30
|
+
viewport instanceof BaseVolumeViewport) {
|
|
31
|
+
for (const layer of getLabelmaps(segmentation)) {
|
|
32
|
+
const segmentationVolume = getOrCreateLabelmapVolume(layer);
|
|
33
|
+
if (!segmentationVolume) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const labelValue = segmentationVolume.imageData.getScalarValueFromWorld(worldPoint);
|
|
37
|
+
if (!labelValue) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
|
|
30
41
|
}
|
|
31
|
-
|
|
32
|
-
return segmentIndex;
|
|
42
|
+
return;
|
|
33
43
|
}
|
|
34
44
|
const segmentationImageIds = getCurrentLabelmapImageIdsForViewport(viewport.id, segmentation.segmentationId);
|
|
35
|
-
if (segmentationImageIds
|
|
36
|
-
console.warn('Segment selection for labelmaps with multiple imageIds in stack viewports is not supported yet.');
|
|
45
|
+
if (!segmentationImageIds?.length) {
|
|
37
46
|
return;
|
|
38
47
|
}
|
|
39
|
-
const segmentationImageId
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
for (const segmentationImageId of segmentationImageIds) {
|
|
49
|
+
const image = cache.getImage(segmentationImageId);
|
|
50
|
+
if (!image) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentation.segmentationId, segmentationImageId);
|
|
54
|
+
const imageData = segmentationActorEntry?.actor.getMapper().getInputData();
|
|
55
|
+
const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
|
|
56
|
+
const dimensions = imageData.getDimensions();
|
|
57
|
+
const voxelManager = (imageData.voxelManager ||
|
|
58
|
+
utilities.VoxelManager.createScalarVolumeVoxelManager({
|
|
59
|
+
dimensions,
|
|
60
|
+
scalarData: imageData.getPointData().getScalars().getData(),
|
|
61
|
+
}));
|
|
62
|
+
const labelValue = voxelManager.getAtIJKPoint(indexIJK);
|
|
63
|
+
if (!labelValue) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const layer = getLabelmaps(segmentation).find((candidateLayer) => candidateLayer.imageIds?.includes(segmentationImageId));
|
|
67
|
+
if (!layer) {
|
|
68
|
+
return labelValue;
|
|
69
|
+
}
|
|
70
|
+
return getSegmentIndexForLabelValue(segmentation, layer.labelmapId, labelValue);
|
|
43
71
|
}
|
|
44
|
-
const segmentationActorEntry = getLabelmapActorEntry(viewport.id, segmentation.segmentationId);
|
|
45
|
-
const imageData = segmentationActorEntry?.actor.getMapper().getInputData();
|
|
46
|
-
const indexIJK = utilities.transformWorldToIndex(imageData, worldPoint);
|
|
47
|
-
const dimensions = imageData.getDimensions();
|
|
48
|
-
const voxelManager = (imageData.voxelManager ||
|
|
49
|
-
utilities.VoxelManager.createScalarVolumeVoxelManager({
|
|
50
|
-
dimensions,
|
|
51
|
-
scalarData: imageData.getPointData().getScalars().getData(),
|
|
52
|
-
}));
|
|
53
|
-
const segmentIndex = voxelManager.getAtIJKPoint(indexIJK);
|
|
54
|
-
return segmentIndex;
|
|
55
72
|
}
|
|
56
73
|
export function getSegmentIndexAtWorldForContour(segmentation, worldPoint, { viewport }) {
|
|
57
74
|
const contourData = segmentation.representationData.Contour;
|
|
@@ -13,7 +13,7 @@ function getUniqueSegmentIndices(segmentationId) {
|
|
|
13
13
|
}
|
|
14
14
|
let indices;
|
|
15
15
|
if (segmentation.representationData.Labelmap) {
|
|
16
|
-
indices = handleLabelmapSegmentation(segmentation
|
|
16
|
+
indices = handleLabelmapSegmentation(segmentation);
|
|
17
17
|
}
|
|
18
18
|
else if (segmentation.representationData.Contour) {
|
|
19
19
|
indices = handleContourSegmentation(segmentation);
|
|
@@ -27,38 +27,11 @@ function getUniqueSegmentIndices(segmentationId) {
|
|
|
27
27
|
setCachedSegmentIndices(segmentationId, indices);
|
|
28
28
|
return indices;
|
|
29
29
|
}
|
|
30
|
-
function handleLabelmapSegmentation(segmentation
|
|
31
|
-
|
|
32
|
-
const keySet = new Set();
|
|
33
|
-
if (labelmapData.imageIds) {
|
|
34
|
-
addImageSegmentIndices(keySet, labelmapData.imageIds);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
addVolumeSegmentIndices(keySet, segmentationId);
|
|
38
|
-
}
|
|
39
|
-
return Array.from(keySet)
|
|
30
|
+
function handleLabelmapSegmentation(segmentation) {
|
|
31
|
+
return Object.keys(segmentation.segments)
|
|
40
32
|
.map(Number)
|
|
41
33
|
.sort((a, b) => a - b);
|
|
42
34
|
}
|
|
43
|
-
function addVolumeSegmentIndices(keySet, segmentationId) {
|
|
44
|
-
const volume = cache.getVolume(segmentationId);
|
|
45
|
-
volume.voxelManager.forEach(({ value }) => {
|
|
46
|
-
if (value !== 0) {
|
|
47
|
-
keySet.add(value);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function addImageSegmentIndices(keySet, imageIds) {
|
|
52
|
-
imageIds.forEach((segmentationImageId) => {
|
|
53
|
-
const image = cache.getImage(segmentationImageId);
|
|
54
|
-
const scalarData = image.voxelManager.getScalarData();
|
|
55
|
-
scalarData.forEach((segmentIndex) => {
|
|
56
|
-
if (segmentIndex !== 0) {
|
|
57
|
-
keySet.add(segmentIndex);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
35
|
function handleContourSegmentation(segmentation) {
|
|
63
36
|
const { annotationUIDsMap, geometryIds } = segmentation.representationData.Contour || {};
|
|
64
37
|
if (!geometryIds) {
|
|
@@ -28,6 +28,7 @@ import * as validateLabelmap from './validateLabelmap';
|
|
|
28
28
|
import { computeStackLabelmapFromVolume } from '../../stateManagement/segmentation/helpers/computeStackLabelmapFromVolume';
|
|
29
29
|
import { computeVolumeLabelmapFromStack } from '../../stateManagement/segmentation/helpers/computeVolumeLabelmapFromStack';
|
|
30
30
|
import { getReferenceVolumeForSegmentationVolume } from './getReferenceVolumeForSegmentationVolume';
|
|
31
|
+
import { getReferenceVolumeForSegmentation } from './getReferenceVolumeForSegmentation';
|
|
31
32
|
import { getSegmentLargestBidirectional } from './getSegmentLargestBidirectional';
|
|
32
33
|
import { computeMetabolicStats } from './computeMetabolicStats';
|
|
33
|
-
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getSegmentLargestBidirectional, computeMetabolicStats, };
|
|
34
|
+
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getReferenceVolumeForSegmentation, getSegmentLargestBidirectional, computeMetabolicStats, };
|
|
@@ -28,6 +28,7 @@ import * as validateLabelmap from './validateLabelmap';
|
|
|
28
28
|
import { computeStackLabelmapFromVolume } from '../../stateManagement/segmentation/helpers/computeStackLabelmapFromVolume';
|
|
29
29
|
import { computeVolumeLabelmapFromStack } from '../../stateManagement/segmentation/helpers/computeVolumeLabelmapFromStack';
|
|
30
30
|
import { getReferenceVolumeForSegmentationVolume } from './getReferenceVolumeForSegmentationVolume';
|
|
31
|
+
import { getReferenceVolumeForSegmentation } from './getReferenceVolumeForSegmentation';
|
|
31
32
|
import { getSegmentLargestBidirectional } from './getSegmentLargestBidirectional';
|
|
32
33
|
import { computeMetabolicStats } from './computeMetabolicStats';
|
|
33
|
-
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getSegmentLargestBidirectional, computeMetabolicStats, };
|
|
34
|
+
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, SegmentStatsCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, growCut, LabelmapMemo, IslandRemoval, getOrCreateSegmentationVolume, getOrCreateImageVolume, getStatistics, validateLabelmap, computeStackLabelmapFromVolume, computeVolumeLabelmapFromStack, getReferenceVolumeForSegmentationVolume, getReferenceVolumeForSegmentation, getSegmentLargestBidirectional, computeMetabolicStats, };
|
|
@@ -12,6 +12,10 @@ export const triggerWorkerProgress = (workerType, progress) => {
|
|
|
12
12
|
};
|
|
13
13
|
export const getSegmentationDataForWorker = (segmentationId, segmentIndices) => {
|
|
14
14
|
const segmentation = getSegmentation(segmentationId);
|
|
15
|
+
if (!segmentation?.representationData) {
|
|
16
|
+
console.debug('getSegmentationDataForWorker: segmentation missing or not ready', segmentationId);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
15
19
|
const { representationData } = segmentation;
|
|
16
20
|
const { Labelmap } = representationData;
|
|
17
21
|
if (!Labelmap) {
|
|
@@ -25,8 +29,8 @@ export const getSegmentationDataForWorker = (segmentationId, segmentIndices) =>
|
|
|
25
29
|
volumeId: segVolumeId,
|
|
26
30
|
imageIds: segImageIds,
|
|
27
31
|
};
|
|
28
|
-
let reconstructableVolume =
|
|
29
|
-
if (segImageIds) {
|
|
32
|
+
let reconstructableVolume = Boolean(segVolumeId);
|
|
33
|
+
if (!reconstructableVolume && segImageIds) {
|
|
30
34
|
const refImageIds = segImageIds.map((imageId) => {
|
|
31
35
|
const image = cache.getImage(imageId);
|
|
32
36
|
return image.referencedImageId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cache } from '@cornerstonejs/core';
|
|
2
2
|
function validateRepresentationData(segmentationRepresentationData) {
|
|
3
|
-
if (
|
|
3
|
+
if (segmentationRepresentationData.volumeId) {
|
|
4
4
|
segmentationRepresentationData =
|
|
5
5
|
segmentationRepresentationData;
|
|
6
6
|
const cachedVolume = cache.getVolume(segmentationRepresentationData.volumeId);
|
|
@@ -58,7 +58,6 @@ function prefetch(element) {
|
|
|
58
58
|
let nextImageIdIndex;
|
|
59
59
|
const preventCache = false;
|
|
60
60
|
function doneCallback(imageId) {
|
|
61
|
-
console.log('prefetch done: %s', imageId);
|
|
62
61
|
const imageIdIndex = stack.imageIds.indexOf(imageId);
|
|
63
62
|
removeFromList(imageIdIndex);
|
|
64
63
|
if (stackPrefetch.indicesToRequest.length === 0) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { utilities } from '@cornerstonejs/core';
|
|
1
2
|
function getDeltaPoints(currentPoints, lastPoints) {
|
|
2
3
|
const curr = getMeanPoints(currentPoints);
|
|
3
4
|
const last = getMeanPoints(lastPoints);
|
|
@@ -32,10 +33,10 @@ function getDeltaDistanceBetweenIPoints(currentPoints, lastPoints) {
|
|
|
32
33
|
return deltaDistance;
|
|
33
34
|
}
|
|
34
35
|
function copyPointsList(points) {
|
|
35
|
-
return
|
|
36
|
+
return utilities.deepClone(points);
|
|
36
37
|
}
|
|
37
38
|
function copyPoints(points) {
|
|
38
|
-
return
|
|
39
|
+
return utilities.deepClone(points);
|
|
39
40
|
}
|
|
40
41
|
function getMeanPoints(points) {
|
|
41
42
|
return points.reduce((prev, curr) => {
|