@cornerstonejs/tools 5.5.1 → 5.6.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 (35) hide show
  1. package/dist/esm/index.d.ts +2 -2
  2. package/dist/esm/index.js +2 -2
  3. package/dist/esm/tools/annotation/BidirectionalTool.js +0 -1
  4. package/dist/esm/tools/annotation/CircleROITool.d.ts +4 -1
  5. package/dist/esm/tools/annotation/CircleROITool.js +34 -34
  6. package/dist/esm/tools/annotation/DragProbeTool.js +1 -1
  7. package/dist/esm/tools/annotation/RectangleROITool.d.ts +2 -2
  8. package/dist/esm/tools/annotation/RectangleROITool.js +23 -49
  9. package/dist/esm/tools/base/AnnotationTool.js +6 -4
  10. package/dist/esm/tools/base/BaseTool.d.ts +15 -4
  11. package/dist/esm/tools/base/BaseTool.js +127 -6
  12. package/dist/esm/tools/base/index.d.ts +3 -1
  13. package/dist/esm/tools/base/index.js +3 -1
  14. package/dist/esm/tools/base/measurementTargetFilters.d.ts +19 -0
  15. package/dist/esm/tools/base/measurementTargetFilters.js +38 -0
  16. package/dist/esm/tools/index.d.ts +2 -2
  17. package/dist/esm/tools/index.js +2 -2
  18. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.d.ts +2 -40
  19. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +1 -2
  20. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +0 -1
  21. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +0 -1
  22. package/dist/esm/types/AnnotationTypes.d.ts +34 -1
  23. package/dist/esm/types/IBaseTool.d.ts +22 -0
  24. package/dist/esm/types/ToolSpecificAnnotationTypes.d.ts +26 -53
  25. package/dist/esm/types/index.d.ts +2 -2
  26. package/dist/esm/utilities/defaultGetTextLines.d.ts +9 -0
  27. package/dist/esm/utilities/defaultGetTextLines.js +53 -0
  28. package/dist/esm/utilities/getEllipseWorldCoordinates.d.ts +2 -2
  29. package/dist/esm/utilities/getEllipseWorldCoordinates.js +2 -2
  30. package/dist/esm/utilities/index.d.ts +1 -0
  31. package/dist/esm/utilities/index.js +1 -0
  32. package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js +1 -1
  33. package/dist/esm/version.d.ts +1 -1
  34. package/dist/esm/version.js +1 -1
  35. package/package.json +4 -4
@@ -1,4 +1,6 @@
1
1
  import BaseTool from './BaseTool.js';
2
2
  import AnnotationTool from './AnnotationTool.js';
3
3
  import AnnotationDisplayTool from './AnnotationDisplayTool.js';
