feat(segmentation): Enhance Segmentation Tools with Preview and Selection Features (#4870)

This commit is contained in:
Alireza authored and GitHub committed 2025-03-19 18:24:33 -04:00
1 parent 20042f9109
commit 5f112337b6
24 files changed
+392 -236

No files matched your search

@@ -264,10 +264,14 @@ class SegmentationService extends PubSubService {
{
segmentationId,
type,
config,
suppressEvents = false,
}: {
segmentationId: string;
type?: csToolsEnums.SegmentationRepresentations;
config?: {
blendMode?: csEnums.BlendModes;
};
suppressEvents?: boolean;
}
): Promise<void> {
@@ -301,7 +305,8 @@ class SegmentationService extends PubSubService {
segmentationId,
representationTypeToUse,
colorLUTIndex,
isConverted
isConverted,
config
);
if (!suppressEvents) {
@@ -1349,12 +1354,15 @@ class SegmentationService extends PubSubService {
segmentationId: string,
representationType: csToolsEnums.SegmentationRepresentations,
colorLUTIndex: number,
isConverted: boolean
isConverted: boolean,
config?: {
blendMode?: csEnums.BlendModes;
}
): Promise<void> {
const representation = {
type: representationType,
segmentationId,
config: { colorLUTOrIndex: colorLUTIndex },
config: { colorLUTOrIndex: colorLUTIndex, ...config },
};
const addRepresentation = () =>
@@ -1,4 +1,4 @@
import { Types, getEnabledElementByViewportId } from '@cornerstonejs/core';
import { Enums as CoreEnums, Types, getEnabledElementByViewportId } from '@cornerstonejs/core';
import {
SynchronizerManager,
Synchronizer,
@@ -7,7 +7,8 @@ import {
} from '@cornerstonejs/tools';
const { createSynchronizer } = SynchronizerManager;
const { SEGMENTATION_REPRESENTATION_ADDED } = Enums.Events;
const { SEGMENTATION_REPRESENTATION_MODIFIED } = Enums.Events;
const { BlendModes } = CoreEnums;
export default function createHydrateSegmentationSynchronizer(
synchronizerName: string,
@@ -15,15 +16,16 @@ export default function createHydrateSegmentationSynchronizer(
): Synchronizer {
const stackImageSynchronizer = createSynchronizer(
synchronizerName,
SEGMENTATION_REPRESENTATION_ADDED,
(synchronizerInstance, sourceViewport, targetViewport, sourceEvent) =>
segmentationRepresentationModifiedCallback(
SEGMENTATION_REPRESENTATION_MODIFIED,
(synchronizerInstance, sourceViewport, targetViewport, sourceEvent) => {
return segmentationRepresentationModifiedCallback(
synchronizerInstance,
sourceViewport,
targetViewport,
sourceEvent,
{ servicesManager, options }
),
);
},
{
eventSource: 'eventTarget',
}
@@ -41,8 +43,8 @@ const segmentationRepresentationModifiedCallback = async (
) => {
const event = sourceEvent as ToolsTypes.EventTypes.SegmentationRepresentationModifiedEventType;
const { segmentationId, viewportId } = event.detail;
const { segmentationService, hangingProtocolService } = servicesManager.services;
const { segmentationId } = event.detail;
const { segmentationService } = servicesManager.services;
const targetViewportId = targetViewport.viewportId;
@@ -75,5 +77,9 @@ const segmentationRepresentationModifiedCallback = async (
await segmentationService.addSegmentationRepresentation(targetViewportId, {
segmentationId,
type,
config: {
blendMode:
viewport.getBlendMode() === 1 ? BlendModes.LABELMAP_EDGE_PROJECTION_BLEND : undefined,
},
});
};