Skip to main content
Version: 3.9.0-beta.107 (Latest)

Segmentation Creation

createEmptySegmentationForViewport​

is now createLabelmapForViewport to align with other segmentation creation methods.

Run it using commandsManager.runCommand('createLabelmapForViewport', {viewportId}).

createSegmentationForDisplaySet​

is now -> createLabelmapForDisplaySet

Since we are moving towards segmentations be contours as well, this is renamed to clearly state the purpose. Since OHIF 3.9 introduced Stack Segmentation support, we no longer generate a volume-based labelmap or convert the viewport to a volume viewport by default. Our default creation is now stack-based.

API Changes

  • createSegmentationForDisplaySet has been renamed to createLabelmapForDisplaySet.
  • Pass a displaySet object instead of a displaySetInstanceUID. This change enhances type safety and flexibility, accommodating future updates to the displaySetService.

Before (OHIF 3.8)

async createSegmentationForDisplaySet(
displaySetInstanceUID: string,
options?: {
segmentationId: string;
FrameOfReferenceUID: string;
label: string;
}
): Promise<string>

After (OHIF 3.9)

// Method 1: Display Set Based
async createLabelmapForDisplaySet(
displaySet: DisplaySet,
options?: {
segmentationId?: string;
label: string;
segments?: {
[segmentIndex: number]: Partial<Segment>
};
}
): Promise<string>
Migration Examples
// Before - OHIF 3.8
const segmentationId = await segmentationService.createSegmentationForDisplaySet(
displaySetInstanceUID,
{
label: 'My Segmentation'
}
);
// After - OHIF 3.9
// Option 1: If you have a display set UID
const displaySet = displaySetService.getDisplaySetByUID(displaySetInstanceUID);

const segmentationId = await segmentationService.createLabelmapForDisplaySet(
displaySet,
{
label: 'My Segmentation'
}
);

createSegmentationForRTDisplaySet​

Before (OHIF 3.8)

async createSegmentationForRTDisplaySet(
rtDisplaySet,
segmentationId?: string,
suppressEvents = false
): Promise<string>

After (OHIF 3.9)

async createSegmentationForRTDisplaySet(
rtDisplaySet,
options: {
segmentationId?: string;
type: SegmentationRepresentations; // not required, defaults to Contour
}
): Promise<string>
Migration Examples

if you were not passing segmentationId, you don't need to change anything

// Before - OHIF 3.8
const segmentationId = await segmentationService.createSegmentationForRTDisplaySet(
rtDisplaySet
);

// After - OHIF 3.9
const segmentationId = await segmentationService.createSegmentationForRTDisplaySet(
rtDisplaySet,
);

if you were passing segmentationId, you need to update the API to pass an options object and set the segmentationId in there.

// Before - OHIF 3.8
const segmentationId = await segmentationService.createSegmentationForRTDisplaySet(
rtDisplaySet,
'custom-id',
);
// After - OHIF 3.9
const segmentationId = await segmentationService.createSegmentationForRTDisplaySet(
rtDisplaySet,
{
segmentationId: 'custom-id',
type: csToolsEnums.SegmentationRepresentations.Contour
}
);

createSegmentationForSEGDisplaySet Changes​

Before (OHIF 3.8)

async createSegmentationForSEGDisplaySet(
segDisplaySet,
segmentationId?: string,
suppressEvents = false
): Promise<string>

After (OHIF 3.9)

async createSegmentationForSEGDisplaySet(
segDisplaySet,
options: {
segmentationId?: string;
type: SegmentationRepresentations; // not required, defaults to Labelmap
}
): Promise<string>
Migration Examples
  1. Basic Usage Update

    // Before - OHIF 3.8
    const segmentationId = await segmentationService.createSegmentationForSEGDisplaySet(
    segDisplaySet
    );
    // After - OHIF 3.9
    const segmentationId = await segmentationService.createSegmentationForSEGDisplaySet(
    segDisplaySet,
    {
    type: csToolsEnums.SegmentationRepresentations.Labelmap
    }
    );
  2. Custom Configuration

    // Before - OHIF 3.8
    const segmentationId = await segmentationService.createSegmentationForSEGDisplaySet(
    segDisplaySet,
    'custom-id',
    false
    );
    // After - OHIF 3.9
    const segmentationId = await segmentationService.createSegmentationForSEGDisplaySet(
    segDisplaySet,
    {
    segmentationId: 'custom-id',
    type: csToolsEnums.SegmentationRepresentations.Labelmap
    }
    );