4
- export { BaseTool, AnnotationTool, AnnotationDisplayTool };
4
+ import measurementTargetFilters from './measurementTargetFilters.js';
5
+ export { BaseTool, AnnotationTool, AnnotationDisplayTool, measurementTargetFilters, };
6
+ export * from './measurementTargetFilters.js';
@@ -0,0 +1,19 @@
1
+ import type { MeasurementTargetPredicate, MeasurementTargetsFilter } from '../../types/index.js';
2
+ export declare const NON_PIXEL_DATA_MODALITIES: string[];
3
+ export declare const isPixelData: MeasurementTargetPredicate;
4
+ export declare const firstPixelData: MeasurementTargetsFilter;
5
+ export declare const allPixelData: MeasurementTargetsFilter;
6
+ export declare const first: MeasurementTargetsFilter;
7
+ export declare const all: MeasurementTargetsFilter;
8
+ export declare const forModality: (...modalities: string[]) => MeasurementTargetPredicate;
9
+ export declare const forId: (id: string) => MeasurementTargetPredicate;
10
+ export declare const measurementTargetFilters: {
11
+ isPixelData: MeasurementTargetPredicate;
12
+ firstPixelData: MeasurementTargetsFilter;
13
+ allPixelData: MeasurementTargetsFilter;
14
+ first: MeasurementTargetsFilter;
15
+ all: MeasurementTargetsFilter;
16
+ forModality: (...modalities: string[]) => MeasurementTargetPredicate;
17
+ forId: (id: string) => MeasurementTargetPredicate;
18
+ };
19
+ export default measurementTargetFilters;
@@ -0,0 +1,38 @@
1
+ export const NON_PIXEL_DATA_MODALITIES = [
2
+ 'SEG',
3
+ 'RTSTRUCT',
4
+ 'RTPLAN',
5
+ 'SR',
6
+ 'PR',
7
+ 'KO',
8
+ ];
9
+ export const isPixelData = ({ modality, representationUID, }) => !representationUID &&
10
+ (!modality || !NON_PIXEL_DATA_MODALITIES.includes(modality));
11
+ function isEligible(candidate, options) {
12
+ if (!isPixelData(candidate, options)) {
13
+ return false;
14
+ }
15
+ const { targetPredicate } = options?.configuration ?? {};
16
+ return targetPredicate ? targetPredicate(candidate, options) : true;
17
+ }
18
+ export const firstPixelData = (candidates, options) => {
19
+ const match = candidates.find((candidate) => isEligible(candidate, options));
20
+ return match ? [match] : [];
21
+ };
22
+ export const allPixelData = (candidates, options) => candidates.filter((candidate) => isEligible(candidate, options));
23
+ export const first = (candidates) => candidates.length ? [candidates[0]] : [];
24
+ export const all = (candidates) => candidates;
25
+ export const forModality = (...modalities) => ({ modality }) => modalities.includes(modality);
26
+ export const forId = (id) => ({ displaySetUID, referencedId, targetId }) => displaySetUID?.includes(id) ||
27
+ referencedId?.includes(id) ||
28
+ targetId.includes(id);
29
+ export const measurementTargetFilters = {
30
+ isPixelData,
31
+ firstPixelData,
32
+ allPixelData,
33
+ first,
34
+ all,
35
+ forModality,
36
+ forId,
37
+ };
38
+ export default measurementTargetFilters;
@@ -1,4 +1,4 @@
1
- import { BaseTool, AnnotationTool, AnnotationDisplayTool } from './base/index.js';
1
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, measurementTargetFilters } from './base/index.js';
2
2
  import PanTool from './PanTool.js';
3
3
  import TrackballRotateTool from './TrackballRotateTool.js';
4
4
  import VolumeCroppingTool from './VolumeCroppingTool.js';
@@ -64,4 +64,4 @@ import SegmentBidirectionalTool from './segmentation/SegmentBidirectionalTool.js
64
64
  import * as strategies from './segmentation/strategies/index.js';
65
65
  import SegmentLabelTool from './segmentation/SegmentLabelTool.js';
66
66
  import LabelMapEditWithContourTool from './segmentation/LabelmapEditWithContour.js';
67
- export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, WorldCrosshairTool, SliceIntersectionTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OrientationControllerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, ClickSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, LabelMapEditWithContourTool, strategies, };
67
+ export { BaseTool, AnnotationTool, AnnotationDisplayTool, measurementTargetFilters, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, WorldCrosshairTool, SliceIntersectionTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OrientationControllerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, ClickSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, LabelMapEditWithContourTool, strategies, };
@@ -1,4 +1,4 @@
1
- import { BaseTool, AnnotationTool, AnnotationDisplayTool } from './base/index.js';
1
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, measurementTargetFilters, } from './base/index.js';
2
2
  import PanTool from './PanTool.js';
3
3
  import TrackballRotateTool from './TrackballRotateTool.js';
4
4
  import VolumeCroppingTool from './VolumeCroppingTool.js';
@@ -64,4 +64,4 @@ import SegmentBidirectionalTool from './segmentation/SegmentBidirectionalTool.js
64
64
  import * as strategies from './segmentation/strategies/index.js';
65
65
  import SegmentLabelTool from './segmentation/SegmentLabelTool.js';
66
66
  import LabelMapEditWithContourTool from './segmentation/LabelmapEditWithContour.js';
67
- export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, WorldCrosshairTool, SliceIntersectionTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OrientationControllerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, ClickSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, LabelMapEditWithContourTool, strategies, };
67
+ export { BaseTool, AnnotationTool, AnnotationDisplayTool, measurementTargetFilters, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, WorldCrosshairTool, SliceIntersectionTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OrientationControllerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, ClickSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, LabelMapEditWithContourTool, strategies, };
@@ -1,7 +1,7 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
2
  import { vec3 } from 'gl-matrix';
3
3
  import type { PublicToolProps, ToolProps, EventTypes, SVGDrawingHelper, Annotation } from '../../types/index.js';
4
- import type { CircleROIStartEndThresholdAnnotation, ROICachedStats } from '../../types/ToolSpecificAnnotationTypes.js';
4
+ import type { CircleROIStartEndThresholdAnnotation } from '../../types/ToolSpecificAnnotationTypes.js';
5
5
  import CircleROITool from '../annotation/CircleROITool.js';
