@cornerstonejs/tools 2.8.5 → 2.9.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.
Files changed (49) hide show
  1. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForKeyboardEvents.js +1 -1
  2. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js +1 -1
  3. package/dist/esm/index.d.ts +2 -2
  4. package/dist/esm/index.js +2 -2
  5. package/dist/esm/stateManagement/segmentation/activeSegmentation.d.ts +1 -1
  6. package/dist/esm/stateManagement/segmentation/activeSegmentation.js +1 -1
  7. package/dist/esm/stateManagement/segmentation/index.d.ts +3 -1
  8. package/dist/esm/stateManagement/segmentation/index.js +3 -1
  9. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +1 -1
  10. package/dist/esm/tools/annotation/RegionSegmentPlusTool.d.ts +3 -2
  11. package/dist/esm/tools/annotation/RegionSegmentPlusTool.js +27 -12
  12. package/dist/esm/tools/annotation/RegionSegmentTool.d.ts +1 -1
  13. package/dist/esm/tools/annotation/RegionSegmentTool.js +7 -8
  14. package/dist/esm/tools/annotation/SplineROITool.js +7 -1
  15. package/dist/esm/tools/annotation/WholeBodySegmentTool.d.ts +3 -2
  16. package/dist/esm/tools/annotation/WholeBodySegmentTool.js +40 -5
  17. package/dist/esm/tools/base/AnnotationTool.d.ts +2 -1
  18. package/dist/esm/tools/base/AnnotationTool.js +6 -3
  19. package/dist/esm/tools/base/ContourSegmentationBaseTool.d.ts +1 -0
  20. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -0
  21. package/dist/esm/tools/base/GrowCutBaseTool.d.ts +25 -10
  22. package/dist/esm/tools/base/GrowCutBaseTool.js +124 -21
  23. package/dist/esm/tools/index.d.ts +3 -1
  24. package/dist/esm/tools/index.js +3 -1
  25. package/dist/esm/tools/segmentation/BrushTool.d.ts +0 -1
  26. package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +5 -1
  27. package/dist/esm/tools/segmentation/LabelmapBaseTool.js +107 -12
  28. package/dist/esm/tools/segmentation/strategies/compositions/index.js +1 -1
  29. package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.d.ts +5 -0
  30. package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +27 -0
  31. package/dist/esm/tools/segmentation/strategies/compositions/labelmapStatistics.js +69 -2
  32. package/dist/esm/types/CalculatorTypes.d.ts +4 -0
  33. package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js +5 -2
  34. package/dist/esm/utilities/index.d.ts +3 -1
  35. package/dist/esm/utilities/index.js +3 -1
  36. package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js +2 -2
  37. package/dist/esm/utilities/segmentation/VolumetricCalculator.d.ts +7 -0
  38. package/dist/esm/utilities/segmentation/VolumetricCalculator.js +28 -0
  39. package/dist/esm/utilities/segmentation/growCut/runGrowCutForBoundingBox.d.ts +0 -2
  40. package/dist/esm/utilities/segmentation/growCut/runOneClickGrowCut.d.ts +0 -4
  41. package/dist/esm/utilities/segmentation/index.d.ts +2 -1
  42. package/dist/esm/utilities/segmentation/index.js +2 -1
  43. package/dist/esm/utilities/segmentation/islandRemoval.d.ts +28 -0
  44. package/dist/esm/utilities/segmentation/islandRemoval.js +181 -0
  45. package/package.json +3 -3
  46. package/dist/esm/tools/segmentation/strategies/compositions/islandRemoval.d.ts +0 -16
  47. package/dist/esm/tools/segmentation/strategies/compositions/islandRemoval.js +0 -159
  48. /package/dist/esm/{tools/segmentation/strategies/utils → utilities}/normalizeViewportPlane.d.ts +0 -0
  49. /package/dist/esm/{tools/segmentation/strategies/utils → utilities}/normalizeViewportPlane.js +0 -0
