@cornerstonejs/tools 2.2.19 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/enums/StrategyCallbacks.d.ts +2 -1
- package/dist/esm/enums/StrategyCallbacks.js +1 -0
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationDataModified.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationDataModified.js +2 -1
- package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.d.ts +1 -0
- package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.js +4 -1
- package/dist/esm/tools/annotation/CircleROITool.d.ts +3 -0
- package/dist/esm/tools/annotation/CircleROITool.js +47 -1
- package/dist/esm/tools/annotation/LengthTool.d.ts +3 -0
- package/dist/esm/tools/annotation/LengthTool.js +35 -2
- package/dist/esm/tools/annotation/ProbeTool.d.ts +3 -0
- package/dist/esm/tools/annotation/ProbeTool.js +34 -1
- package/dist/esm/tools/annotation/RectangleROITool.d.ts +3 -0
- package/dist/esm/tools/annotation/RectangleROITool.js +37 -1
- package/dist/esm/tools/annotation/SplineROITool.d.ts +4 -0
- package/dist/esm/tools/annotation/SplineROITool.js +57 -4
- package/dist/esm/tools/base/BaseTool.d.ts +1 -1
- package/dist/esm/tools/base/BaseTool.js +2 -2
- package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +2 -2
- package/dist/esm/tools/segmentation/BrushTool.d.ts +1 -0
- package/dist/esm/tools/segmentation/BrushTool.js +11 -10
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +6 -0
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +6 -4
- package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +1 -1
- package/dist/esm/tools/segmentation/strategies/compositions/index.d.ts +5 -0
- package/dist/esm/tools/segmentation/strategies/compositions/index.js +2 -0
- package/dist/esm/tools/segmentation/strategies/compositions/islandRemoval.js +1 -1
- package/dist/esm/tools/segmentation/strategies/compositions/labelmapStatistics.d.ts +7 -0
- package/dist/esm/tools/segmentation/strategies/compositions/labelmapStatistics.js +32 -0
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
- package/dist/esm/tools/segmentation/strategies/fillCircle.js +2 -2
- package/dist/esm/tools/segmentation/strategies/fillSphere.d.ts +2 -1
- package/dist/esm/tools/segmentation/strategies/fillSphere.js +4 -2
- package/dist/esm/types/EventTypes.d.ts +1 -0
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +3 -1
- package/dist/esm/utilities/segmentation/VolumetricCalculator.d.ts +8 -0
- package/dist/esm/utilities/segmentation/VolumetricCalculator.js +18 -0
- package/dist/esm/utilities/segmentation/index.d.ts +2 -1
- package/dist/esm/utilities/segmentation/index.js +2 -1
- package/package.json +3 -3
|
@@ -9,6 +9,7 @@ declare enum StrategyCallbacks {
|
|
|
9
9
|
CreateIsInThreshold = "createIsInThreshold",
|
|
10
10
|
Initialize = "initialize",
|
|
11
11
|
INTERNAL_setValue = "setValue",
|
|
12
|
-
ComputeInnerCircleRadius = "computeInnerCircleRadius"
|
|
12
|
+
ComputeInnerCircleRadius = "computeInnerCircleRadius",
|
|
13
|
+
GetStatistics = "getStatistics"
|
|
13
14
|
}
|
|
14
15
|
export default StrategyCallbacks;
|
|
@@ -11,5 +11,6 @@ var StrategyCallbacks;
|
|
|
11
11
|
StrategyCallbacks["Initialize"] = "initialize";
|
|
12
12
|
StrategyCallbacks["INTERNAL_setValue"] = "setValue";
|
|
13
13
|
StrategyCallbacks["ComputeInnerCircleRadius"] = "computeInnerCircleRadius";
|
|
14
|
+
StrategyCallbacks["GetStatistics"] = "getStatistics";
|
|
14
15
|
})(StrategyCallbacks || (StrategyCallbacks = {}));
|
|
15
16
|
export default StrategyCallbacks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function triggerSegmentationDataModified(segmentationId: string, modifiedSlicesToUse?: number[]): void;
|
|
1
|
+
export declare function triggerSegmentationDataModified(segmentationId: string, modifiedSlicesToUse?: number[], segmentIndex?: number): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { triggerEvent, eventTarget } from '@cornerstonejs/core';
|
|
2
2
|
import { Events } from '../../../enums';
|
|
3
3
|
import { setSegmentationDirty } from '../../../utilities/segmentation/utilities';
|
|
4
|
-
export function triggerSegmentationDataModified(segmentationId, modifiedSlicesToUse) {
|
|
4
|
+
export function triggerSegmentationDataModified(segmentationId, modifiedSlicesToUse, segmentIndex) {
|
|
5
5
|
const eventDetail = {
|
|
6
6
|
segmentationId,
|
|
7
7
|
modifiedSlicesToUse,
|
|
8
|
+
segmentIndex,
|
|
8
9
|
};
|
|
9
10
|
setSegmentationDirty(segmentationId);
|
|
10
11
|
triggerEvent(eventTarget, Events.SEGMENTATION_DATA_MODIFIED, eventDetail);
|
|
@@ -2,3 +2,4 @@ export declare function getLabelmapActorUID(viewportId: string, segmentationId:
|
|
|
2
2
|
export declare function getLabelmapActorEntry(viewportId: string, segmentationId: string): import("packages/core/dist/esm/types").ActorEntry;
|
|
3
3
|
export declare function getSurfaceActorEntry(viewportId: string, segmentationId: string, segmentIndex?: number | string): import("packages/core/dist/esm/types").ActorEntry;
|
|
4
4
|
export declare function getSurfaceActorUID(viewportId: string, segmentationId: string, segmentIndex?: number | string): string | undefined;
|
|
5
|
+
export declare function getSurfaceRepresentationUID(segmentationId: string, segmentIndex?: number | string): string;
|
|
@@ -21,10 +21,13 @@ export function getLabelmapActorEntry(viewportId, segmentationId) {
|
|
|
21
21
|
return getActorEntry(viewportId, segmentationId, (actor) => actor.representationUID?.startsWith(`${segmentationId}-${SegmentationRepresentations.Labelmap}`));
|
|
22
22
|
}
|
|
23
23
|
export function getSurfaceActorEntry(viewportId, segmentationId, segmentIndex) {
|
|
24
|
-
return getActorEntry(viewportId, segmentationId, (actor) => actor.representationUID?.startsWith(
|
|
24
|
+
return getActorEntry(viewportId, segmentationId, (actor) => actor.representationUID?.startsWith(getSurfaceRepresentationUID(segmentationId, segmentIndex)));
|
|
25
25
|
}
|
|
26
26
|
export function getSurfaceActorUID(viewportId, segmentationId, segmentIndex) {
|
|
27
27
|
const segIndex = segmentIndex ? segmentIndex.toString() : '';
|
|
28
28
|
const actorEntry = getSurfaceActorEntry(viewportId, segmentationId, segIndex);
|
|
29
29
|
return actorEntry?.uid;
|
|
30
30
|
}
|
|
31
|
+
export function getSurfaceRepresentationUID(segmentationId, segmentIndex) {
|
|
32
|
+
return `${segmentationId}-${SegmentationRepresentations.Surface}-${segmentIndex}`;
|
|
33
|
+
}
|
|
@@ -32,5 +32,8 @@ declare class CircleROITool extends AnnotationTool {
|
|
|
32
32
|
renderAnnotation: (enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper) => boolean;
|
|
33
33
|
_calculateCachedStats: (annotation: any, viewport: any, renderingEngine: any, enabledElement: any) => any;
|
|
34
34
|
_isInsideVolume: (index1: any, index2: any, dimensions: any) => boolean;
|
|
35
|
+
static hydrate: (viewportId: string, points: Types.Point3[], options?: {
|
|
36
|
+
annotationUID?: string;
|
|
37
|
+
}) => CircleROIAnnotation;
|
|
35
38
|
}
|
|
36
39
|
export default CircleROITool;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnnotationTool } from '../base';
|
|
2
|
-
import { getEnabledElement, VolumeViewport, utilities as csUtils, } from '@cornerstonejs/core';
|
|
2
|
+
import { getEnabledElement, VolumeViewport, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
3
3
|
import { getCalibratedAspect, getCalibratedLengthUnitsAndScale, } from '../../utilities/getCalibratedUnits';
|
|
4
4
|
import throttle from '../../utilities/throttle';
|
|
5
5
|
import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
|
|
@@ -557,6 +557,52 @@ class CircleROITool extends AnnotationTool {
|
|
|
557
557
|
};
|
|
558
558
|
this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
|
|
559
559
|
}
|
|
560
|
+
static { this.hydrate = (viewportId, points, options) => {
|
|
561
|
+
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
562
|
+
if (!enabledElement) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const { viewport } = enabledElement;
|
|
566
|
+
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
567
|
+
const { viewPlaneNormal, viewUp } = viewport.getCamera();
|
|
568
|
+
const instance = new this();
|
|
569
|
+
const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
|
|
570
|
+
const annotation = {
|
|
571
|
+
annotationUID: options?.annotationUID || csUtils.uuidv4(),
|
|
572
|
+
data: {
|
|
573
|
+
handles: {
|
|
574
|
+
points,
|
|
575
|
+
textBox: {
|
|
576
|
+
hasMoved: false,
|
|
577
|
+
worldPosition: [0, 0, 0],
|
|
578
|
+
worldBoundingBox: {
|
|
579
|
+
topLeft: [0, 0, 0],
|
|
580
|
+
topRight: [0, 0, 0],
|
|
581
|
+
bottomLeft: [0, 0, 0],
|
|
582
|
+
bottomRight: [0, 0, 0],
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
activeHandleIndex: null,
|
|
586
|
+
},
|
|
587
|
+
label: '',
|
|
588
|
+
cachedStats: {},
|
|
589
|
+
},
|
|
590
|
+
highlighted: false,
|
|
591
|
+
autoGenerated: false,
|
|
592
|
+
invalidated: false,
|
|
593
|
+
isLocked: false,
|
|
594
|
+
isVisible: true,
|
|
595
|
+
metadata: {
|
|
596
|
+
toolName: instance.getToolName(),
|
|
597
|
+
viewPlaneNormal,
|
|
598
|
+
FrameOfReferenceUID,
|
|
599
|
+
referencedImageId,
|
|
600
|
+
...options,
|
|
601
|
+
},
|
|
602
|
+
};
|
|
603
|
+
addAnnotation(annotation, viewport.element);
|
|
604
|
+
triggerAnnotationRenderForViewportIds([viewport.id]);
|
|
605
|
+
}; }
|
|
560
606
|
}
|
|
561
607
|
function defaultGetTextLines(data, targetId) {
|
|
562
608
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
@@ -16,6 +16,9 @@ declare class LengthTool extends AnnotationTool {
|
|
|
16
16
|
isDrawing: boolean;
|
|
17
17
|
isHandleOutsideImage: boolean;
|
|
18
18
|
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
19
|
+
static hydrate: (viewportId: string, points: Types.Point3[], options?: {
|
|
20
|
+
annotationUID?: string;
|
|
21
|
+
}) => LengthAnnotation;
|
|
19
22
|
addNewAnnotation: (evt: EventTypes.InteractionEventType) => LengthAnnotation;
|
|
20
23
|
isPointNearTool: (element: HTMLDivElement, annotation: LengthAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
|
|
21
24
|
toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: LengthAnnotation) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Events } from '../../enums';
|
|
2
|
-
import { getEnabledElement, utilities as csUtils } from '@cornerstonejs/core';
|
|
2
|
+
import { getEnabledElement, utilities as csUtils, utilities, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
3
3
|
import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
|
|
4
4
|
import { AnnotationTool } from '../base';
|
|
5
5
|
import throttle from '../../utilities/throttle';
|
|
@@ -29,7 +29,7 @@ class LengthTool extends AnnotationTool {
|
|
|
29
29
|
const { currentPoints, element } = eventDetail;
|
|
30
30
|
const worldPos = currentPoints.world;
|
|
31
31
|
const enabledElement = getEnabledElement(element);
|
|
32
|
-
const { viewport
|
|
32
|
+
const { viewport } = enabledElement;
|
|
33
33
|
hideElementCursor(element);
|
|
34
34
|
this.isDrawing = true;
|
|
35
35
|
const { viewPlaneNormal, viewUp, position: cameraPosition, } = viewport.getCamera();
|
|
@@ -344,6 +344,39 @@ class LengthTool extends AnnotationTool {
|
|
|
344
344
|
};
|
|
345
345
|
this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
|
|
346
346
|
}
|
|
347
|
+
static { this.hydrate = (viewportId, points, options) => {
|
|
348
|
+
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
349
|
+
if (!enabledElement) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const { viewport } = enabledElement;
|
|
353
|
+
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
354
|
+
const { viewPlaneNormal, viewUp } = viewport.getCamera();
|
|
355
|
+
const instance = new this();
|
|
356
|
+
const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
|
|
357
|
+
const annotation = {
|
|
358
|
+
annotationUID: options?.annotationUID || utilities.uuidv4(),
|
|
359
|
+
data: {
|
|
360
|
+
handles: {
|
|
361
|
+
points,
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
highlighted: false,
|
|
365
|
+
autoGenerated: false,
|
|
366
|
+
invalidated: false,
|
|
367
|
+
isLocked: false,
|
|
368
|
+
isVisible: true,
|
|
369
|
+
metadata: {
|
|
370
|
+
toolName: instance.getToolName(),
|
|
371
|
+
viewPlaneNormal,
|
|
372
|
+
FrameOfReferenceUID,
|
|
373
|
+
referencedImageId,
|
|
374
|
+
...options,
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
addAnnotation(annotation, viewport.element);
|
|
378
|
+
triggerAnnotationRenderForViewportIds([viewport.id]);
|
|
379
|
+
}; }
|
|
347
380
|
handleSelectedCallback(evt, annotation, handle) {
|
|
348
381
|
const eventDetail = evt.detail;
|
|
349
382
|
const { element } = eventDetail;
|
|
@@ -18,6 +18,9 @@ declare class ProbeTool extends AnnotationTool {
|
|
|
18
18
|
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
19
19
|
isPointNearTool(): boolean;
|
|
20
20
|
toolSelectedCallback(): void;
|
|
21
|
+
static hydrate: (viewportId: string, points: Types.Point3[], options?: {
|
|
22
|
+
annotationUID?: string;
|
|
23
|
+
}) => ProbeAnnotation;
|
|
21
24
|
addNewAnnotation: (evt: EventTypes.InteractionEventType) => ProbeAnnotation;
|
|
22
25
|
getHandleNearImagePoint(element: HTMLDivElement, annotation: ProbeAnnotation, canvasCoords: Types.Point2, proximity: number): ToolHandle | undefined;
|
|
23
26
|
handleSelectedCallback(evt: EventTypes.InteractionEventType, annotation: ProbeAnnotation): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { vec2, vec3 } from 'gl-matrix';
|
|
2
|
-
import { getEnabledElement, VolumeViewport, utilities as csUtils, } from '@cornerstonejs/core';
|
|
2
|
+
import { getEnabledElement, VolumeViewport, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
3
3
|
import { AnnotationTool } from '../base';
|
|
4
4
|
import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
|
|
5
5
|
import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../stateManagement/annotation/helpers/state';
|
|
@@ -220,6 +220,39 @@ class ProbeTool extends AnnotationTool {
|
|
|
220
220
|
return false;
|
|
221
221
|
}
|
|
222
222
|
toolSelectedCallback() { }
|
|
223
|
+
static { this.hydrate = (viewportId, points, options) => {
|
|
224
|
+
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
225
|
+
if (!enabledElement) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const { viewport } = enabledElement;
|
|
229
|
+
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
230
|
+
const { viewPlaneNormal, viewUp } = viewport.getCamera();
|
|
231
|
+
const instance = new this();
|
|
232
|
+
const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
|
|
233
|
+
const annotation = {
|
|
234
|
+
annotationUID: options?.annotationUID || csUtils.uuidv4(),
|
|
235
|
+
data: {
|
|
236
|
+
handles: {
|
|
237
|
+
points,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
highlighted: false,
|
|
241
|
+
autoGenerated: false,
|
|
242
|
+
invalidated: false,
|
|
243
|
+
isLocked: false,
|
|
244
|
+
isVisible: true,
|
|
245
|
+
metadata: {
|
|
246
|
+
toolName: instance.getToolName(),
|
|
247
|
+
viewPlaneNormal,
|
|
248
|
+
FrameOfReferenceUID,
|
|
249
|
+
referencedImageId,
|
|
250
|
+
...options,
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
addAnnotation(annotation, viewport.element);
|
|
254
|
+
triggerAnnotationRenderForViewportIds([viewport.id]);
|
|
255
|
+
}; }
|
|
223
256
|
getHandleNearImagePoint(element, annotation, canvasCoords, proximity) {
|
|
224
257
|
const enabledElement = getEnabledElement(element);
|
|
225
258
|
const { viewport } = enabledElement;
|
|
@@ -36,5 +36,8 @@ declare class RectangleROITool extends AnnotationTool {
|
|
|
36
36
|
};
|
|
37
37
|
_calculateCachedStats: (annotation: any, viewPlaneNormal: any, viewUp: any, renderingEngine: any, enabledElement: any) => any;
|
|
38
38
|
_isInsideVolume: (index1: any, index2: any, dimensions: any) => boolean;
|
|
39
|
+
static hydrate: (viewportId: string, points: Types.Point3[], options?: {
|
|
40
|
+
annotationUID?: string;
|
|
41
|
+
}) => RectangleROIAnnotation;
|
|
39
42
|
}
|
|
40
43
|
export default RectangleROITool;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnnotationTool } from '../base';
|
|
2
|
-
import { getEnabledElement, VolumeViewport, utilities as csUtils, } from '@cornerstonejs/core';
|
|
2
|
+
import { getEnabledElement, VolumeViewport, utilities as csUtils, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
3
3
|
import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
|
|
4
4
|
import throttle from '../../utilities/throttle';
|
|
5
5
|
import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement';
|
|
@@ -529,6 +529,42 @@ class RectangleROITool extends AnnotationTool {
|
|
|
529
529
|
};
|
|
530
530
|
this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
|
|
531
531
|
}
|
|
532
|
+
static { this.hydrate = (viewportId, points, options) => {
|
|
533
|
+
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
534
|
+
if (!enabledElement) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const { viewport } = enabledElement;
|
|
538
|
+
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
539
|
+
const { viewPlaneNormal, viewUp } = viewport.getCamera();
|
|
540
|
+
const instance = new this();
|
|
541
|
+
const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
|
|
542
|
+
const annotation = {
|
|
543
|
+
annotationUID: options?.annotationUID || csUtils.uuidv4(),
|
|
544
|
+
data: {
|
|
545
|
+
handles: {
|
|
546
|
+
points,
|
|
547
|
+
activeHandleIndex: null,
|
|
548
|
+
},
|
|
549
|
+
label: '',
|
|
550
|
+
cachedStats: {},
|
|
551
|
+
},
|
|
552
|
+
highlighted: false,
|
|
553
|
+
autoGenerated: false,
|
|
554
|
+
invalidated: false,
|
|
555
|
+
isLocked: false,
|
|
556
|
+
isVisible: true,
|
|
557
|
+
metadata: {
|
|
558
|
+
toolName: instance.getToolName(),
|
|
559
|
+
viewPlaneNormal,
|
|
560
|
+
FrameOfReferenceUID,
|
|
561
|
+
referencedImageId,
|
|
562
|
+
...options,
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
addAnnotation(annotation, viewport.element);
|
|
566
|
+
triggerAnnotationRenderForViewportIds([viewport.id]);
|
|
567
|
+
}; }
|
|
532
568
|
}
|
|
533
569
|
function defaultGetTextLines(data, targetId) {
|
|
534
570
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
@@ -65,5 +65,9 @@ declare class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
65
65
|
private _getSplineConfig;
|
|
66
66
|
private _updateSplineInstance;
|
|
67
67
|
private _calculateCachedStats;
|
|
68
|
+
static hydrate: (viewportId: string, points: Types.Point3[], options?: {
|
|
69
|
+
annotationUID?: string;
|
|
70
|
+
splineType?: SplineTypesEnum;
|
|
71
|
+
}) => SplineROIAnnotation;
|
|
68
72
|
}
|
|
69
73
|
export default SplineROITool;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getEnabledElement, eventTarget, triggerEvent, utilities, } from '@cornerstonejs/core';
|
|
1
|
+
import { getEnabledElement, eventTarget, triggerEvent, utilities, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
2
2
|
import { vec3 } from 'gl-matrix';
|
|
3
|
-
import { getChildAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
|
|
3
|
+
import { addAnnotation, getChildAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
|
|
4
4
|
import { drawHandles as drawHandlesSvg, drawPolyline as drawPolylineSvg, drawLinkedTextBox as drawLinkedTextBoxSvg, } from '../../drawingSvg';
|
|
5
5
|
import { state } from '../../store/state';
|
|
6
6
|
import { Events, MouseBindings, KeyboardBindings, ChangeTypes, } from '../../enums';
|
|
@@ -116,8 +116,6 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
116
116
|
viewportIdsToRender,
|
|
117
117
|
movingTextBox: false,
|
|
118
118
|
};
|
|
119
|
-
const enabledElement = getEnabledElement(element);
|
|
120
|
-
const { renderingEngine } = enabledElement;
|
|
121
119
|
this._activateModify(element);
|
|
122
120
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
123
121
|
evt.preventDefault();
|
|
@@ -711,6 +709,61 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
711
709
|
}
|
|
712
710
|
return spline;
|
|
713
711
|
}
|
|
712
|
+
static { this.hydrate = (viewportId, points, options) => {
|
|
713
|
+
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
714
|
+
if (!enabledElement) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
if (points.length < SPLINE_MIN_POINTS) {
|
|
718
|
+
console.warn('Spline requires at least 3 control points');
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
const { viewport } = enabledElement;
|
|
722
|
+
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
723
|
+
const { viewPlaneNormal, viewUp } = viewport.getCamera();
|
|
724
|
+
const instance = new this();
|
|
725
|
+
const referencedImageId = instance.getReferencedImageId(viewport, points[0], viewPlaneNormal, viewUp);
|
|
726
|
+
const splineType = options?.splineType || SplineTypesEnum.CatmullRom;
|
|
727
|
+
const splineConfig = instance._getSplineConfig(splineType);
|
|
728
|
+
const SplineClass = splineConfig.Class;
|
|
729
|
+
const splineInstance = new SplineClass();
|
|
730
|
+
const canvasPoints = points.map((point) => viewport.worldToCanvas(point));
|
|
731
|
+
splineInstance.setControlPoints(canvasPoints);
|
|
732
|
+
const splinePolylineCanvas = splineInstance.getPolylinePoints();
|
|
733
|
+
const splinePolylineWorld = splinePolylineCanvas.map((point) => viewport.canvasToWorld(point));
|
|
734
|
+
const annotation = {
|
|
735
|
+
annotationUID: options?.annotationUID || utilities.uuidv4(),
|
|
736
|
+
data: {
|
|
737
|
+
handles: {
|
|
738
|
+
points,
|
|
739
|
+
},
|
|
740
|
+
label: '',
|
|
741
|
+
cachedStats: {},
|
|
742
|
+
spline: {
|
|
743
|
+
type: splineType,
|
|
744
|
+
instance: splineInstance,
|
|
745
|
+
},
|
|
746
|
+
contour: {
|
|
747
|
+
closed: true,
|
|
748
|
+
polyline: splinePolylineWorld,
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
highlighted: false,
|
|
752
|
+
autoGenerated: false,
|
|
753
|
+
invalidated: true,
|
|
754
|
+
isLocked: false,
|
|
755
|
+
isVisible: true,
|
|
756
|
+
metadata: {
|
|
757
|
+
toolName: instance.getToolName(),
|
|
758
|
+
viewPlaneNormal,
|
|
759
|
+
FrameOfReferenceUID,
|
|
760
|
+
referencedImageId,
|
|
761
|
+
...options,
|
|
762
|
+
},
|
|
763
|
+
};
|
|
764
|
+
addAnnotation(annotation, viewport.element);
|
|
765
|
+
triggerAnnotationRenderForViewportIds([viewport.id]);
|
|
766
|
+
}; }
|
|
714
767
|
}
|
|
715
768
|
function defaultGetTextLines(data, targetId) {
|
|
716
769
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
@@ -11,7 +11,7 @@ declare abstract class BaseTool {
|
|
|
11
11
|
constructor(toolProps: PublicToolProps, defaultToolProps: ToolProps);
|
|
12
12
|
getToolName(): string;
|
|
13
13
|
applyActiveStrategy(enabledElement: Types.IEnabledElement, operationData: unknown): any;
|
|
14
|
-
applyActiveStrategyCallback(enabledElement: Types.IEnabledElement, operationData: unknown, callbackType: StrategyCallbacks | string): any;
|
|
14
|
+
applyActiveStrategyCallback(enabledElement: Types.IEnabledElement, operationData: unknown, callbackType: StrategyCallbacks | string, ...extraArgs: any[]): any;
|
|
15
15
|
setConfiguration(newConfiguration: Record<string, any>): void;
|
|
16
16
|
setActiveStrategy(strategyName: string): void;
|
|
17
17
|
protected getTargetImageData(targetId: string): Types.IImageData | Types.CPUIImageData;
|
|
@@ -22,12 +22,12 @@ class BaseTool {
|
|
|
22
22
|
const { strategies, activeStrategy } = this.configuration;
|
|
23
23
|
return strategies[activeStrategy]?.call(this, enabledElement, operationData);
|
|
24
24
|
}
|
|
25
|
-
applyActiveStrategyCallback(enabledElement, operationData, callbackType) {
|
|
25
|
+
applyActiveStrategyCallback(enabledElement, operationData, callbackType, ...extraArgs) {
|
|
26
26
|
const { strategies, activeStrategy } = this.configuration;
|
|
27
27
|
if (!strategies[activeStrategy]) {
|
|
28
28
|
throw new Error(`applyActiveStrategyCallback: active strategy ${activeStrategy} not found, check tool configuration or spellings`);
|
|
29
29
|
}
|
|
30
|
-
return strategies[activeStrategy][callbackType]?.call(this, enabledElement, operationData);
|
|
30
|
+
return strategies[activeStrategy][callbackType]?.call(this, enabledElement, operationData, ...extraArgs);
|
|
31
31
|
}
|
|
32
32
|
setConfiguration(newConfiguration) {
|
|
33
33
|
this.configuration = utilities.deepMerge(this.configuration, newConfiguration);
|
|
@@ -4,11 +4,10 @@ import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
|
|
|
4
4
|
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
|
|
5
5
|
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
|
|
6
6
|
import vtkCellArray from '@kitware/vtk.js/Common/Core/CellArray';
|
|
7
|
-
import { getSurfaceActorEntry,
|
|
7
|
+
import { getSurfaceActorEntry, getSurfaceRepresentationUID, } from '../../../stateManagement/segmentation/helpers/getSegmentationActor';
|
|
8
8
|
function addOrUpdateSurfaceToElement(element, surface, segmentationId) {
|
|
9
9
|
const enabledElement = getEnabledElement(element);
|
|
10
10
|
const { viewport } = enabledElement;
|
|
11
|
-
const representationUID = getSurfaceActorUID(viewport.id, segmentationId, surface.segmentIndex);
|
|
12
11
|
const surfaceActorEntry = getSurfaceActorEntry(viewport.id, segmentationId, surface.segmentIndex);
|
|
13
12
|
const surfaceActor = surfaceActorEntry?.actor;
|
|
14
13
|
if (surfaceActor) {
|
|
@@ -49,6 +48,7 @@ function addOrUpdateSurfaceToElement(element, surface, segmentationId) {
|
|
|
49
48
|
actor.setMapper(mapper);
|
|
50
49
|
actor.getProperty().setColor(color[0] / 255, color[1] / 255, color[2] / 255);
|
|
51
50
|
actor.getProperty().setLineWidth(2);
|
|
51
|
+
const representationUID = getSurfaceRepresentationUID(segmentationId, surface.segmentIndex);
|
|
52
52
|
viewport.addActor({
|
|
53
53
|
uid: utilities.uuidv4(),
|
|
54
54
|
actor: actor,
|
|
@@ -119,6 +119,7 @@ declare class BrushTool extends BaseTool {
|
|
|
119
119
|
};
|
|
120
120
|
private _calculateCursor;
|
|
121
121
|
private _endCallback;
|
|
122
|
+
getStatistics(element: any, segmentIndices?: any): any;
|
|
122
123
|
rejectPreview(element?: HTMLDivElement): void;
|
|
123
124
|
acceptPreview(element?: HTMLDivElement): void;
|
|
124
125
|
private _activateDraw;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { utilities as csUtils, cache, getEnabledElement, StackViewport, eventTarget, Enums, BaseVolumeViewport, volumeLoader, } from '@cornerstonejs/core';
|
|
2
2
|
import { vec3, vec2 } from 'gl-matrix';
|
|
3
3
|
import { BaseTool } from '../base';
|
|
4
|
-
import { fillInsideSphere, thresholdInsideSphere, } from './strategies/fillSphere';
|
|
4
|
+
import { fillInsideSphere, thresholdInsideSphere, thresholdInsideSphereIsland, } from './strategies/fillSphere';
|
|
5
5
|
import { eraseInsideSphere } from './strategies/eraseSphere';
|
|
6
6
|
import { thresholdInsideCircle, fillInsideCircle, } from './strategies/fillCircle';
|
|
7
7
|
import { eraseInsideCircle } from './strategies/eraseCircle';
|
|
@@ -25,6 +25,7 @@ class BrushTool extends BaseTool {
|
|
|
25
25
|
ERASE_INSIDE_SPHERE: eraseInsideSphere,
|
|
26
26
|
THRESHOLD_INSIDE_CIRCLE: thresholdInsideCircle,
|
|
27
27
|
THRESHOLD_INSIDE_SPHERE: thresholdInsideSphere,
|
|
28
|
+
THRESHOLD_INSIDE_SPHERE_WITH_ISLAND_REMOVAL: thresholdInsideSphereIsland,
|
|
28
29
|
},
|
|
29
30
|
strategySpecificConfiguration: {
|
|
30
31
|
THRESHOLD: {
|
|
@@ -52,14 +53,6 @@ class BrushTool extends BaseTool {
|
|
|
52
53
|
},
|
|
53
54
|
],
|
|
54
55
|
},
|
|
55
|
-
[StrategyCallbacks.RejectPreview]: {
|
|
56
|
-
method: StrategyCallbacks.RejectPreview,
|
|
57
|
-
bindings: [
|
|
58
|
-
{
|
|
59
|
-
key: 'Escape',
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
56
|
},
|
|
64
57
|
},
|
|
65
58
|
}) {
|
|
@@ -401,7 +394,7 @@ class BrushTool extends BaseTool {
|
|
|
401
394
|
];
|
|
402
395
|
const activeStrategy = this.configuration.activeStrategy;
|
|
403
396
|
const strategy = this.configuration.strategies[activeStrategy];
|
|
404
|
-
if (typeof strategy
|
|
397
|
+
if (typeof strategy?.computeInnerCircleRadius === 'function') {
|
|
405
398
|
strategy.computeInnerCircleRadius({
|
|
406
399
|
configuration: this.configuration,
|
|
407
400
|
viewport,
|
|
@@ -409,6 +402,14 @@ class BrushTool extends BaseTool {
|
|
|
409
402
|
}
|
|
410
403
|
data.invalidated = false;
|
|
411
404
|
}
|
|
405
|
+
getStatistics(element, segmentIndices) {
|
|
406
|
+
if (!element) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const enabledElement = getEnabledElement(element);
|
|
410
|
+
const stats = this.applyActiveStrategyCallback(enabledElement, this.getOperationData(element), StrategyCallbacks.GetStatistics, segmentIndices);
|
|
411
|
+
return stats;
|
|
412
|
+
}
|
|
412
413
|
rejectPreview(element = this._previewData.element) {
|
|
413
414
|
if (!element || !this._previewData.preview) {
|
|
414
415
|
return;
|
|
@@ -59,6 +59,11 @@ export default class BrushStrategy {
|
|
|
59
59
|
threshold: {
|
|
60
60
|
createIsInThreshold: (operationData: InitializedOperationData) => (index: any) => boolean;
|
|
61
61
|
};
|
|
62
|
+
labelmapStatistics: {
|
|
63
|
+
getStatistics: (enabledElement: any, operationData: InitializedOperationData, options?: {
|
|
64
|
+
indices?: number | number[];
|
|
65
|
+
}) => import("../../../types").NamedStatistics;
|
|
66
|
+
};
|
|
62
67
|
};
|
|
63
68
|
protected static childFunctions: {
|
|
64
69
|
onInteractionStart: (brushStrategy: any, func: any) => void;
|
|
@@ -71,6 +76,7 @@ export default class BrushStrategy {
|
|
|
71
76
|
setValue: (brushStrategy: any, func: any) => void;
|
|
72
77
|
preview: (brushStrategy: any, func: any) => void;
|
|
73
78
|
computeInnerCircleRadius: (brushStrategy: any, func: any) => void;
|
|
79
|
+
getStatistics: (brushStrategy: any, func: any) => void;
|
|
74
80
|
compositions: any;
|
|
75
81
|
};
|
|
76
82
|
compositions: Composition[];
|
|
@@ -17,6 +17,7 @@ export default class BrushStrategy {
|
|
|
17
17
|
[StrategyCallbacks.INTERNAL_setValue]: addSingletonMethod(StrategyCallbacks.INTERNAL_setValue),
|
|
18
18
|
[StrategyCallbacks.Preview]: addSingletonMethod(StrategyCallbacks.Preview, false),
|
|
19
19
|
[StrategyCallbacks.ComputeInnerCircleRadius]: addListMethod(StrategyCallbacks.ComputeInnerCircleRadius),
|
|
20
|
+
[StrategyCallbacks.GetStatistics]: addSingletonMethod(StrategyCallbacks.GetStatistics),
|
|
20
21
|
compositions: null,
|
|
21
22
|
}; }
|
|
22
23
|
constructor(name, ...initializers) {
|
|
@@ -36,8 +37,9 @@ export default class BrushStrategy {
|
|
|
36
37
|
strategySpecificConfiguration.centerIJK = centerIJK;
|
|
37
38
|
}
|
|
38
39
|
this._fill.forEach((func) => func(initializedData));
|
|
39
|
-
const { segmentationVoxelManager, previewVoxelManager, previewSegmentIndex, } = initializedData;
|
|
40
|
-
|
|
40
|
+
const { segmentationVoxelManager, previewVoxelManager, previewSegmentIndex, segmentIndex, } = initializedData;
|
|
41
|
+
const isPreview = previewSegmentIndex && previewVoxelManager.modifiedSlices.size;
|
|
42
|
+
triggerSegmentationDataModified(initializedData.segmentationId, segmentationVoxelManager.getArrayOfModifiedSlices(), isPreview ? previewSegmentIndex : segmentIndex);
|
|
41
43
|
if (!previewSegmentIndex || !previewVoxelManager.modifiedSlices.size) {
|
|
42
44
|
segmentationVoxelManager.resetModifiedSlices();
|
|
43
45
|
return null;
|
|
@@ -134,9 +136,9 @@ function addSingletonMethod(name, isInitialized = true) {
|
|
|
134
136
|
}
|
|
135
137
|
brushStrategy[name] = isInitialized
|
|
136
138
|
? func
|
|
137
|
-
: (enabledElement, operationData) => {
|
|
139
|
+
: (enabledElement, operationData, ...args) => {
|
|
138
140
|
operationData.enabledElement = enabledElement;
|
|
139
|
-
return func.call(brushStrategy, operationData);
|
|
141
|
+
return func.call(brushStrategy, operationData, ...args);
|
|
140
142
|
};
|
|
141
143
|
};
|
|
142
144
|
}
|
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
hasSegmentIndex ||= value === segmentIndex;
|
|
23
23
|
hasPreviewIndex ||= value === previewSegmentIndex;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
segmentationVoxelManager.forEach(callback, {
|
|
26
26
|
imageData: segmentationImageData,
|
|
27
27
|
isInObject: operationData.isInObject,
|
|
28
28
|
});
|
|
@@ -32,5 +32,10 @@ declare const _default: {
|
|
|
32
32
|
threshold: {
|
|
33
33
|
createIsInThreshold: (operationData: import("../BrushStrategy").InitializedOperationData) => (index: any) => boolean;
|
|
34
34
|
};
|
|
35
|
+
labelmapStatistics: {
|
|
36
|
+
getStatistics: (enabledElement: any, operationData: import("../BrushStrategy").InitializedOperationData, options?: {
|
|
37
|
+
indices?: number | number[];
|
|
38
|
+
}) => import("../../../../types").NamedStatistics;
|
|
39
|
+
};
|
|
35
40
|
};
|
|
36
41
|
export default _default;
|
|
@@ -6,6 +6,7 @@ import preview from './preview';
|
|
|
6
6
|
import regionFill from './regionFill';
|
|
7
7
|
import setValue from './setValue';
|
|
8
8
|
import threshold from './threshold';
|
|
9
|
+
import labelmapStatistics from './labelmapStatistics';
|
|
9
10
|
export default {
|
|
10
11
|
determineSegmentIndex,
|
|
11
12
|
dynamicThreshold,
|
|
@@ -15,4 +16,5 @@ export default {
|
|
|
15
16
|
regionFill,
|
|
16
17
|
setValue,
|
|
17
18
|
threshold,
|
|
19
|
+
labelmapStatistics,
|
|
18
20
|
};
|
|
@@ -118,6 +118,6 @@ export default {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
triggerSegmentationDataModified(operationData.segmentationId, previewVoxelManager.getArrayOfModifiedSlices());
|
|
121
|
+
triggerSegmentationDataModified(operationData.segmentationId, previewVoxelManager.getArrayOfModifiedSlices(), previewSegmentIndex);
|
|
122
122
|
},
|
|
123
123
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InitializedOperationData } from '../BrushStrategy';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
getStatistics: (enabledElement: any, operationData: InitializedOperationData, options?: {
|
|
4
|
+
indices?: number | number[];
|
|
5
|
+
}) => import("../../../../types").NamedStatistics;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import StrategyCallbacks from '../../../../enums/StrategyCallbacks';
|
|
2
|
+
import VolumetricCalculator from '../../../../utilities/segmentation/VolumetricCalculator';
|
|
3
|
+
import { getActiveSegmentIndex } from '../../../../stateManagement/segmentation/getActiveSegmentIndex';
|
|
4
|
+
import { getStrategyData } from '../utils/getStrategyData';
|
|
5
|
+
export default {
|
|
6
|
+
[StrategyCallbacks.GetStatistics]: function (enabledElement, operationData, options) {
|
|
7
|
+
const { viewport } = enabledElement;
|
|
8
|
+
let { indices } = options;
|
|
9
|
+
const { segmentationId } = operationData;
|
|
10
|
+
if (!indices) {
|
|
11
|
+
indices = [getActiveSegmentIndex(segmentationId)];
|
|
12
|
+
}
|
|
13
|
+
else if (!Array.isArray(indices)) {
|
|
14
|
+
indices = [indices, 255];
|
|
15
|
+
}
|
|
16
|
+
const indicesArr = indices;
|
|
17
|
+
const { segmentationVoxelManager, imageVoxelManager, segmentationImageData, } = getStrategyData({
|
|
18
|
+
operationData,
|
|
19
|
+
viewport,
|
|
20
|
+
});
|
|
21
|
+
const spacing = segmentationImageData.getSpacing();
|
|
22
|
+
segmentationVoxelManager.forEach((voxel) => {
|
|
23
|
+
const { value, pointIJK } = voxel;
|
|
24
|
+
if (indicesArr.indexOf(value) === -1) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const imageValue = imageVoxelManager.getAtIJKPoint(pointIJK);
|
|
28
|
+
VolumetricCalculator.statsCallback({ value: imageValue });
|
|
29
|
+
});
|
|
30
|
+
return VolumetricCalculator.getStatistics({ spacing });
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -66,7 +66,7 @@ export default {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
tracking.forEach(callback, {});
|
|
69
|
-
triggerSegmentationDataModified(operationData.segmentationId, tracking.getArrayOfModifiedSlices());
|
|
69
|
+
triggerSegmentationDataModified(operationData.segmentationId, tracking.getArrayOfModifiedSlices(), preview.segmentIndex);
|
|
70
70
|
tracking.clear();
|
|
71
71
|
},
|
|
72
72
|
[StrategyCallbacks.RejectPreview]: (operationData) => {
|
|
@@ -78,7 +78,7 @@ export default {
|
|
|
78
78
|
segmentationVoxelManager.setAtIndex(index, value);
|
|
79
79
|
};
|
|
80
80
|
previewVoxelManager.forEach(callback);
|
|
81
|
-
triggerSegmentationDataModified(operationData.segmentationId, previewVoxelManager.getArrayOfModifiedSlices());
|
|
81
|
+
triggerSegmentationDataModified(operationData.segmentationId, previewVoxelManager.getArrayOfModifiedSlices(), 0);
|
|
82
82
|
previewVoxelManager.clear();
|
|
83
83
|
},
|
|
84
84
|
};
|
|
@@ -61,8 +61,8 @@ function createPointInEllipse(worldInfo) {
|
|
|
61
61
|
const { precalculated } = precalculatePointInEllipse(ellipseObj, {});
|
|
62
62
|
return precalculated;
|
|
63
63
|
}
|
|
64
|
-
const CIRCLE_STRATEGY = new BrushStrategy('Circle', compositions.regionFill, compositions.setValue, initializeCircle, compositions.determineSegmentIndex, compositions.preview);
|
|
65
|
-
const CIRCLE_THRESHOLD_STRATEGY = new BrushStrategy('CircleThreshold', compositions.regionFill, compositions.setValue, initializeCircle, compositions.determineSegmentIndex, compositions.dynamicThreshold, compositions.threshold, compositions.preview, compositions.islandRemoval);
|
|
64
|
+
const CIRCLE_STRATEGY = new BrushStrategy('Circle', compositions.regionFill, compositions.setValue, initializeCircle, compositions.determineSegmentIndex, compositions.preview, compositions.labelmapStatistics);
|
|
65
|
+
const CIRCLE_THRESHOLD_STRATEGY = new BrushStrategy('CircleThreshold', compositions.regionFill, compositions.setValue, initializeCircle, compositions.determineSegmentIndex, compositions.dynamicThreshold, compositions.threshold, compositions.preview, compositions.islandRemoval, compositions.labelmapStatistics);
|
|
66
66
|
const fillInsideCircle = CIRCLE_STRATEGY.strategyFunction;
|
|
67
67
|
const thresholdInsideCircle = CIRCLE_THRESHOLD_STRATEGY.strategyFunction;
|
|
68
68
|
export function fillOutsideCircle() {
|
|
@@ -2,5 +2,6 @@ import BrushStrategy from './BrushStrategy';
|
|
|
2
2
|
declare const SPHERE_STRATEGY: BrushStrategy;
|
|
3
3
|
declare const fillInsideSphere: (enabledElement: any, operationData: any) => unknown;
|
|
4
4
|
declare const thresholdInsideSphere: (enabledElement: any, operationData: any) => unknown;
|
|
5
|
+
declare const thresholdInsideSphereIsland: (enabledElement: any, operationData: any) => unknown;
|
|
5
6
|
export declare function fillOutsideSphere(): void;
|
|
6
|
-
export { fillInsideSphere, thresholdInsideSphere, SPHERE_STRATEGY };
|
|
7
|
+
export { fillInsideSphere, thresholdInsideSphere, SPHERE_STRATEGY, thresholdInsideSphereIsland, };
|
|
@@ -28,11 +28,13 @@ const sphereComposition = {
|
|
|
28
28
|
});
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
|
-
const SPHERE_STRATEGY = new BrushStrategy('Sphere', compositions.regionFill, compositions.setValue, sphereComposition, compositions.determineSegmentIndex, compositions.preview);
|
|
31
|
+
const SPHERE_STRATEGY = new BrushStrategy('Sphere', compositions.regionFill, compositions.setValue, sphereComposition, compositions.determineSegmentIndex, compositions.preview, compositions.labelmapStatistics);
|
|
32
32
|
const fillInsideSphere = SPHERE_STRATEGY.strategyFunction;
|
|
33
33
|
const SPHERE_THRESHOLD_STRATEGY = new BrushStrategy('SphereThreshold', ...SPHERE_STRATEGY.compositions, compositions.dynamicThreshold, compositions.threshold, compositions.islandRemoval);
|
|
34
|
+
const SPHERE_THRESHOLD_STRATEGY_ISLAND = new BrushStrategy('SphereThreshold', ...SPHERE_STRATEGY.compositions, compositions.dynamicThreshold, compositions.threshold, compositions.islandRemoval);
|
|
34
35
|
const thresholdInsideSphere = SPHERE_THRESHOLD_STRATEGY.strategyFunction;
|
|
36
|
+
const thresholdInsideSphereIsland = SPHERE_THRESHOLD_STRATEGY_ISLAND.strategyFunction;
|
|
35
37
|
export function fillOutsideSphere() {
|
|
36
38
|
throw new Error('fill outside sphere not implemented');
|
|
37
39
|
}
|
|
38
|
-
export { fillInsideSphere, thresholdInsideSphere, SPHERE_STRATEGY };
|
|
40
|
+
export { fillInsideSphere, thresholdInsideSphere, SPHERE_STRATEGY, thresholdInsideSphereIsland, };
|
|
@@ -108,6 +108,7 @@ type ContourAnnotationCompletedEventDetail = AnnotationCompletedEventDetail & {
|
|
|
108
108
|
type SegmentationDataModifiedEventDetail = {
|
|
109
109
|
segmentationId: string;
|
|
110
110
|
modifiedSlicesToUse?: number[];
|
|
111
|
+
segmentIndex?: number;
|
|
111
112
|
};
|
|
112
113
|
type SegmentationRenderedEventDetail = {
|
|
113
114
|
viewportId: string;
|
|
@@ -24,7 +24,9 @@ export default class BasicStatsCalculator extends Calculator {
|
|
|
24
24
|
this.runMean.push(0, 0);
|
|
25
25
|
this.m2.push(this.m2[0], this.m2[0]);
|
|
26
26
|
}
|
|
27
|
-
this.pointsInShape
|
|
27
|
+
if (this.pointsInShape && pointLPS) {
|
|
28
|
+
this.pointsInShape?.push(pointLPS);
|
|
29
|
+
}
|
|
28
30
|
const newArray = Array.isArray(newValue) ? newValue : [newValue];
|
|
29
31
|
this.count += 1;
|
|
30
32
|
this.max.map((it, idx) => {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NamedStatistics } from '../../types';
|
|
2
|
+
import { BasicStatsCalculator } from '../math/basic';
|
|
3
|
+
export default class VolumetricCalculator extends BasicStatsCalculator {
|
|
4
|
+
static getStatistics(options: {
|
|
5
|
+
spacing?: number;
|
|
6
|
+
unit?: string;
|
|
7
|
+
}): NamedStatistics;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BasicStatsCalculator } from '../math/basic';
|
|
2
|
+
export default class VolumetricCalculator extends BasicStatsCalculator {
|
|
3
|
+
static getStatistics(options) {
|
|
4
|
+
const { spacing } = options;
|
|
5
|
+
const stats = BasicStatsCalculator.getStatistics();
|
|
6
|
+
const volumeUnit = spacing ? 'mm\xb3' : 'voxels\xb3';
|
|
7
|
+
const volumeScale = spacing ? spacing[0] * spacing[1] * spacing[2] : 1;
|
|
8
|
+
stats.volume = {
|
|
9
|
+
value: Array.isArray(stats.count.value)
|
|
10
|
+
? stats.count.value.map((v) => v * volumeScale)
|
|
11
|
+
: stats.count.value * volumeScale,
|
|
12
|
+
unit: volumeUnit,
|
|
13
|
+
name: 'volume',
|
|
14
|
+
};
|
|
15
|
+
stats.array.push(stats.volume);
|
|
16
|
+
return stats;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -6,6 +6,7 @@ import { triggerSegmentationRender, triggerSegmentationRenderBySegmentationId }
|
|
|
6
6
|
import floodFill from './floodFill';
|
|
7
7
|
import { getBrushSizeForToolGroup, setBrushSizeForToolGroup } from './brushSizeForToolGroup';
|
|
8
8
|
import { getBrushThresholdForToolGroup, setBrushThresholdForToolGroup } from './brushThresholdForToolGroup';
|
|
9
|
+
import VolumetricCalculator from './VolumetricCalculator';
|
|
9
10
|
import thresholdSegmentationByRange from './thresholdSegmentationByRange';
|
|
10
11
|
import contourAndFindLargestBidirectional from './contourAndFindLargestBidirectional';
|
|
11
12
|
import createBidirectionalToolData from './createBidirectionalToolData';
|
|
@@ -16,4 +17,4 @@ import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
|
|
|
16
17
|
import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
|
|
17
18
|
import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
|
|
18
19
|
import { getBrushToolInstances } from './getBrushToolInstances';
|
|
19
|
-
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
|
|
20
|
+
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
|
|
@@ -6,6 +6,7 @@ import { triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, }
|
|
|
6
6
|
import floodFill from './floodFill';
|
|
7
7
|
import { getBrushSizeForToolGroup, setBrushSizeForToolGroup, } from './brushSizeForToolGroup';
|
|
8
8
|
import { getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, } from './brushThresholdForToolGroup';
|
|
9
|
+
import VolumetricCalculator from './VolumetricCalculator';
|
|
9
10
|
import thresholdSegmentationByRange from './thresholdSegmentationByRange';
|
|
10
11
|
import contourAndFindLargestBidirectional from './contourAndFindLargestBidirectional';
|
|
11
12
|
import createBidirectionalToolData from './createBidirectionalToolData';
|
|
@@ -16,4 +17,4 @@ import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
|
|
|
16
17
|
import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
|
|
17
18
|
import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
|
|
18
19
|
import { getBrushToolInstances } from './getBrushToolInstances';
|
|
19
|
-
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
|
|
20
|
+
export { thresholdVolumeByRange, createMergedLabelmapForIndex, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, VolumetricCalculator, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"canvas": "^2.11.2"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
|
-
"@cornerstonejs/core": "^2.
|
|
107
|
+
"@cornerstonejs/core": "^2.3.0",
|
|
108
108
|
"@kitware/vtk.js": "32.1.1",
|
|
109
109
|
"@types/d3-array": "^3.0.4",
|
|
110
110
|
"@types/d3-interpolate": "^3.0.1",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"type": "individual",
|
|
124
124
|
"url": "https://ohif.org/donate"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "bb71a514486a519a45468b1f474b5c2c0bb25575"
|
|
127
127
|
}
|