6
6
  declare class CircleROIStartEndThresholdTool extends CircleROITool {
7
7
  static toolName: any;
@@ -16,45 +16,7 @@ declare class CircleROIStartEndThresholdTool extends CircleROITool {
16
16
  isDrawing: boolean;
17
17
  isHandleOutsideImage: boolean;
18
18
  constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
19
- addNewAnnotation: (evt: EventTypes.InteractionEventType) => {
20
- highlighted: boolean;
21
- invalidated: boolean;
22
- metadata: {
23
- toolName: string;
24
- viewPlaneNormal: Types.Point3;
25
- viewUp: Types.Point3;
26
- FrameOfReferenceUID: string;
27
- referencedImageId: any;
28
- volumeId: any;
29
- spacingInNormal: number;
30
- enabledElement: Types.IEnabledElement;
31
- };
32
- data: {
33
- label: string;
34
- startCoordinate: number;
35
- endCoordinate: number;
36
- handles: {
37
- textBox: {
38
- hasMoved: boolean;
39
- worldPosition: Types.Point3;
40
- worldBoundingBox: {
41
- topLeft: Types.Point3;
42
- topRight: Types.Point3;
43
- bottomLeft: Types.Point3;
44
- bottomRight: Types.Point3;
45
- };
46
- };
47
- points: any;
48
- activeHandleIndex: any;
49
- };
50
- cachedStats: {
51
- pointsInVolume: any[];
52
- projectionPoints: any[];
53
- statistics: ROICachedStats;
54
- };
55
- labelmapUID: any;
56
- };
57
- };
19
+ addNewAnnotation: (evt: EventTypes.InteractionEventType) => Annotation;
58
20
  _endCallback: (evt: EventTypes.InteractionEventType) => void;
59
21
  renderAnnotation: (enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper) => boolean;
60
22
  _computeProjectionPoints(annotation: CircleROIStartEndThresholdAnnotation, imageVolume: Types.IImageVolume): void;
@@ -41,7 +41,7 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
41
41
  const { currentPoints, element } = eventDetail;
42
42
  const worldPos = currentPoints.world;
43
43
  const enabledElement = getEnabledElement(element);
44
- const { viewport, renderingEngine } = enabledElement;
44
+ const { viewport } = enabledElement;
45
45
  this.isDrawing = true;
46
46
  const camera = viewport.getCamera();
47
47
  const { viewPlaneNormal, viewUp } = camera;
@@ -108,7 +108,6 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
108
108
  projectionPoints: [],
109
109
  statistics: [],
110
110
  },
111
- labelmapUID: null,
112
111
  },
113
112
  };
114
113
  this._computeProjectionPoints(annotation, imageVolume);
@@ -55,7 +55,6 @@ declare class RectangleROIStartEndThresholdTool extends RectangleROITool {
55
55
  points: Types.Point3[];
56
56
  activeHandleIndex: any;
57
57
  };
58
- labelmapUID: any;
59
58
  };
60
59
  };
61
60
  _endCallback: (evt: EventTypes.InteractionEventType) => void;
@@ -96,7 +96,6 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
96
96
  ],
97
97
  activeHandleIndex: null,
98
98
  },
99
- labelmapUID: null,
100
99
  },
101
100
  };
102
101
  this._computeProjectionPoints(annotation, imageVolume);
@@ -6,14 +6,47 @@ export type AnnotationMetadata = Types.ViewReference & {
6
6
  segmentColor?: any;
7
7
  enabledElement?: Types.IEnabledElement;
8
8
  };
9
+ export type StatItem = {
10
+ name: string;
11
+ label: string;
12
+ value: number | number[];
13
+ unit?: string;
14
+ pointIJK?: Types.Point3;
15
+ pointLPS?: Types.Point3;
16
+ };
17
+ export interface CachedStats {
18
+ Modality?: string;
19
+ area?: number | number[];
20
+ length?: number | number[];
21
+ width?: number | number[];
22
+ unit?: string;
23
+ areaUnit?: string;
24
+ max?: number | number[];
25
+ mean?: number | number[];
26
+ min?: number | number[];
27
+ radius?: number;
28
+ radiusUnit?: string;
29
+ perimeter?: number;
30
+ statsArray?: StatItem[];
31
+ [key: string]: unknown;
32
+ }
33
+ export interface VolumeStats {
34
+ pointsInVolume: Types.Point3[];
35
+ projectionPoints: Types.Point3[] | Types.Point3[][];
36
+ projectionPointsImageIds?: string[];
37
+ statistics?: unknown;
38
+ }
9
39
  export type AnnotationData = {
10
40
  handles?: Handles;
11
- cachedStats?: Record<string, unknown>;
41
+ cachedStats?: Record<string, CachedStats> | VolumeStats;
12
42
  label?: string;
13
43
  contour?: Contour;
14
44
  isOpenUShapeContour?: boolean | 'farthestT' | 'lineSegment' | 'orthogonalT';
15
45
  [key: string]: unknown;
16
46
  };
