@cornerstonejs/tools 5.8.1 → 5.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/esm/config.js +3 -1
  2. package/dist/esm/cursors/setCursorForElement.js +3 -1
  3. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDownActivate.js +3 -1
  4. package/dist/esm/eventDispatchers/touchEventHandlers/touchStartActivate.js +3 -1
  5. package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +3 -1
  6. package/dist/esm/stateManagement/annotation/AnnotationRenderingEngine.js +3 -1
  7. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +4 -2
  8. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +9 -3
  9. package/dist/esm/stateManagement/segmentation/addColorLUT.js +3 -1
  10. package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +3 -1
  11. package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +2 -0
  12. package/dist/esm/stateManagement/segmentation/internalAddRepresentationData.js +3 -1
  13. package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -1
  14. package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +3 -1
  15. package/dist/esm/stateManagement/segmentation/segmentIndex.js +3 -1
  16. package/dist/esm/stateManagement/segmentation/utilities/convertContourHoles.js +9 -7
  17. package/dist/esm/stateManagement/segmentation/utilities/decimateContours.js +6 -4
  18. package/dist/esm/stateManagement/segmentation/utilities/getPolylineMap.js +3 -1
  19. package/dist/esm/stateManagement/segmentation/utilities/removeContourHoles.js +5 -3
  20. package/dist/esm/stateManagement/segmentation/utilities/removeContourIslands.js +5 -3
  21. package/dist/esm/stateManagement/segmentation/utilities/smoothContours.js +6 -4
  22. package/dist/esm/store/SynchronizerManager/Synchronizer.js +4 -2
  23. package/dist/esm/store/ToolGroupManager/ToolGroup.js +17 -15
  24. package/dist/esm/store/ToolGroupManager/createToolGroup.js +3 -1
  25. package/dist/esm/store/filterToolsWithAnnotationsForElement.js +3 -1
  26. package/dist/esm/tools/AdvancedMagnifyTool.js +3 -1
  27. package/dist/esm/tools/CrosshairsTool.js +4 -2
  28. package/dist/esm/tools/MIPJumpToClickTool.js +3 -1
  29. package/dist/esm/tools/OrientationControllerTool.js +6 -4
  30. package/dist/esm/tools/OverlayGridTool.js +5 -3
  31. package/dist/esm/tools/ReferenceCursors.js +3 -1
  32. package/dist/esm/tools/ReferenceLinesTool.js +3 -1
  33. package/dist/esm/tools/SculptorTool.js +7 -5
  34. package/dist/esm/tools/SegmentationIntersectionTool.js +3 -1
  35. package/dist/esm/tools/VolumeCroppingControlTool.js +5 -3
  36. package/dist/esm/tools/VolumeCroppingTool.js +5 -3
  37. package/dist/esm/tools/WindowLevelRegionTool.js +3 -1
  38. package/dist/esm/tools/annotation/AngleTool.js +3 -1
  39. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +3 -1
  40. package/dist/esm/tools/annotation/BidirectionalTool.js +3 -1
  41. package/dist/esm/tools/annotation/CircleROITool.js +30 -33
  42. package/dist/esm/tools/annotation/CobbAngleTool.js +3 -1
  43. package/dist/esm/tools/annotation/DragProbeTool.js +3 -1
  44. package/dist/esm/tools/annotation/ETDRSGridTool.js +3 -1
  45. package/dist/esm/tools/annotation/EllipticalROITool.js +35 -38
  46. package/dist/esm/tools/annotation/HeightTool.js +3 -1
  47. package/dist/esm/tools/annotation/KeyImageTool.js +3 -1
  48. package/dist/esm/tools/annotation/LabelTool.js +3 -1
  49. package/dist/esm/tools/annotation/LengthTool.js +4 -2
  50. package/dist/esm/tools/annotation/LivewireContourTool.js +3 -1
  51. package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +13 -2
  52. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +28 -81
  53. package/dist/esm/tools/annotation/ProbeTool.js +3 -1
  54. package/dist/esm/tools/annotation/RectangleROITool.js +31 -20
  55. package/dist/esm/tools/annotation/SplineROITool.js +3 -1
  56. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +3 -1
  57. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +5 -3
  58. package/dist/esm/tools/annotation/VideoRedactionTool.js +3 -1
  59. package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +3 -1
  60. package/dist/esm/tools/base/AnnotationTool.js +3 -1
  61. package/dist/esm/tools/base/ContourBaseTool.js +3 -1
  62. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +4 -2
  63. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +3 -1
  64. package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +3 -1
  65. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +4 -2
  66. package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +4 -2
  67. package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +3 -1
  68. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +6 -4
  69. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +3 -1
  70. package/dist/esm/tools/segmentation/CircleScissorsTool.js +3 -1
  71. package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -1
  72. package/dist/esm/tools/segmentation/PaintFillTool.js +3 -1
  73. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +3 -1
  74. package/dist/esm/tools/segmentation/RectangleROIThresholdTool.js +3 -1
  75. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +3 -1
  76. package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +3 -1
  77. package/dist/esm/tools/segmentation/SegmentSelectTool.d.ts +6 -1
  78. package/dist/esm/tools/segmentation/SegmentSelectTool.js +30 -4
  79. package/dist/esm/tools/segmentation/SphereScissorsTool.js +3 -1
  80. package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +3 -1
  81. package/dist/esm/tools/segmentation/strategies/compositions/index.js +1 -1
  82. package/dist/esm/types/SegmentationStateTypes.d.ts +4 -0
  83. package/dist/esm/utilities/calibrateImageSpacing.js +3 -1
  84. package/dist/esm/utilities/cine/playClip.js +3 -1
  85. package/dist/esm/utilities/contourSegmentation/applyContourStroke.js +3 -1
  86. package/dist/esm/utilities/contourSegmentation/contourSegmentationOperation.js +4 -2
  87. package/dist/esm/utilities/contourSegmentation/convertContourSegmentation.js +3 -1
  88. package/dist/esm/utilities/contourSegmentation/logicalOperators.js +6 -4
  89. package/dist/esm/utilities/contourSegmentation/mergeMultipleAnnotations.js +3 -1
  90. package/dist/esm/utilities/contourSegmentation/sharedOperations.js +3 -1
  91. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +3 -1
  92. package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js +3 -1
  93. package/dist/esm/utilities/contours/interpolation/interpolate.js +3 -1
  94. package/dist/esm/utilities/dynamicVolume/generateImageFromTimeData.js +4 -2
  95. package/dist/esm/utilities/dynamicVolume/getDataInTime.js +3 -1
  96. package/dist/esm/utilities/index.d.ts +2 -1
  97. package/dist/esm/utilities/index.js +2 -1
  98. package/dist/esm/utilities/livewire/LivewireScissors.js +3 -1
  99. package/dist/esm/utilities/math/basic/Calculator.js +3 -1
  100. package/dist/esm/utilities/math/polyline/addCanvasPointsToArray.js +3 -1
  101. package/dist/esm/utilities/math/polyline/combinePolyline.js +4 -2
  102. package/dist/esm/utilities/math/polyline/getSubPixelSpacingAndXYDirections.js +12 -6
  103. package/dist/esm/utilities/math/polyline/intersectPolylines.js +4 -2
  104. package/dist/esm/utilities/math/polyline/subtractPolylines.js +4 -2
  105. package/dist/esm/utilities/sampleAreaAnnotationVoxels.d.ts +44 -0
  106. package/dist/esm/utilities/sampleAreaAnnotationVoxels.js +63 -0
  107. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +5 -3
  108. package/dist/esm/utilities/segmentation/growCut/runFloodFillSegmentation.js +10 -5
  109. package/dist/esm/utilities/segmentation/growCut/runGrowCut.js +3 -1
  110. package/dist/esm/utilities/segmentation/growCut/runGrowCutForSphere.js +3 -1
  111. package/dist/esm/utilities/segmentation/growCut/runOneClickGrowCut.js +10 -8
  112. package/dist/esm/utilities/segmentation/isLineInSegment.js +3 -1
  113. package/dist/esm/utilities/segmentation/islandRemoval.js +3 -1
  114. package/dist/esm/utilities/segmentation/segmentContourAction.js +4 -2
  115. package/dist/esm/utilities/segmentation/utilsForWorker.js +4 -2
  116. package/dist/esm/utilities/spatial/areViewportsSpatiallyLinked.js +2 -1
  117. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js +5 -3
  118. package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +4 -2
  119. package/dist/esm/utilities/triggerAnnotationRenderForToolGroupIds.js +4 -2
  120. package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +4 -2
  121. package/dist/esm/utilities/voi/colorbar/Colorbar.js +3 -1
  122. package/dist/esm/utilities/voi/windowlevel/extractWindowLevelRegionToolData.js +3 -1
  123. package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.js +4 -2
  124. package/dist/esm/version.d.ts +1 -1
  125. package/dist/esm/version.js +1 -1
  126. package/dist/esm/workers/computeWorker.js +5 -3
  127. package/package.json +4 -5
  128. package/LICENSE +0 -21