@@ -19,7 +19,7 @@ export default function getToolsWithModesForKeyboardEvent(evt, toolModes) {
19
19
  if (!actions?.length || !toolModes.includes(tool.mode)) {
20
20
  continue;
21
21
  }
22
- const action = actions.find((action) => action.bindings.some((binding) => binding.key === key));
22
+ const action = actions.find((action) => action.bindings?.some((binding) => binding.key === key));
23
23
  if (action) {
24
24
  toolsWithActions.set(tool, action);
25
25
  }
@@ -21,7 +21,7 @@ export default function getToolsWithActionsForMouseEvent(evt, toolModes) {
21
21
  if (!actions?.length || !toolModes.includes(tool.mode)) {
22
22
  continue;
23
23
  }
24
- const action = actions.find((action) => action.bindings.length &&
24
+ const action = actions.find((action) => action.bindings?.length &&
25
25
  action.bindings.some((binding) => binding.mouseButton === mouseButton &&
26
26
  binding.modifierKey === modifierKey));
27
27
  if (action) {
@@ -9,7 +9,7 @@ import * as cursors from './cursors';
9
9
  import * as Types from './types';
10
10
  import * as annotation from './stateManagement/annotation';
11
11
  import * as segmentation from './stateManagement/segmentation';
12
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool } from './tools';
12
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool } from './tools';
13
13
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
14
14
  import * as Enums from './enums';
15
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, };
15
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, };
package/dist/esm/index.js CHANGED
@@ -9,7 +9,7 @@ import * as cursors from './cursors';
9
9
  import * as Types from './types';
10
10
  import * as annotation from './stateManagement/annotation';
11
11
  import * as segmentation from './stateManagement/segmentation';
12
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, } from './tools';
12
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, } from './tools';
13
13
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
14
14
  import * as Enums from './enums';
15
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, };
15
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, };
@@ -1,4 +1,4 @@
1
1
  import type { Segmentation } from '../../types/SegmentationStateTypes';
2
2
  declare function getActiveSegmentation(viewportId: string): Segmentation;
3
- declare function setActiveSegmentation(viewportId: string, segmentationId: string, suppressEvent?: boolean): void;
3
+ declare function setActiveSegmentation(viewportId: string, segmentationId: string): void;
4
4
  export { getActiveSegmentation, setActiveSegmentation, };
@@ -3,7 +3,7 @@ import { setActiveSegmentation as _setActiveSegmentation } from './setActiveSegm
3
3
  function getActiveSegmentation(viewportId) {
4
4
  return _getActiveSegmentation(viewportId);
5
5
  }
6
- function setActiveSegmentation(viewportId, segmentationId, suppressEvent = false) {
6
+ function setActiveSegmentation(viewportId, segmentationId) {
7
7
  _setActiveSegmentation(viewportId, segmentationId);
8
8
  }
9
9
  export { getActiveSegmentation, setActiveSegmentation, };
@@ -1,6 +1,7 @@
1
1
  import { removeContourRepresentation, removeLabelmapRepresentation, removeSegmentationRepresentation, removeSurfaceRepresentation, removeSegmentationRepresentations, removeAllSegmentationRepresentations } from './removeSegmentationRepresentations';
2
2
  import { addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations } from './addSegmentationRepresentationsToViewport';
3
3
  import { addSegmentations } from './addSegmentations';
4
+ import addRepresentationData from './internalAddRepresentationData';
4
5
  import { updateSegmentations } from './updateSegmentations';
5
6
  import * as activeSegmentation from './activeSegmentation';
6
7
  import * as segmentLocking from './segmentLocking';
@@ -15,6 +16,7 @@ import { clearSegmentValue } from './helpers/clearSegmentValue';
15
16
  import { convertVolumeToStackLabelmap } from './helpers/computeStackLabelmapFromVolume';
16
17
  import { removeSegment } from './removeSegment';
17
18
  import { getLabelmapImageIds } from './getLabelmapImageIds';
19
+ import * as strategies from './../../tools/segmentation/strategies';
18
20
  import { removeAllSegmentations, removeSegmentation } from './removeSegmentation';
19
21
  declare const helpers: {
20
22
  clearSegmentValue: typeof clearSegmentValue;
@@ -22,4 +24,4 @@ declare const helpers: {
22
24
  computeVolumeLabelmapFromStack: typeof computeVolumeLabelmapFromStack;
23
25
  convertVolumeToStackLabelmap: typeof convertVolumeToStackLabelmap;
24
26
  };
25
- export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers, polySegManager as polySeg, removeSegment, getLabelmapImageIds, };
27
+ export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers, polySegManager as polySeg, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, };
@@ -1,6 +1,7 @@
1
1
  import { removeContourRepresentation, removeLabelmapRepresentation, removeSegmentationRepresentation, removeSurfaceRepresentation, removeSegmentationRepresentations, removeAllSegmentationRepresentations, } from './removeSegmentationRepresentations';