47
+ export type AnnotationDataStatsByTargetId = Omit<AnnotationData, 'cachedStats'> & {
48
+ cachedStats: Record<string, CachedStats>;
49
+ };
17
50
  export type Annotation = {
18
51
  annotationUID?: string;
19
52
  parentAnnotationUID?: string;
@@ -1,9 +1,31 @@
1
+ import type { Types } from '@cornerstonejs/core';
1
2
  import type BaseTool from '../tools/base/BaseTool.js';
3
+ import type { AnnotationData } from './AnnotationTypes.js';
4
+ export type MeasurementTargetCandidate = {
5
+ displaySet?: unknown;
6
+ displaySetUID?: string;
7
+ instance?: any;
8
+ index: number;
9
+ referencedId?: string;
10
+ representationUID?: string;
11
+ modality?: string;
12
+ imageIds?: string[];
13
+ targetId: string;
14
+ };
15
+ export type MeasurementTargetOptions = {
16
+ viewport: Types.IViewport;
17
+ configuration: ToolConfiguration;
18
+ data?: AnnotationData;
19
+ };
20
+ export type MeasurementTargetPredicate = (candidate: MeasurementTargetCandidate, options: MeasurementTargetOptions) => boolean;
21
+ export type MeasurementTargetsFilter = (candidates: MeasurementTargetCandidate[], options: MeasurementTargetOptions) => MeasurementTargetCandidate[];
2
22
  export interface ToolConfiguration {
3
23
  strategies: any;
4
24
  defaultStrategy?: string;
5
25
  activeStrategy?: string;
6
26
  strategyOptions: any;
27
+ targetsFilter?: MeasurementTargetsFilter;
28
+ targetPredicate?: MeasurementTargetPredicate;
7
29
  isPreferredTargetId?: (viewport: any, targetInfo: {
8
30
  imageId: string;
9
31
  cachedStat: any;
@@ -1,19 +1,19 @@
1
1
  import type { Types } from '@cornerstonejs/core';
2
- import type { Annotation, AnnotationData } from './AnnotationTypes.js';
2
+ import type { Annotation, AnnotationData, CachedStats, VolumeStats } from './AnnotationTypes.js';
3
3
  import type { ISpline } from './index.js';
4
4
  import type { ContourSegmentationAnnotationData } from './ContourSegmentationAnnotation.js';
5
5
  import type { ContourAnnotation } from './ContourAnnotation.js';
6
- export interface ROICachedStats {
7
- [targetId: string]: {
8
- Modality: string;
9
- area: number;
10
- areaUnit: string;
11
- max: number;
12
- mean: number;
13
- stdDev: number;
14
- unit?: number;
15
- };
6
+ export interface ROICachedStatsByTargetId {
7
+ [targetId: string]: ROICachedStats;
16
8
  }
9
+ export type ROICachedStats = CachedStats & {
10
+ Modality: string;
11
+ area: number | number[];
12
+ areaUnit: string;
13
+ max: number | number[];
14
+ mean: number | number[];
15
+ stdDev: number;
16
+ };
17
17
  export interface RectangleROIAnnotation extends Annotation {
18
18
  data: {
19
19
  handles: {
@@ -31,11 +31,7 @@ export interface RectangleROIAnnotation extends Annotation {
31
31
  };
32
32
  };
33
33
  label: string;
34
- cachedStats?: ROICachedStats | {
35
- pointsInVolume?: Types.Point3[];
36
- projectionPoints?: Types.Point3[];
37
- projectionPointsImageIds?: string[];
38
- };
34
+ cachedStats: ROICachedStatsByTargetId;
39
35
  };
40
36
  }
41
37
  export interface ProbeAnnotation extends Annotation {
@@ -44,7 +40,7 @@ export interface ProbeAnnotation extends Annotation {
44
40
  points: Types.Point3[];
45
41
  };
46
42
  cachedStats: {
47
- [targetId: string]: {
43
+ [targetId: string]: CachedStats & {
48
44
  Modality: string;
49
45
  index: Types.Point3;
50
46
  value: number;
@@ -77,7 +73,7 @@ export interface LengthAnnotation extends Annotation {
77
73
  };
78
74
  label: string;
79
75
  cachedStats: {
80
- [targetId: string]: {
76
+ [targetId: string]: CachedStats & {
81
77
  length: number;
82
78
  unit: string;
83
79
  };
@@ -109,13 +105,7 @@ export interface AdvancedMagnifyAnnotation extends Annotation {
109
105
  export interface CircleROIAnnotation extends Annotation {
110
106
  data: {
111
107
  handles: {
112
- points: [
113
- Types.Point3,
114
- Types.Point3,
115
- Types.Point3,
116
- Types.Point3,
117
- Types.Point3
118
- ];
108
+ points: Types.Point3[];
119
109
  activeHandleIndex: number | null;
120
110
  textBox?: {
121
111
  hasMoved: boolean;
@@ -129,16 +119,7 @@ export interface CircleROIAnnotation extends Annotation {
129
119
  };
130
120
  };
131
121
  label: string;
132
- cachedStats?: (ROICachedStats & {
133
- [targetId: string]: {
134
- radius: number;
135
- radiusUnit: string;
136
- perimeter: number;
137
- };
138
- }) | {
139
- pointsInVolume: Types.Point3[];
140
- projectionPoints: Types.Point3[][];
141
- };
122
+ cachedStats?: ROICachedStatsByTargetId;
142
123
  };
143
124
  }
144
125
  export type SplineROIAnnotation = ContourAnnotation & {
@@ -150,7 +131,7 @@ export type SplineROIAnnotation = ContourAnnotation & {
150
131
  resolution: number;
151
132
  };
152
133
  cachedStats?: {
153
- [targetId: string]: {
134
+ [targetId: string]: CachedStats & {
154
135
  Modality: string;
155
136
  area: number;
156
137
  areaUnit: string;
@@ -178,7 +159,7 @@ export interface EllipticalROIAnnotation extends Annotation {
178
159
  };
179
160
  };
180
161
  label: string;
181
- cachedStats?: ROICachedStats;
162
+ cachedStats?: ROICachedStatsByTargetId;
182
163
  initialRotation: number;
183
164
  };
184
165
  }
@@ -198,14 +179,14 @@ export interface BidirectionalAnnotation extends Annotation {
198
179
  };
199
180
  };
200
181
  };
201
- label?: string;
202
182
  cachedStats: {
203
- [targetId: string]: {
183
+ [targetId: string]: CachedStats & {
204
184
  length: number;
205
185
  width: number;
206
186
  unit: string;
207
187
  };
208
188
  };
189
+ label?: string;
209
190
  };
210
191
  }
211
192
  export interface RectangleROIThresholdAnnotation extends Annotation {
@@ -247,12 +228,7 @@ export interface RectangleROIStartEndThresholdAnnotation extends Annotation {
247
228
  label: string;
248
229
  startCoordinate: number;
249
230
  endCoordinate: number;
250
- cachedStats: {
251
- pointsInVolume: Types.Point3[];
252
- projectionPoints: Types.Point3[][];
253
- projectionPointsImageIds: string[];
254
- statistics?: ROICachedStats;
255
- };
231
+ cachedStats: VolumeStats;
256
232
  handles: {
257
233
  points: Types.Point3[];
258
234
  activeHandleIndex: number | null;
@@ -287,11 +263,8 @@ export interface CircleROIStartEndThresholdAnnotation extends Annotation {
287
263
  label: string;
288
264
  startCoordinate: number;
289
265
  endCoordinate: number;
290
- cachedStats?: {
291
- pointsInVolume: Types.Point3[];
292
- projectionPoints: Types.Point3[][];
293
- statistics?: ROICachedStats;
294
- };
266
+ cachedStats?: VolumeStats;
267
+ labelmapUID?: string;
295
268
  handles: {
296
269
  points: Types.Point3[];
297
270
  activeHandleIndex: number | null;
@@ -313,7 +286,7 @@ export type PlanarFreehandROIAnnotation = ContourAnnotation & {
313
286
  label?: string;
314
287
  isOpenUShapeContour?: boolean | 'lineSegment' | 'orthogonalT';
315
288
  openUShapeContourVectorToPeak?: Types.Point3[];
316
- cachedStats?: ROICachedStats;
289
+ cachedStats?: ROICachedStatsByTargetId;
317
290
  };
318
291
  };
319
292
  export type PlanarFreehandContourSegmentationAnnotation = PlanarFreehandROIAnnotation & ContourSegmentationAnnotationData;
@@ -519,8 +492,8 @@ export interface VideoRedactionAnnotation extends Annotation {
519
492
  points: Types.Point3[];
520
493
  activeHandleIndex: number | null;
521
494
  };
522
- cachedStats: {
523
- [key: string]: unknown;
495
+ cachedStats?: {
496
+ [targetId: string]: CachedStats;
524
497
  };
525
498
  active: boolean;
526
499
  };
@@ -42,9 +42,9 @@ import type { SplineCurveSegment } from './SplineCurveSegment.js';
42
42
  import type { SplineLineSegment } from './SplineLineSegment.js';
43
43
  import type { SplineProps } from './SplineProps.js';
44
44
  import type { BidirectionalData } from '../utilities/segmentation/createBidirectionalToolData.js';
45
- import type { IBaseTool } from './IBaseTool.js';
45
+ import type { IBaseTool, MeasurementTargetCandidate, MeasurementTargetOptions, MeasurementTargetPredicate, MeasurementTargetsFilter } from './IBaseTool.js';
46
46
  import type { RepresentationStyle } from './../stateManagement/segmentation/SegmentationStyle.js';
47
47
  import type { LogicalOperation } from '../utilities/contourSegmentation/index.js';
48
48
  import type { LabelmapStyle, LabelmapSegmentationData, LabelmapSegmentationDataStack, LabelmapSegmentationDataVolume, BaseLabelmapStyle, InactiveLabelmapStyle } from './LabelmapTypes.js';
49
49
  import type { SurfaceStyle, SurfaceSegmentationData, SurfaceStateStyles } from './SurfaceTypes.js';
50
- export type { ContourAnnotationData, ContourAnnotation, ContourSegmentationAnnotationData, ContourSegmentationAnnotation, BidirectionalData, CanvasCoordinates, IAnnotationManager, InterpolationViewportData, ImageInterpolationData, AnnotationStyle, ToolSpecificAnnotationTypes, AnnotationGroupSelector, AnnotationRenderContext, PlanarBoundingBox, ToolProps, PublicToolProps, ToolConfiguration, EventTypes, IPoints, ITouchPoints, IDistance, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, ToolAction, IToolGroup, IToolClassReference, ISynchronizerEventHandler, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationRepresentation, SegmentationState, RepresentationData, RepresentationsData, SVGCursorDescriptor, SVGPoint, CINETypes, BoundsIJK, SVGDrawingHelper, FloodFillResult, FloodFillGetter, FloodFillOptions, ContourSegmentationData, ISculptToolShape, Statistics, NamedStatistics, LabelmapToolOperationData, LabelmapToolOperationDataStack, LabelmapToolOperationDataVolume, CardinalSplineProps, ClosestControlPoint, ClosestPoint, ClosestSplinePoint, ControlPointInfo, ISpline, SplineCurveSegment, SplineLineSegment, SplineProps, IBaseTool, RepresentationStyle, Segment, SegmentationPublicInput, LabelmapStyle, ContourStyle, SurfaceStyle, SurfaceSegmentationData, SurfaceStateStyles, LabelmapSegmentationData, LabelmapSegmentationDataStack, LabelmapSegmentationDataVolume, BaseLabelmapStyle, InactiveLabelmapStyle, LogicalOperation, };
50
+ export type { ContourAnnotationData, ContourAnnotation, ContourSegmentationAnnotationData, ContourSegmentationAnnotation, BidirectionalData, CanvasCoordinates, IAnnotationManager, InterpolationViewportData, ImageInterpolationData, AnnotationStyle, ToolSpecificAnnotationTypes, AnnotationGroupSelector, AnnotationRenderContext, PlanarBoundingBox, ToolProps, PublicToolProps, ToolConfiguration, EventTypes, IPoints, ITouchPoints, IDistance, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, ToolAction, IToolGroup, IToolClassReference, ISynchronizerEventHandler, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationRepresentation, SegmentationState, RepresentationData, RepresentationsData, SVGCursorDescriptor, SVGPoint, CINETypes, BoundsIJK, SVGDrawingHelper, FloodFillResult, FloodFillGetter, FloodFillOptions, ContourSegmentationData, ISculptToolShape, Statistics, NamedStatistics, LabelmapToolOperationData, LabelmapToolOperationDataStack, LabelmapToolOperationDataVolume, CardinalSplineProps, ClosestControlPoint, ClosestPoint, ClosestSplinePoint, ControlPointInfo, ISpline, SplineCurveSegment, SplineLineSegment, SplineProps, IBaseTool, MeasurementTargetCandidate, MeasurementTargetOptions, MeasurementTargetPredicate, MeasurementTargetsFilter, RepresentationStyle, Segment, SegmentationPublicInput, LabelmapStyle, ContourStyle, SurfaceStyle, SurfaceSegmentationData, SurfaceStateStyles, LabelmapSegmentationData, LabelmapSegmentationDataStack, LabelmapSegmentationDataVolume, BaseLabelmapStyle, InactiveLabelmapStyle, LogicalOperation, };
@@ -0,0 +1,9 @@
1
+ export interface MetricDefinition {
2
+ name: string;
3
+ attribute: string;
4
+ unitAttribute: string;
5
+ }
6
+ export declare const AREA_METRICS: MetricDefinition[];
7
+ export declare function createGetTextLines(metrics: MetricDefinition[]): (data: any, targetId: string | string[]) => string[];
8
+ export declare const defaultAreaGetTextLines: (data: any, targetId: string | string[]) => string[];
9
+ export declare function createMultiResultLine(cachedVolumeStats: any, targetIds: string[], name: string, attribute: string, unitAttribute: string): string;
@@ -0,0 +1,53 @@
1
+ import { utilities as csUtils } from '@cornerstonejs/core';
2
+ const { isEqual } = csUtils;
3
+ export const AREA_METRICS = [
4
+ { name: 'Area', attribute: 'area', unitAttribute: 'areaUnit' },
5
+ { name: 'Mean', attribute: 'mean', unitAttribute: 'modalityUnit' },
6
+ { name: 'Max', attribute: 'max', unitAttribute: 'modalityUnit' },
7
+ { name: 'Min', attribute: 'min', unitAttribute: 'modalityUnit' },
8
+ { name: 'Std Dev', attribute: 'stdDev', unitAttribute: 'modalityUnit' },
9
+ ];
10
+ export function createGetTextLines(metrics) {
11
+ return function (data, targetId) {
12
+ const targetIds = Array.isArray(targetId) ? targetId : [targetId];
13
+ const cachedVolumeStats = targetIds
14
+ .map((id) => data.cachedStats[id])
15
+ .filter((stats) => metrics.some(({ attribute }) => stats?.[attribute] !== undefined && stats?.[attribute] !== null));
16
+ if (!cachedVolumeStats.length) {
17
+ return;
18
+ }
19
+ const textLines = [];
20
+ for (const metric of metrics) {
21
+ pushResult(textLines, createMultiResultLine(cachedVolumeStats, targetIds, metric.name, metric.attribute, metric.unitAttribute));
22
+ }
23
+ return textLines;
24
+ };
25
+ }
26
+ export const defaultAreaGetTextLines = createGetTextLines(AREA_METRICS);
27
+ function pushResult(textLines, value) {
28
+ if (value) {
29
+ textLines.push(value);
30
+ }
31
+ }
32
+ export function createMultiResultLine(cachedVolumeStats, targetIds, name, attribute, unitAttribute) {
33
+ const result = [`${name}:`];
34
+ let lastValue = null;
35
+ let lastUnit = null;
36
+ for (const stats of cachedVolumeStats) {
37
+ if (!csUtils.isNumber(stats?.[attribute])) {
38
+ continue;
39
+ }
40
+ const attributeValue = stats[attribute];
41
+ const unitValue = stats[unitAttribute];
42
+ if (isEqual(lastValue, attributeValue) && lastUnit === unitValue) {
43
+ continue;
44
+ }
45
+ result.push(`${csUtils.roundNumber(attributeValue)} ${unitValue}`);
46
+ lastValue = attributeValue;
47
+ lastUnit = unitValue;
48
+ }
49
+ if (result.length <= 1) {
50
+ return;
51
+ }
52
+ return result.join(' ');
53
+ }
@@ -1,2 +1,2 @@
1
- import type { VolumeViewport, Types } from '@cornerstonejs/core';
2
- export default function getEllipseWorldCoordinates(points: [Types.Point3, Types.Point3], viewport: Types.IStackViewport | VolumeViewport): Types.Point3[];
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export default function getEllipseWorldCoordinates(points: [Types.Point3, Types.Point3], viewport: Types.IViewport): Types.Point3[];
@@ -1,7 +1,7 @@
1
1
  import { vec3 } from 'gl-matrix';
2
+ import getViewportICamera from './getViewportICamera.js';
2
3
  export default function getEllipseWorldCoordinates(points, viewport) {
3
- const camera = viewport.getCamera();
4
- const { viewUp, viewPlaneNormal } = camera;
4
+ const { viewUp, viewPlaneNormal } = getViewportICamera(viewport);
5
5
  const viewRight = vec3.create();
6
6
  vec3.cross(viewRight, viewUp, viewPlaneNormal);
7
7
  const [centerWorld, endWorld] = points;
@@ -46,4 +46,5 @@ import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume.js';
46
46
  import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction.js';
47
47
  import { jumpToFocalPoint } from './genericViewportToolHelpers.js';
48
48
  import pickIntensityPointInSlab, { getSlabIntensityPickContext } from './pickIntensityPointInSlab.js';
49
+ export * from './defaultGetTextLines.js';
49
50
  export { math, planar, spatial, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, draw3D, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, jumpToFocalPoint, pickIntensityPointInSlab, getSlabIntensityPickContext, };
@@ -46,4 +46,5 @@ import getOrCreateImageVolume from './segmentation/getOrCreateImageVolume.js';
46
46
  import * as usFanExtraction from '../tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction.js';
47
47
  import { jumpToFocalPoint } from './genericViewportToolHelpers.js';
48
48
  import pickIntensityPointInSlab, { getSlabIntensityPickContext, } from './pickIntensityPointInSlab.js';
49
+ export * from './defaultGetTextLines.js';
49
50
  export { math, planar, spatial, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnitsAndScale, getCalibratedProbeUnitsAndValue, getCalibratedAspect, getPixelValueUnits, getPixelValueUnitsImageId, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRenderForToolGroupIds, triggerAnnotationRender, getSphereBoundsInfo, getAnnotationNearPoint, getViewportForAnnotation, getAnnotationNearPointOnEnabledElement, viewport, cine, boundingBox, draw3D, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, roundNumber, pointToString, polyDataUtils, voi, AnnotationMultiSlice, contourSegmentation, annotationHydration, getClosestImageIdForStackViewport, pointInSurroundingSphereCallback, normalizeViewportPlane, IslandRemoval, geometricSurfaceUtils, usFanExtraction, setAnnotationLabel, moveAnnotationToViewPlane, safeStructuredClone, getOrCreateImageVolume, jumpToFocalPoint, pickIntensityPointInSlab, getSlabIntensityPickContext, };
@@ -49,7 +49,7 @@ export default function filterAnnotationsWithinSlice(annotations, camera, spacin
49
49
  if (!annotationsWithParallelNormals.length) {
50
50
  return [];
51
51
  }
52
- const halfSpacingInNormalDirection = spacingInNormalDirection / 2;
52
+ const halfSpacingInNormalDirection = spacingInNormalDirection / 2 + EPSILON;
53
53
  const { focalPoint } = camera;
54
54
  const annotationsWithinSlice = [];
55
55
  for (const annotation of annotationsWithParallelNormals) {
@@ -1 +1 @@
1
- export declare const version = "5.5.1";
1
+ export declare const version = "5.6.0";
@@ -1 +1 @@
1
- export const version = '5.5.1';
1
+ export const version = '5.6.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "5.5.1",
3
+ "version": "5.6.0",
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.5.1",
129
+ "@cornerstonejs/core": "5.6.0",
130
130
  "canvas": "3.2.0"
131
131
  },
132
132
  "peerDependencies": {
133
- "@cornerstonejs/core": "5.5.1",
133
+ "@cornerstonejs/core": "5.6.0",
134
134
  "@kitware/vtk.js": "35.5.3",
135
135
  "@types/d3-array": "3.2.1",
136
136
  "@types/d3-interpolate": "3.0.4",
@@ -149,5 +149,5 @@
149
149
  "type": "individual",
150
150
  "url": "https://ohif.org/donate"
151
151
  },
152
- "gitHead": "af9742045c8c7ab454f5edbdc46b0a9fdc493b8f"
152
+ "gitHead": "bca909b8af25305cc850f52b43d5834b55fcf011"
153
153
  }