@@ -0,0 +1,44 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import { utilities as csUtils } from '@cornerstonejs/core';
3
+ export type AreaAnnotationVolume = {
4
+ dimensions: Types.Point3;
5
+ direction: Types.Mat3;
6
+ spacing: Types.Point3;
7
+ origin: Types.Point3;
8
+ };
9
+ export type AreaAnnotationShape = csUtils.voxelSlab.VoxelSlabShape;
10
+ export type AreaAnnotationVoxel = {
11
+ value: number;
12
+ pointLPS: Types.Point3;
13
+ pointIJK: Types.Point3;
14
+ };
15
+ export interface AreaAnnotationVoxelsOptions {
16
+ annotation: {
17
+ metadata?: {
18
+ viewPlaneNormal?: Types.Point3;
19
+ planeRestriction?: {
20
+ referencePlaneThickness?: number;
21
+ inPlaneVector1?: Types.Point3;
22
+ inPlaneVector2?: Types.Point3;
23
+ };
24
+ };
25
+ };
26
+ image: AreaAnnotationVolume & {
27
+ imageData: any;
28
+ };
29
+ voxelManager: {
30
+ getAtIJKPoint(ijk: Types.Point3): number;
31
+ };
32
+ points: Types.Point3[];
33
+ boundsMargin?: number;
34
+ createShape: (args: {
35
+ volume: AreaAnnotationVolume;
36
+ planePoint: Types.Point3;
37
+ viewPlaneNormal: Types.Point3;
38
+ }) => AreaAnnotationShape | null | undefined;
39
+ planePoint?: Types.Point3;
40
+ minimumPoints?: number;
41
+ onSample?: (sample: AreaAnnotationVoxel) => void;
42
+ storePointData?: boolean;
43
+ }
44
+ export default function sampleAreaAnnotationVoxels({ annotation, image, voxelManager, points, boundsMargin, createShape, planePoint: planePointOverride, minimumPoints, onSample, storePointData, }: AreaAnnotationVoxelsOptions): AreaAnnotationVoxel[];
@@ -0,0 +1,63 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ import { utilities as csUtils } from '@cornerstonejs/core';
3
+ import { getBoundingBoxAroundShapeIJK } from './boundingBox/index.js';
4
+ const { asUnitNormal, getMembershipHalfWidth, getVoxelThicknessAlongNormal, resolveReferencePlaneThickness, sampleVoxelsInShape, } = csUtils.voxelSlab;
5
+ export default function sampleAreaAnnotationVoxels({ annotation, image, voxelManager, points, boundsMargin = 0, createShape, planePoint: planePointOverride, minimumPoints = 3, onSample, storePointData, }) {
6
+ const viewPlaneNormal = resolveAnnotationNormal(annotation?.metadata);
7
+ if (!voxelManager ||
8
+ !image ||
9
+ !viewPlaneNormal ||
10
+ !(points?.length >= minimumPoints)) {
11
+ return [];
12
+ }
13
+ const planePoint = planePointOverride ?? points[0];
14
+ const { dimensions, direction, spacing, origin, imageData } = image;
15
+ const volume = { dimensions, direction, spacing, origin };
16
+ const voxelThickness = getVoxelThicknessAlongNormal(volume, viewPlaneNormal);
17
+ const referencePlaneThickness = resolveReferencePlaneThickness(annotation.metadata?.planeRestriction?.referencePlaneThickness, voxelThickness);
18
+ const shape = createShape({ volume, planePoint, viewPlaneNormal });
19
+ if (!shape) {
20
+ return [];
21
+ }
22
+ const slabThickness = shape.getRequiredThickness() || referencePlaneThickness;
23
+ return sampleVoxelsInShape({
24
+ volume,
25
+ planePoint,
26
+ viewPlaneNormal,
27
+ referencePlaneThickness: slabThickness,
28
+ bounds: getAnnotationIndexBounds(points, volume, imageData, viewPlaneNormal, getMembershipHalfWidth(slabThickness, voxelThickness), boundsMargin),
29
+ getShapeRuns: shape.getRuns,
30
+ voxelManager,
31
+ onSample,
32
+ storePointData,
33
+ });
34
+ }
35
+ function resolveAnnotationNormal(metadata) {
36
+ const recorded = metadata?.viewPlaneNormal;
37
+ if (recorded && vec3.squaredLength(recorded) > 0) {
38
+ return asUnitNormal(recorded);
39
+ }
40
+ const { inPlaneVector1, inPlaneVector2 } = metadata?.planeRestriction ?? {};
41
+ if (!inPlaneVector1 || !inPlaneVector2) {
42
+ return undefined;
43
+ }
44
+ const normal = vec3.cross(vec3.create(), inPlaneVector1, inPlaneVector2);
45
+ return vec3.squaredLength(normal) > 0
46
+ ? asUnitNormal(normal)
47
+ : undefined;
48
+ }
49
+ function getAnnotationIndexBounds(points, volume, imageData, viewPlaneNormal, halfWidth, margin) {
50
+ const { dimensions, direction, spacing } = volume;
51
+ const indexPoints = points.map((point) => imageData.worldToIndex(point));
52
+ const boundingBox = getBoundingBoxAroundShapeIJK(indexPoints);
53
+ return [0, 1, 2].map((axis) => {
54
+ const axisVector = direction.slice(axis * 3, axis * 3 + 3);
55
+ const dilation = Math.ceil((margin +
56
+ halfWidth * Math.abs(vec3.dot(axisVector, viewPlaneNormal))) /
57
+ spacing[axis]) + 1;
58
+ return [
59
+ Math.max(0, Math.floor(boundingBox[axis][0]) - dilation),
60
+ Math.min(dimensions[axis] - 1, Math.ceil(boundingBox[axis][1]) + dilation),
61
+ ];
62
+ });
63
+ }
@@ -7,6 +7,8 @@ import deleteRelatedAnnotations from './deleteRelatedAnnotations.js';
7
7
  import ChangeTypes from '../../../enums/ChangeTypes.js';