2
2
  import { addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, } from './addSegmentationRepresentationsToViewport';
3
3
  import { addSegmentations } from './addSegmentations';
4
+ import addRepresentationData from './internalAddRepresentationData';
4
5
  import { updateSegmentations } from './updateSegmentations';
5
6
  import * as activeSegmentation from './activeSegmentation';
6
7
  import * as segmentLocking from './segmentLocking';
@@ -15,6 +16,7 @@ import { clearSegmentValue } from './helpers/clearSegmentValue';
15
16
  import { convertVolumeToStackLabelmap } from './helpers/computeStackLabelmapFromVolume';
16
17
  import { removeSegment } from './removeSegment';
17
18
  import { getLabelmapImageIds } from './getLabelmapImageIds';
19
+ import * as strategies from './../../tools/segmentation/strategies';
18
20
  import { removeAllSegmentations, removeSegmentation, } from './removeSegmentation';
19
21
  const helpers = {
20
22
  clearSegmentValue,
@@ -22,4 +24,4 @@ const helpers = {
22
24
  computeVolumeLabelmapFromStack,
23
25
  convertVolumeToStackLabelmap,
24
26
  };
25
- export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers, polySegManager as polySeg, removeSegment, getLabelmapImageIds, };
27
+ export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers, polySegManager as polySeg, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, };
@@ -46,7 +46,7 @@ export function createAndAddContourSegmentationsFromClippedSurfaces(rawContourDa
46
46
  },
47
47
  };
48
48
  addAnnotation(contourSegmentationAnnotation, viewport.element);
49
- const currentSet = annotationUIDsMap.get(segmentIndex) || new Set();
49
+ const currentSet = annotationUIDsMap?.get(segmentIndex) || new Set();
50
50
  currentSet.add(contourSegmentationAnnotation.annotationUID);
51
51
  annotationUIDsMap.set(segmentIndex, currentSet);
52
52
  }
@@ -1,7 +1,7 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  import type { EventTypes, PublicToolProps, ToolProps } from '../../types';
3
3
  import GrowCutBaseTool from '../base/GrowCutBaseTool';
4
- import type { GrowCutToolData } from '../base/GrowCutBaseTool';
4
+ import type { GrowCutToolData, RemoveIslandData } from '../base/GrowCutBaseTool';
5
5
  type RegionSegmentPlusToolData = GrowCutToolData & {
6
6
  worldPoint: Types.Point3;
7
7
  };
@@ -10,6 +10,7 @@ declare class RegionSegmentPlusTool extends GrowCutBaseTool {
10
10
  protected growCutData: RegionSegmentPlusToolData | null;
11
11
  constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
12
12
  preMouseDownCallback(evt: EventTypes.MouseDownActivateEventType): Promise<boolean>;
13
- protected getGrowCutLabelmap(): Promise<Types.IImageVolume>;
13
+ protected getRemoveIslandData(growCutData: RegionSegmentPlusToolData): RemoveIslandData;
14
+ protected getGrowCutLabelmap(growCutData: any): Promise<Types.IImageVolume>;
14
15
  }
15
16
  export default RegionSegmentPlusTool;
@@ -1,4 +1,4 @@
1
- import { getRenderingEngine } from '@cornerstonejs/core';
1
+ import { getRenderingEngine, utilities as csUtils } from '@cornerstonejs/core';
2
2
  import { growCut } from '../../utilities/segmentation';
3
3
  import GrowCutBaseTool from '../base/GrowCutBaseTool';