8
8
  import getViewportForAnnotation from '../../getViewportForAnnotation.js';
9
9
  import { addContourSegmentationAnnotation } from '../../contourSegmentation/addContourSegmentationAnnotation.js';
10
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
11
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.InterpolationManager.InterpolationManager');
10
12
  const { uuidv4 } = csUtils;
11
13
  const ChangeTypesForInterpolation = [
12
14
  ChangeTypes.HandlesUpdated,
@@ -70,7 +72,7 @@ InterpolationManager.handleAnnotationCompleted = (evt) => {
70
72
  }
71
73
  const viewport = getViewportForAnnotation(annotation);
72
74
  if (!viewport) {
73
- console.warn('Unable to find viewport for', annotation);
75
+ cs3dLogger.warn('Unable to find viewport for', annotation);
74
76
  return;
75
77
  }
76
78
  const sliceData = getSliceData(viewport);
@@ -134,7 +136,7 @@ InterpolationManager.handleAnnotationUpdate = (evt) => {
134
136
  }
135
137
  const viewport = getViewportForAnnotation(annotation);
136
138
  if (!viewport) {
137
- console.warn('Unable to find matching viewport for annotation interpolation', annotation);
139
+ cs3dLogger.warn('Unable to find matching viewport for annotation interpolation', annotation);
138
140
  return;
139
141
  }
140
142
  if (annotation.autoGenerated) {
@@ -162,7 +164,7 @@ InterpolationManager.handleAnnotationDelete = (evt) => {
162
164
  }
163
165
  const viewport = getViewportForAnnotation(annotation);
164
166
  if (!viewport) {
165
- console.warn("No viewport, can't delete interpolated results", annotation);
167
+ cs3dLogger.warn("No viewport, can't delete interpolated results", annotation);
166
168
  return;
167
169
  }
168
170
  const sliceData = getSliceData(viewport);
@@ -9,14 +9,19 @@ import { getViewportVoiMappingForVolume } from './getViewportVoiMappingForVolume
9
9
  const { transformWorldToIndex, mapScalarToViewportVoiIntensity, mapMappedBandToRawRange, } = csUtils;
10
10
  const { growCutLog: log } = csUtils.logger;
11
11
  const ENABLE_VERBOSE_FLOOD_FILL_LOGS = false;
12
+ const timingStarts = new Map();
12
13
  const timeStart = (label) => {
13
14
  if (ENABLE_VERBOSE_FLOOD_FILL_LOGS) {
14
- console.time(label);
15
+ timingStarts.set(label, performance.now());
15
16
  }
16
17
  };
17
18
  const timeEnd = (label) => {
18
19
  if (ENABLE_VERBOSE_FLOOD_FILL_LOGS) {
19
- console.timeEnd(label);
20
+ const start = timingStarts.get(label);
21
+ if (start !== undefined) {
22
+ log.debug(`${label}: ${performance.now() - start}ms`);
23
+ timingStarts.delete(label);
24
+ }
20
25
  }
21
26
  };
22
27
  const FLOOD_FILL_PREP_TIMING_LABEL = 'cornerstone.tools: floodFill: prep';
@@ -289,7 +294,7 @@ async function runFloodFillSegmentation({ referencedVolumeId, worldPosition, vie
289
294
  ...diagnostics,
290
295
  });
291
296
  if (ENABLE_VERBOSE_FLOOD_FILL_LOGS) {
292
- console.info('[cornerstone-tools] flood fill intensity range', {
297
+ log.info('[cornerstone-tools] flood fill intensity range', {
293
298
  rawMin: clampedRangeMin,
294
299
  rawMax: clampedRangeMax,
295
300
  strategy: diagnostics.strategy,
@@ -326,7 +331,7 @@ async function runFloodFillSegmentation({ referencedVolumeId, worldPosition, vie
326
331
  }
327
332
  }
328
333
  if (ENABLE_VERBOSE_FLOOD_FILL_LOGS) {
329
- console.info('[cornerstone-tools] flood fill seed + effective tolerance', {
334
+ log.info('[cornerstone-tools] flood fill seed + effective tolerance', {
330
335
  seedScalar,
331
336
  effectiveMin: positiveMin,
332
337
  effectiveMax: positiveMax,
@@ -504,7 +509,7 @@ async function runFloodFillSegmentation({ referencedVolumeId, worldPosition, vie
504
509
  otherCount += 1;
505
510
  }
506
511
  }
507
- console.info('[cornerstone-tools] flood fill final voxel check', {
512
+ log.info('[cornerstone-tools] flood fill final voxel check', {
508
513
  floodedPoints: floodedPoints.length,
509
514
  segmentIndex,
510
515
  paintIndex,
@@ -1,5 +1,7 @@
1
1
  import { cache } from '@cornerstonejs/core';
2
2
  import shaderCode from './growCutShader.js';
3
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
4
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.growCut.runGrowCut');
3
5
  const GB = 1024 * 1024 * 1024;
4
6
  const WEBGPU_MEMORY_LIMIT = 1.99 * GB;
5
7
  const DEFAULT_GROWCUT_OPTIONS = {
@@ -273,7 +275,7 @@ async function runGrowCut(referenceVolumeId, labelmapVolumeId, options = DEFAULT
273
275
  }
274
276
  }
275
277
  if (limitProcessingTime && performance.now() > limitProcessingTime) {
276
- console.warn(`Exceeded processing time limit (${maxProcessingTime})ms`);
278
+ cs3dLogger.warn(`Exceeded processing time limit (${maxProcessingTime})ms`);
277
279
  break;
278
280
  }
279
281
  }
@@ -3,6 +3,8 @@ import { utilities as csUtils, cache, volumeLoader } from '@cornerstonejs/core';
3
3
  import getViewportICamera from '../../getViewportICamera.js';
4
4
  import { run } from './runGrowCut.js';
5
5
  import { getSphereBoundsInfo } from '../../getSphereBoundsInfo.js';
6
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
7
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.growCut.runGrowCutForSphere');
6
8
  const { transformWorldToIndex } = csUtils;
7
9
  const POSITIVE_SEED_VALUE = 254;
8
10
  const NEGATIVE_SEED_VALUE = 255;
@@ -36,7 +38,7 @@ function _createSubVolumeFromSphere(referencedVolume, sphereInfo, viewport) {
36
38
  !csUtils.isEqual(Math.abs(vec[1]), 1) &&
37
39
  !csUtils.isEqual(Math.abs(vec[2]), 1));
38
40
  if (obliqueView) {
39
- console.warn('Oblique view is not supported!');
41
+ cs3dLogger.warn('Oblique view is not supported!');
40
42
  return;
41
43
  }
42
44
  const { boundsIJK: sphereBoundsIJK } = _getSphereBoundsInfo(referencedVolume, sphereInfo);
@@ -1,6 +1,8 @@
1
1
  import { utilities as csUtils, cache, volumeLoader } from '@cornerstonejs/core';
2
2
  import { run } from './runGrowCut.js';
3
3
  import { POSITIVE_SEED_LABEL, NEGATIVE_SEED_LABEL, DEFAULT_NEIGHBORHOOD_RADIUS, DEFAULT_POSITIVE_STD_DEV_MULTIPLIER, DEFAULT_NEGATIVE_STD_DEV_MULTIPLIER, DEFAULT_NEGATIVE_SEED_MARGIN, DEFAULT_NEGATIVE_SEEDS_COUNT, MAX_NEGATIVE_SEED_ATTEMPTS_MULTIPLIER, } from './constants.js';
4
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
5
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.growCut.runOneClickGrowCut');
4
6
  const { transformWorldToIndex } = csUtils;
5
7
  const MAX_POSITIVE_SEEDS = 100000;
6
8
  function calculateGrowCutSeeds(referencedVolume, worldPosition, options) {
@@ -22,7 +24,7 @@ function calculateGrowCutSeeds(referencedVolume, worldPosition, options) {
22
24
  ijkStart[1] >= height ||
23
25
  ijkStart[2] < 0 ||
24
26
  ijkStart[2] >= numSlices) {
25
- console.warn('Click position is outside volume bounds.');
27
+ cs3dLogger.warn('Click position is outside volume bounds.');
26
28
  return null;
27
29
  }
28
30
  const initialStats = csUtils.calculateNeighborhoodStats(scalarData, dimensions, ijkStart, neighborhoodRadius);
@@ -54,7 +56,7 @@ function calculateGrowCutSeeds(referencedVolume, worldPosition, options) {
54
56
  minZ = maxZ = ijkStart[2];
55
57
  }
56
58
  else {
57
- console.warn('Clicked voxel intensity is outside the calculated positive range. No positive seeds generated.');
59
+ cs3dLogger.warn('Clicked voxel intensity is outside the calculated positive range. No positive seeds generated.');
58
60
  return { positiveSeedIndices: new Set(), negativeSeedIndices: new Set() };
59
61
  }
60
62
  let currentQueueIndex = 0;
@@ -95,10 +97,10 @@ function calculateGrowCutSeeds(referencedVolume, worldPosition, options) {
95
97
  }
96
98
  }
97
99
  if (positiveSeedIndices.size >= MAX_POSITIVE_SEEDS) {
98
- console.debug(`Reached maximum number of positive seeds (${MAX_POSITIVE_SEEDS}). Stopping BFS.`);
100
+ cs3dLogger.debug(`Reached maximum number of positive seeds (${MAX_POSITIVE_SEEDS}). Stopping BFS.`);
99
101
  }
100
102
  if (positiveSeedIndices.size === 0) {
101
- console.warn('No positive seeds found after BFS.');
103
+ cs3dLogger.warn('No positive seeds found after BFS.');
102
104
  return { positiveSeedIndices: new Set(), negativeSeedIndices: new Set() };
103
105
  }
104
106
  let positiveSum = 0;
@@ -161,10 +163,10 @@ function calculateGrowCutSeeds(referencedVolume, worldPosition, options) {
161
163
  }
162
164
  }
163
165
  if (negativeSeedIndices.size === 0) {
164
- console.warn('Could not find any negative seeds. GrowCut might fail or produce poor results.');
166
+ cs3dLogger.warn('Could not find any negative seeds. GrowCut might fail or produce poor results.');
165
167
  }
166
- console.debug('positiveSeedIndices', positiveSeedIndices.size);
167
- console.debug('negativeSeedIndices', negativeSeedIndices.size);
168
+ cs3dLogger.debug('positiveSeedIndices', positiveSeedIndices.size);
169
+ cs3dLogger.debug('negativeSeedIndices', negativeSeedIndices.size);
168
170
  return { positiveSeedIndices, negativeSeedIndices };
169
171
  }
170
172
  async function runOneClickGrowCut({ referencedVolumeId, worldPosition, options, }) {
@@ -186,7 +188,7 @@ async function runOneClickGrowCut({ referencedVolumeId, worldPosition, options,
186
188
  if (positiveSeedIndices.size < 10 ||
187
189
  positiveSeedIndices.size > MAX_POSITIVE_SEEDS ||
188
190
  negativeSeedIndices.size < 10) {
189
- console.warn('Not enough seeds found. GrowCut might fail or produce poor results.');
191
+ cs3dLogger.warn('Not enough seeds found. GrowCut might fail or produce poor results.');
190
192
  return labelmap;
191
193
  }
192
194
  positiveSeedIndices.forEach((index) => {
@@ -1,5 +1,7 @@
1
1
  import { cache } from '@cornerstonejs/core';
2
2
  import { vec3 } from 'gl-matrix';
3
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
4
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.isLineInSegment');
3
5
  export default function isLineInSegment(point1, point2, isInSegment) {
4
6
  const ijk1 = isInSegment.toIJK(point1);
5
7
  const ijk2 = isInSegment.toIJK(point2);
@@ -43,7 +45,7 @@ function createIsInSegmentMetadata({ dimensions, imageData, voxelManager, segmen
43
45
  function createIsInSegment(segVolumeId, segmentIndex, containedSegmentIndices) {
44
46
  const vol = cache.getVolume(segVolumeId);
45
47
  if (!vol) {
46
- console.warn(`No volume found for ${segVolumeId}`);
48
+ cs3dLogger.warn(`No volume found for ${segVolumeId}`);
47
49
  return;
48
50
  }
49
51
  return createIsInSegmentMetadata({
@@ -1,5 +1,7 @@
1
1
  import { utilities } from '@cornerstonejs/core';
2
2
  import normalizeViewportPlane from '../normalizeViewportPlane.js';
3
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
4
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.islandRemoval');
3
5
  const { RLEVoxelMap, VoxelManager } = utilities;
4
6
  const MAX_IMAGE_SIZE = 65535;
5
7
  export var SegmentationEnum;
@@ -43,7 +45,7 @@ export default class IslandRemoval {
43
45
  }
44
46
  const { toIJK, fromIJK, boundsIJKPrime, error } = normalizeViewportPlane(viewport, boundsIJK);
45
47
  if (error) {
46
- console.warn('Not performing island removal for planes not orthogonal to acquisition plane', error);
48
+ cs3dLogger.warn('Not performing island removal for planes not orthogonal to acquisition plane', error);
47
49
  return;
48
50
  }
49
51
  const [width, height, depth] = fromIJK(segmentationVoxelManager.dimensions);
@@ -5,8 +5,10 @@ import createBidirectionalToolData from './createBidirectionalToolData.js';
5
5
  import BidirectionalTool from '../../tools/annotation/BidirectionalTool.js';
6
6
  import { getSegmentations } from '../../stateManagement/segmentation/getSegmentations.js';
7
7
  import { getActiveSegmentIndex } from '../../stateManagement/segmentation/getActiveSegmentIndex.js';
8
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
9
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.segmentContourAction');
8
10
  export default async function segmentContourAction(element, configuration) {
9
- console.warn('Deprecation Alert: There is a new getSegmentLargestBidirectional function that handles volume, stack and individual segment cases properly. This function is deprecated and will be removed in a future version.');
11
+ cs3dLogger.warn('Deprecation Alert: There is a new getSegmentLargestBidirectional function that handles volume, stack and individual segment cases properly. This function is deprecated and will be removed in a future version.');
10
12
  const { data: configurationData } = configuration;
11
13
  const enabledElement = getEnabledElement(element);
12
14
  const segment = (configurationData.getSegment || defaultGetSegment)(enabledElement, configurationData);
@@ -73,7 +75,7 @@ export default async function segmentContourAction(element, configuration) {
73
75
  enabledElement.viewport.render();
74
76
  }
75
77
  else {
76
- console.warn('No bidirectional found');
78
+ cs3dLogger.warn('No bidirectional found');
77
79
  }
78
80
  return newBidirectional;
79
81
  }
@@ -4,6 +4,8 @@ import { getSegmentation } from '../../stateManagement/segmentation/getSegmentat
4
4
  import { getStrategyData } from '../../tools/segmentation/strategies/utils/getStrategyData.js';
5
5
  import ensureSegmentationVolume from '../../tools/segmentation/strategies/compositions/ensureSegmentationVolume.js';
6
6
  import ensureImageVolume from '../../tools/segmentation/strategies/compositions/ensureImageVolume.js';
7
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
8
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.segmentation.utilsForWorker');
7
9
  export const triggerWorkerProgress = (workerType, progress) => {
8
10
  triggerEvent(eventTarget, Enums.Events.WEB_WORKER_PROGRESS, {
9
11
  progress,
@@ -13,13 +15,13 @@ export const triggerWorkerProgress = (workerType, progress) => {
13
15
  export const getSegmentationDataForWorker = (segmentationId, segmentIndices) => {
14
16
  const segmentation = getSegmentation(segmentationId);
15
17
  if (!segmentation?.representationData) {
16
- console.debug('getSegmentationDataForWorker: segmentation missing or not ready', segmentationId);
18
+ cs3dLogger.debug('getSegmentationDataForWorker: segmentation missing or not ready', segmentationId);
17
19
  return null;
18
20
  }
19
21
  const { representationData } = segmentation;
20
22
  const { Labelmap } = representationData;
21
23
  if (!Labelmap) {
22
- console.debug('No labelmap found for segmentation', segmentationId);
24
+ cs3dLogger.debug('No labelmap found for segmentation', segmentationId);
23
25
  return null;
24
26
  }
25
27
  const segVolumeId = Labelmap.volumeId;
@@ -39,7 +39,8 @@ export default function areViewportsSpatiallyLinked(source, target, options) {
39
39
  case 'toolGroup': {
40
40
  const sourceToolGroup = getToolGroupForViewport(source.id, source.renderingEngineId);
41
41
  const targetToolGroup = getToolGroupForViewport(target.id, target.renderingEngineId);
42
- return (!!sourceToolGroup && !!targetToolGroup &&
42
+ return (!!sourceToolGroup &&
43
+ !!targetToolGroup &&
43
44
  sourceToolGroup.id === targetToolGroup.id);
44
45
  }
45
46
  default:
@@ -2,6 +2,8 @@ import { imageLoader, Enums, eventTarget, imageLoadPoolManager, cache, metaData,
2
2
  import { addToolState, getToolState } from './state.js';
3
3
  import { getStackData, requestType, clearFromImageIds, getPromiseRemovedHandler, } from './stackPrefetchUtils.js';
4
4
  import { Events } from '../../enums/index.js';
5
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
6
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.stackPrefetch.stackContextPrefetch');
5
7
  const { imageRetrieveMetadataProvider } = utilities;
6
8
  let configuration = {
7
9
  maxImagesToPrefetch: Infinity,
@@ -19,7 +21,7 @@ const enable = (element, priority = 0) => {
19
21
  return;
20
22
  }
21
23
  if (!stack.imageIds?.length) {
22
- console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
24
+ cs3dLogger.warn('CornerstoneTools.stackPrefetch: No images in stack.');
23
25
  return;
24
26
  }
25
27
  updateToolState(element);
@@ -37,7 +39,7 @@ function prefetch(element, priority = 0) {
37
39
  return;
38
40
  }
39
41
  if (!stack?.imageIds?.length) {
40
- console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
42
+ cs3dLogger.warn('CornerstoneTools.stackPrefetch: No images in stack.');
41
43
  return;
42
44
  }
43
45
  const stackPrefetchData = getToolState(element);
@@ -154,7 +156,7 @@ const updateToolState = (element, usage) => {
154
156
  return;
155
157
  }
156
158
  if (!stack.imageIds?.length) {
157
- console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
159
+ cs3dLogger.warn('CornerstoneTools.stackPrefetch: No images in stack.');
158
160
  return;
159
161
  }
160
162
  const { currentImageIdIndex } = stack;
@@ -2,6 +2,8 @@ import { imageLoader, Enums, eventTarget, imageLoadPoolManager, cache, metaData,
2
2
  import { addToolState, getToolState } from './state.js';
3
3
  import { getStackData, requestType, priority, getPromiseRemovedHandler, nearestIndex, range, } from './stackPrefetchUtils.js';
4
4
  import { Events } from '../../enums/index.js';
5
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
6
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.stackPrefetch.stackPrefetch');
5
7
  const { imageRetrieveMetadataProvider } = utilities;
6
8
  let configuration = {
7
9
  maxImagesToPrefetch: Infinity,
@@ -17,7 +19,7 @@ function prefetch(element) {
17
19
  const stackPrefetch = (stackPrefetchData || {});
18
20
  const stack = getStackData(element);
19
21
  if (!stack?.imageIds?.length) {
20
- console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
22
+ cs3dLogger.warn('CornerstoneTools.stackPrefetch: No images in stack.');
21
23
  return;
22
24
  }
23
25
  const { currentImageIdIndex } = stack;
@@ -128,7 +130,7 @@ function onImageUpdated(e) {
128
130
  function enable(element) {
129
131
  const stack = getStackData(element);
130
132
  if (!stack || !stack.imageIds || stack.imageIds.length === 0) {
131
- console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
133
+ cs3dLogger.warn('CornerstoneTools.stackPrefetch: No images in stack.');
132
134
  return;
133
135
  }
134
136
  const stackPrefetchData = {
@@ -1,11 +1,13 @@
1
1
  import { getRenderingEngine } from '@cornerstonejs/core';
2
2
  import triggerAnnotationRender from './triggerAnnotationRender.js';
3
3
  import { getToolGroup } from '../store/ToolGroupManager/index.js';
4
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
5
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.triggerAnnotationRenderForToolGroupIds');
4
6
  export function triggerAnnotationRenderForToolGroupIds(toolGroupIds) {
5
7
  toolGroupIds.forEach((toolGroupId) => {
6
8
  const toolGroup = getToolGroup(toolGroupId);
7
9
  if (!toolGroup) {
8
- console.warn(`ToolGroup not available for ${toolGroupId}`);
10
+ cs3dLogger.warn(`ToolGroup not available for ${toolGroupId}`);
9
11
  return;
10
12
  }
11
13
  const viewportsInfo = toolGroup.getViewportsInfo();
@@ -13,7 +15,7 @@ export function triggerAnnotationRenderForToolGroupIds(toolGroupIds) {
13
15
  const { renderingEngineId, viewportId } = viewportInfo;
14
16
  const renderingEngine = getRenderingEngine(renderingEngineId);
15
17
  if (!renderingEngine) {
16
- console.warn(`RenderingEngine not available for ${renderingEngineId}`);
18
+ cs3dLogger.warn(`RenderingEngine not available for ${renderingEngineId}`);
17
19
  return;
18
20
  }
19
21
  const viewport = renderingEngine.getViewport(viewportId);
@@ -1,5 +1,7 @@
1
1
  import { getEnabledElementByViewportId } from '@cornerstonejs/core';
2
2
  import triggerAnnotationRender from './triggerAnnotationRender.js';
3
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
4
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.triggerAnnotationRenderForViewportIds');
3
5
  export function triggerAnnotationRenderForViewportIds(viewportIdsToRender) {
4
6
  if (!viewportIdsToRender.length) {
5
7
  return;
@@ -7,12 +9,12 @@ export function triggerAnnotationRenderForViewportIds(viewportIdsToRender) {
7
9
  viewportIdsToRender.forEach((viewportId) => {
8
10
  const enabledElement = getEnabledElementByViewportId(viewportId);
9
11
  if (!enabledElement) {
10
- console.warn(`Viewport not available for ${viewportId}`);
12
+ cs3dLogger.warn(`Viewport not available for ${viewportId}`);
11
13
  return;
12
14
  }
13
15
  const { viewport } = enabledElement;
14
16
  if (!viewport) {
15
- console.warn(`Viewport not available for ${viewportId}`);
17
+ cs3dLogger.warn(`Viewport not available for ${viewportId}`);
16
18
  return;
17
19
  }
18
20
  const element = viewport.element;
@@ -6,6 +6,8 @@ import { ColorbarCanvas } from './ColorbarCanvas.js';
6
6
  import { ColorbarTicks } from './ColorbarTicks.js';
7
7
  import isRangeTextPositionValid from './common/isRangeTextPositionValid.js';
8
8
  import Widget from '../../../widgets/Widget.js';
9
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
10
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.voi.colorbar.Colorbar');
9
11
  const DEFAULTS = {
10
12
  MULTIPLIER: 1,
11
13
  RANGE_TEXT_POSITION: ColorbarRangeTextPosition.Right,
@@ -78,7 +80,7 @@ class Colorbar extends Widget {
78
80
  }
79
81
  const colormap = this._colormaps.get(colormapName);
80
82
  if (!colormap) {
81
- console.warn(`Invalid colormap name (${colormapName})`);
83
+ cs3dLogger.warn(`Invalid colormap name (${colormapName})`);
82
84
  return;
83
85
  }
84
86
  this._activeColormapName = colormapName;
@@ -1,4 +1,6 @@
1
1
  import { cache, utilities as csUtils, StackViewport, VolumeViewport, } from '@cornerstonejs/core';
2
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
3
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.voi.windowlevel.extractWindowLevelRegionToolData');
2
4
  function extractWindowLevelRegionToolData(viewport) {
3
5
  if (viewport instanceof VolumeViewport) {
4
6
  return extractImageDataVolume(viewport);
@@ -45,7 +47,7 @@ function extractImageDataStack(viewport) {
45
47
  function extractImageDataGeneric(viewport) {
46
48
  const imageId = viewport.getCurrentImageId();
47
49
  if (!imageId) {
48
- console.warn('WindowLevelRegionTool: the current native viewport slice has no backing image (reformatted/oblique volume plane); skipping region window level.');
50
+ cs3dLogger.warn('WindowLevelRegionTool: the current native viewport slice has no backing image (reformatted/oblique volume plane); skipping region window level.');
49
51
  return undefined;
50
52
  }
51
53
  const image = cache.getImage(imageId);
@@ -8,6 +8,8 @@ import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer.js';
8
8
  import { Enums } from '@cornerstonejs/core';
9
9
  import vtkAnnotatedRhombicuboctahedronActor from '../AnnotatedRhombicuboctahedronActor/index.js';
10
10
  import { beginOwnedDrag, endOwnedDrag } from '../../interactionDragCoordinator.js';
11
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
12
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('utilities.vtkjs.OrientationControllerWidget.index');
11
13
  export class vtkOrientationControllerWidget {
12
14
  constructor() {
13
15
  this.actors = new Map();
@@ -239,7 +241,7 @@ export class vtkOrientationControllerWidget {
239
241
  positionActors(viewport, actors, config) {
240
242
  const canvas = viewport.canvas;
241
243
  if (!canvas) {
242
- console.warn('OrientationControllerWidget: No canvas available');
244
+ cs3dLogger.warn('OrientationControllerWidget: No canvas available');
243
245
  return false;
244
246
  }
245
247
  const mainRenderer = viewport
@@ -262,7 +264,7 @@ export class vtkOrientationControllerWidget {
262
264
  actor.setScale(markerSize, markerSize, markerSize);
263
265
  const worldPos = this.calculateMarkerPosition(viewport, config.position, screenSizePixels);
264
266
  if (!worldPos) {
265
- console.warn('OrientationControllerWidget: Could not get world position');
267
+ cs3dLogger.warn('OrientationControllerWidget: Could not get world position');
266
268
  return;
267
269
  }
268
270
  actor.setPosition(worldPos[0], worldPos[1], worldPos[2]);
@@ -1 +1 @@
1
- export declare const version = "5.8.1";
1
+ export declare const version = "5.10.2";
@@ -1 +1 @@
1
- export const version = '5.8.1';
1
+ export const version = '5.10.2';
@@ -9,6 +9,8 @@ import { getDeduplicatedVTKPolyDataPoints } from '../utilities/contours/getDedup
9
9
  import { findContoursFromReducedSet } from '../utilities/contours/contourFinder.js';
10
10
  import { createBidirectionalForSlice } from '../utilities/segmentation/findLargestBidirectional.js';
11
11
  import { createIsInSegmentMetadata } from '../utilities/segmentation/isLineInSegment.js';
12
+ import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
13
+ const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('workers.computeWorker');
12
14
  const { VoxelManager } = utilities;
13
15
  const computeWorker = {
14
16
  createVoxelManager: (dimensions, scalarData) => {
@@ -261,7 +263,7 @@ const computeWorker = {
261
263
  }
262
264
  }
263
265
  catch (e) {
264
- console.warn(e);
266
+ cs3dLogger.warn(e);
265
267
  }
266
268
  const isInSegment = createIsInSegmentMetadata({
267
269
  dimensions,
@@ -361,8 +363,8 @@ const computeWorker = {
361
363
  }
362
364
  }
363
365
  catch (e) {
364
- console.warn(sliceIndex);
365
- console.warn(e);
366
+ cs3dLogger.warn(sliceIndex);
367
+ cs3dLogger.warn(e);
366
368
  }
367
369
  }
368
370
  const ContourSet = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "5.8.1",
3
+ "version": "5.10.2",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -126,11 +126,11 @@
126
126
  "lodash.get": "4.4.2"
127
127
  },
128
128
  "devDependencies": {
129
- "@cornerstonejs/core": "5.8.1",
129
+ "@cornerstonejs/core": "5.10.2",
130
130
  "canvas": "3.2.0"
131
131
  },
132
132
  "peerDependencies": {
133
- "@cornerstonejs/core": "5.8.1",
133
+ "@cornerstonejs/core": "5.10.2",
134
134
  "@kitware/vtk.js": "36.4.1",
135
135
  "@types/d3-array": "3.2.1",
136
136
  "@types/d3-interpolate": "3.0.4",
@@ -148,6 +148,5 @@
148
148
  "funding": {
149
149
  "type": "individual",
150
150
  "url": "https://ohif.org/donate"
151
- },
152
- "gitHead": "b0e07ac229d4118fa46350210a0ed6ce2cd24a25"
151
+ }
153
152
  }