4
4
  class RegionSegmentPlusTool extends GrowCutBaseTool {
@@ -8,6 +8,9 @@ class RegionSegmentPlusTool extends GrowCutBaseTool {
8
8
  positiveSeedVariance: 0.4,
9
9
  negativeSeedVariance: 0.9,
10
10
  subVolumePaddingPercentage: 0.1,
11
+ islandRemoval: {
12
+ enabled: true,
13
+ },
11
14
  },
12
15
  }) {
13
16
  super(toolProps, defaultToolProps);
@@ -16,24 +19,36 @@ class RegionSegmentPlusTool extends GrowCutBaseTool {
16
19
  const eventData = evt.detail;
17
20
  const { currentPoints } = eventData;
18
21
  const { world: worldPoint } = currentPoints;
19
- super.preMouseDownCallback(evt);
22
+ await super.preMouseDownCallback(evt);
23
+ this.growCutData = csUtils.deepMerge(this.growCutData, {
24
+ worldPoint,
25
+ islandRemoval: {
26
+ worldIslandPoints: [worldPoint],
27
+ },
28
+ });
20
29
  this.growCutData.worldPoint = worldPoint;
30
+ this.growCutData.islandRemoval = {
31
+ worldIslandPoints: [worldPoint],
32
+ };
21
33
  this.runGrowCut();
22
34
  return true;
23
35
  }
24
- async getGrowCutLabelmap() {
25
- const { segmentation: { segmentIndex, referencedVolumeId }, renderingEngineId, viewportId, worldPoint, } = this.growCutData;
36
+ getRemoveIslandData(growCutData) {
37
+ const { worldPoint } = growCutData;
38
+ return {
39
+ worldIslandPoints: [worldPoint],
40
+ };
41
+ }
42
+ async getGrowCutLabelmap(growCutData) {
43
+ const { segmentation: { referencedVolumeId }, renderingEngineId, viewportId, worldPoint, options, } = growCutData;
26
44
  const renderingEngine = getRenderingEngine(renderingEngineId);
27
45
  const viewport = renderingEngine.getViewport(viewportId);
28
- const { positiveSeedVariance, negativeSeedVariance, subVolumePaddingPercentage, } = this.configuration;
29
- const options = {
30
- positiveSeedValue: segmentIndex,
31
- negativeSeedValue: 255,
32
- positiveSeedVariance: positiveSeedVariance,
33
- negativeSeedVariance: negativeSeedVariance,
34
- subVolumePaddingPercentage: subVolumePaddingPercentage,
46
+ const { subVolumePaddingPercentage } = this.configuration;
47
+ const mergedOptions = {
48
+ ...options,
49
+ subVolumePaddingPercentage,
35
50
  };
36
- return await growCut.runOneClickGrowCut(referencedVolumeId, worldPoint, viewport, options);
51
+ return growCut.runOneClickGrowCut(referencedVolumeId, worldPoint, viewport, mergedOptions);
37
52
  }
38
53
  }
39
54
  RegionSegmentPlusTool.toolName = 'RegionSegmentPlus';
@@ -13,7 +13,7 @@ declare class RegionSegmentTool extends GrowCutBaseTool {
13
13
  preMouseDownCallback(evt: EventTypes.MouseDownActivateEventType): Promise<boolean>;
14
14
  private _dragCallback;
15
15
  private _endCallback;
16
- protected getGrowCutLabelmap(): Promise<Types.IImageVolume>;
16
+ protected getGrowCutLabelmap(growCutData: any): Promise<Types.IImageVolume>;
17
17
  private _activateDraw;
18
18
  private _deactivateDraw;
19
19
  renderAnnotation(enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper): void;
@@ -9,7 +9,10 @@ import GrowCutBaseTool from '../base/GrowCutBaseTool';
9
9
  class RegionSegmentTool extends GrowCutBaseTool {
10
10
  constructor(toolProps = {}, defaultToolProps = {
11
11
  supportedInteractionTypes: ['Mouse', 'Touch'],
12
- configuration: {},
12
+ configuration: {
13
+ positiveSeedVariance: 0.5,
14
+ negativeSeedVariance: 0.9,
15
+ },
13
16
  }) {
14
17
  super(toolProps, defaultToolProps);
15
18
  this._dragCallback = (evt) => {
@@ -44,7 +47,7 @@ class RegionSegmentTool extends GrowCutBaseTool {
44
47
  const { world: worldPoint } = currentPoints;
45
48
  const enabledElement = getEnabledElement(element);
46
49
  const { viewport, renderingEngine } = enabledElement;
47
- super.preMouseDownCallback(evt);
50
+ await super.preMouseDownCallback(evt);
48
51
  Object.assign(this.growCutData, {
49
52
  circleCenterPoint: worldPoint,
50
53
  circleBorderPoint: worldPoint,
@@ -54,8 +57,8 @@ class RegionSegmentTool extends GrowCutBaseTool {
54
57
  triggerAnnotationRenderForViewportUIDs([viewport.id]);
55
58
  return true;
56
59
  }
57
- async getGrowCutLabelmap() {
58
- const { segmentation: { segmentIndex, referencedVolumeId }, renderingEngineId, viewportId, circleCenterPoint, circleBorderPoint, } = this.growCutData;
60
+ async getGrowCutLabelmap(growCutData) {
61
+ const { segmentation: { referencedVolumeId }, renderingEngineId, viewportId, circleCenterPoint, circleBorderPoint, options, } = growCutData;
59
62
  const renderingEngine = getRenderingEngine(renderingEngineId);
60
63
  const viewport = renderingEngine.getViewport(viewportId);
61
64
  const worldCircleRadius = vec3.len(vec3.sub(vec3.create(), circleCenterPoint, circleBorderPoint));
@@ -63,10 +66,6 @@ class RegionSegmentTool extends GrowCutBaseTool {
63
66
  center: circleCenterPoint,
64
67
  radius: worldCircleRadius,
65
68
  };
66
- const options = {
67
- positiveSeedValue: segmentIndex,
68
- negativeSeedValue: 255,
69
- };
70
69
  return growCut.runGrowCutForSphere(referencedVolumeId, sphereInfo, viewport, options);
71
70
  }
72
71
  _activateDraw(element) {
@@ -226,11 +226,17 @@ class SplineROITool extends ContourSegmentationBaseTool {
226
226
  }
227
227
  this.doneEditMemo();
228
228
  const eventDetail = evt.detail;
229
- const { currentPoints } = eventDetail;
229
+ const { currentPoints, element } = eventDetail;
230
230
  const { canvas: canvasPoint, world: worldPoint } = currentPoints;
231
231
  let closeContour = data.handles.points.length >= 2 && doubleClick;
232
232
  let addNewPoint = true;
233
+ if (data.handles.points.length) {
234
+ this.createMemo(element, annotation, {
235
+ newAnnotation: data.handles.points.length === 1,
236
+ });
237
+ }
233
238
  if (data.handles.points.length >= 3) {
239
+ this.createMemo(element, annotation);
234
240
  const { instance: spline } = data.spline;
235
241
  const closestControlPoint = spline.getClosestControlPointWithinDistance(canvasPoint, SPLINE_CLICK_CLOSE_CURVE_DIST);
236
242
  if (closestControlPoint?.index === 0) {
@@ -1,6 +1,6 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  import type { EventTypes, PublicToolProps, ToolProps, SVGDrawingHelper } from '../../types';
3
- import type { GrowCutToolData } from '../base/GrowCutBaseTool';
3
+ import type { GrowCutToolData, RemoveIslandData } from '../base/GrowCutBaseTool';
4
4
  import GrowCutBaseTool from '../base/GrowCutBaseTool';
5
5
  type HorizontalLine = [Types.Point3, Types.Point3];
6
6
  type WholeBodySegmentToolData = GrowCutToolData & {
@@ -14,7 +14,8 @@ declare class WholeBodySegmentTool extends GrowCutBaseTool {
14
14
  private _dragCallback;
15
15
  private _endCallback;
16
16
  renderAnnotation(enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper): void;
17
- protected getGrowCutLabelmap(): Promise<Types.IImageVolume>;
17
+ protected getGrowCutLabelmap(growCutData: any): Promise<Types.IImageVolume>;
18
+ protected getRemoveIslandData(): RemoveIslandData;
18
19
  private _activateDraw;
19
20
  private _deactivateDraw;
20
21
  private _projectWorldPointAcrossSlices;
@@ -6,11 +6,21 @@ import { Events } from '../../enums';
6
6
  import triggerAnnotationRenderForViewportUIDs from '../../utilities/triggerAnnotationRenderForViewportIds';
7
7
  import { growCut } from '../../utilities/segmentation';
8
8
  import GrowCutBaseTool from '../base/GrowCutBaseTool';
9
+ const NEGATIVE_PIXEL_RANGE = [-Infinity, -995];
10
+ const POSITIVE_PIXEL_RANGE = [0, 1900];
11
+ const ISLAND_PIXEL_RANGE = [1000, 1900];
9
12
  const { transformWorldToIndex, transformIndexToWorld } = csUtils;
10
13
  class WholeBodySegmentTool extends GrowCutBaseTool {
11
14
  constructor(toolProps = {}, defaultToolProps = {
12
15
  supportedInteractionTypes: ['Mouse', 'Touch'],
13
- configuration: {},
16
+ configuration: {
17
+ positivePixelRange: POSITIVE_PIXEL_RANGE,
18
+ negativePixelRange: NEGATIVE_PIXEL_RANGE,
19
+ islandRemoval: {
20
+ enabled: true,
21
+ islandPixelRange: ISLAND_PIXEL_RANGE,
22
+ },
23
+ },
14
24
  }) {
15
25
  super(toolProps, defaultToolProps);
16
26
  this._dragCallback = (evt) => {
@@ -47,7 +57,7 @@ class WholeBodySegmentTool extends GrowCutBaseTool {
47
57
  const enabledElement = getEnabledElement(element);
48
58
  const { viewport, renderingEngine } = enabledElement;
49
59
  const linePoints = this._getHorizontalLineWorldPoints(enabledElement, worldPoint);
50
- super.preMouseDownCallback(evt);
60
+ await super.preMouseDownCallback(evt);
51
61
  this.growCutData.horizontalLines = [linePoints, linePoints];
52
62
  this._activateDraw(element);
53
63
  hideElementCursor(element);
@@ -89,8 +99,8 @@ class WholeBodySegmentTool extends GrowCutBaseTool {
89
99
  closePath: true,
90
100
  });
91
101
  }
92
- async getGrowCutLabelmap() {
93
- const { segmentation: { segmentIndex, referencedVolumeId }, renderingEngineId, viewportId, horizontalLines, } = this.growCutData;
102
+ async getGrowCutLabelmap(growCutData) {
103
+ const { segmentation: { segmentIndex, referencedVolumeId }, renderingEngineId, viewportId, horizontalLines, } = growCutData;
94
104
  const renderingEngine = getRenderingEngine(renderingEngineId);
95
105
  const viewport = renderingEngine.getViewport(viewportId);
96
106
  const [line1, line2] = horizontalLines;
@@ -105,12 +115,37 @@ class WholeBodySegmentTool extends GrowCutBaseTool {
105
115
  ijkBottomRight,
106
116
  },
107
117
  };
118
+ const config = this.configuration;
108
119
  const options = {
109
120
  positiveSeedValue: segmentIndex,
110
121
  negativeSeedValue: 255,
122
+ negativePixelRange: config.negativePixelRange,
123
+ positivePixelRange: config.positivePixelRange,
111
124
  };
112
125
  return growCut.runGrowCutForBoundingBox(referencedVolumeId, boundingBoxInfo, options);
113
126
  }
127
+ getRemoveIslandData() {
128
+ const { segmentation: { segmentIndex, referencedVolumeId, labelmapVolumeId }, } = this.growCutData;
129
+ const referencedVolume = cache.getVolume(referencedVolumeId);
130
+ const labelmapVolume = cache.getVolume(labelmapVolumeId);
131
+ const referencedVolumeData = referencedVolume.voxelManager.getCompleteScalarDataArray();
132
+ const labelmapData = labelmapVolume.voxelManager.getCompleteScalarDataArray();
133
+ const { islandPixelRange } = this.configuration.islandRemoval;
134
+ const islandPointIndexes = [];
135
+ for (let i = 0, len = labelmapData.length; i < len; i++) {
136
+ if (labelmapData[i] !== segmentIndex) {
137
+ continue;
138
+ }
139
+ const pixelValue = referencedVolumeData[i];
140
+ if (pixelValue >= islandPixelRange[0] &&
141
+ pixelValue <= islandPixelRange[1]) {
142
+ islandPointIndexes.push(i);
143
+ }
144
+ }
145
+ return {
146
+ islandPointIndexes,
147
+ };
148
+ }
114
149
  _activateDraw(element) {
115
150
  element.addEventListener(Events.MOUSE_UP, this._endCallback);
116
151
  element.addEventListener(Events.MOUSE_DRAG, this._dragCallback);
@@ -184,5 +219,5 @@ class WholeBodySegmentTool extends GrowCutBaseTool {
184
219
  return [worldPoint1, worldPoint2];
185
220
  }
186
221
  }
187
- WholeBodySegmentTool.toolName = 'WholeBodySegmentTool';
222
+ WholeBodySegmentTool.toolName = 'WholeBodySegment';
188
223
  export default WholeBodySegmentTool;
@@ -16,7 +16,8 @@ declare abstract class AnnotationTool extends AnnotationDisplayTool {
16
16
  mouseMoveCallback: (evt: EventTypes.MouseMoveEventType, filteredAnnotations?: Annotations) => boolean;
17
17
  getHandleNearImagePoint(element: HTMLDivElement, annotation: Annotation, canvasCoords: Types.Point2, proximity: number): ToolHandle | undefined;
18
18
  getLinkedTextBoxStyle(specifications: StyleSpecifier, annotation?: Annotation): Record<string, unknown>;
19
- isSuvScaled(viewport: Types.IStackViewport | Types.IVolumeViewport, targetId: string, imageId?: string): boolean;
19
+ static isSuvScaled(viewport: Types.IStackViewport | Types.IVolumeViewport, targetId: string, imageId?: string): boolean;
20
+ isSuvScaled: typeof AnnotationTool.isSuvScaled;
20
21
  protected getAnnotationStyle(context: {
21
22
  annotation: Annotation;
22
23
  styleSpecifier: StyleSpecifier;
@@ -82,6 +82,7 @@ class AnnotationTool extends AnnotationDisplayTool {
82
82
  }
83
83
  return annotationsNeedToBeRedrawn;
84
84
  };
85
+ this.isSuvScaled = AnnotationTool.isSuvScaled;
85
86
  if (toolProps.configuration?.getTextLines) {
86
87
  this.configuration.getTextLines = toolProps.configuration.getTextLines;
87
88
  }
@@ -139,7 +140,7 @@ class AnnotationTool extends AnnotationDisplayTool {
139
140
  lineDash: this.getStyle('textBoxLinkLineDash', specifications, annotation),
140
141
  };
141
142
  }
142
- isSuvScaled(viewport, targetId, imageId) {
143
+ static isSuvScaled(viewport, targetId, imageId) {
143
144
  if (viewport instanceof BaseVolumeViewport) {
144
145
  const volumeId = csUtils.getVolumeId(targetId);
145
146
  const volume = cache.getVolume(volumeId);
@@ -215,6 +216,8 @@ class AnnotationTool extends AnnotationDisplayTool {
215
216
  const annotationMemo = {
216
217
  restoreMemo: () => {
217
218
  const newState = AnnotationTool.createAnnotationState(annotation, deleting);
219
+ const { viewport } = getEnabledElement(element) || {};
220
+ viewport?.setViewReference(annotation.metadata);
218
221
  if (state.deleting === true) {
219
222
  state.deleting = false;
220
223
  Object.assign(annotation.data, state.data);
@@ -229,7 +232,7 @@ class AnnotationTool extends AnnotationDisplayTool {
229
232
  state.data = newState.data;
230
233
  addAnnotation(annotation, element);
231
234
  setAnnotationSelected(annotation.annotationUID, true);
232
- getEnabledElement(element)?.viewport.render();
235
+ viewport?.render();
233
236
  return;
234
237
  }
235
238
  if (state.deleting === false) {
@@ -237,7 +240,7 @@ class AnnotationTool extends AnnotationDisplayTool {
237
240
  state.data = newState.data;
238
241
  setAnnotationSelected(annotation.annotationUID);
239
242
  removeAnnotation(annotation.annotationUID);
240
- getEnabledElement(element)?.viewport.render();
243
+ viewport?.render();
241
244
  return;
242
245
  }
243
246
  const currentAnnotation = getAnnotation(annotationUID);
@@ -3,6 +3,7 @@ import type { ContourAnnotation } from '../../types/ToolSpecificAnnotationTypes'
3
3
  import type { StyleSpecifier } from '../../types/AnnotationStyle';
4
4
  import ContourBaseTool from './ContourBaseTool';
5
5
  declare abstract class ContourSegmentationBaseTool extends ContourBaseTool {
6
+ static PreviewSegmentIndex: number;
6
7
  constructor(toolProps: PublicToolProps, defaultToolProps: ToolProps);
7
8
  protected isContourSegmentationTool(): boolean;
8
9
  protected createAnnotation(evt: EventTypes.InteractionEventType): ContourAnnotation;
@@ -13,6 +13,7 @@ import { getActiveSegmentIndex } from '../../stateManagement/segmentation/getAct
13
13
  import { getLockedSegmentIndices } from '../../stateManagement/segmentation/segmentLocking';
14
14
  import { getSVGStyleForSegment } from '../../utilities/segmentation/getSVGStyleForSegment';
15
15
  class ContourSegmentationBaseTool extends ContourBaseTool {
16
+ static { this.PreviewSegmentIndex = 255; }
16
17
  constructor(toolProps, defaultToolProps) {
17
18
  super(toolProps, defaultToolProps);
18
19
  if (this.configuration.interpolation?.enabled) {
@@ -1,4 +1,4 @@
1
- import type { Types } from '@cornerstonejs/core';
1
+ import { type Types } from '@cornerstonejs/core';
2
2
  import { BaseTool } from '../base';
3
3
  import type { EventTypes, PublicToolProps, ToolProps } from '../../types';
4
4
  type GrowCutToolData = {
@@ -11,17 +11,39 @@ type GrowCutToolData = {
11
11
  labelmapVolumeId: string;
12
12
  referencedVolumeId: string;
13
13
  };
14
+ islandRemoval?: {
15
+ worldIslandPoints: Types.Point3[];
16
+ };
14
17
  viewportId: string;
15
18
  renderingEngineId: string;
16
19
  };
20
+ type RemoveIslandData = {
21
+ worldIslandPoints?: Types.Point3[];
22
+ ijkIslandPoints?: Types.Point3[];
23
+ islandPointIndexes?: number[];
24
+ };
17
25
  declare class GrowCutBaseTool extends BaseTool {
18
26
  static toolName: any;
19
27
  protected growCutData: GrowCutToolData | null;
28
+ private static lastGrowCutCommand;
20
29
  constructor(toolProps: PublicToolProps, defaultToolProps: ToolProps);
21
30
  preMouseDownCallback(evt: EventTypes.MouseDownActivateEventType): Promise<boolean>;
22
- protected getGrowCutLabelmap(): Promise<Types.IImageVolume>;
31
+ shrink(): void;
32
+ expand(): void;
33
+ refresh(): void;
34
+ protected getGrowCutLabelmap(_growCutData: GrowCutToolData): Promise<Types.IImageVolume>;
23
35
  protected runGrowCut(): Promise<void>;
24
36
  protected applyGrowCutLabelmap(segmentationId: string, segmentIndex: number, targetLabelmap: Types.IImageVolume, sourceLabelmap: Types.IImageVolume): void;
37
+ private _runLastCommand;
38
+ protected getLabelmapSegmentationData(viewport: Types.IViewport): Promise<{
39
+ segmentationId: string;
40
+ segmentIndex: number;
41
+ labelmapVolumeId: string;
42
+ referencedVolumeId: string;
43
+ }>;
44
+ protected _isOrthogonalView(viewport: Types.IViewport, referencedVolumeId: string): boolean;
45
+ protected getRemoveIslandData(_growCutData: GrowCutToolData): RemoveIslandData;
46
+ private _removeIslands;
25
47
  protected getSegmentStyle({ segmentationId, viewportId, segmentIndex }: {
26
48
  segmentationId: any;
27
49
  viewportId: any;
@@ -37,13 +59,6 @@ declare class GrowCutBaseTool extends BaseTool {
37
59
  };
38
60
  visibility: boolean;
39
61
  };
40
- protected getLabelmapSegmentationData(viewport: Types.IViewport): {
41
- segmentationId: string;
42
- segmentIndex: number;
43
- labelmapVolumeId: string;
44
- referencedVolumeId: string;
45
- };
46
- protected _isOrthogonalView(viewport: Types.IViewport, referencedVolumeId: string): boolean;
47
62
  }
48
63
  export default GrowCutBaseTool;
49
- export type { GrowCutToolData };
64
+ export type { GrowCutToolData, RemoveIslandData };