From faf5515e4b93da58b673f1ae59ec345e30870446 Mon Sep 17 00:00:00 2001 From: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:12:58 -0500 Subject: [PATCH] fix(segmentation): black preview when loading a seg, and crash on opening panel (#4602) --- .../src/panels/PanelSegmentation.tsx | 6 +++-- .../SegmentationService.ts | 22 +++++++++++-------- .../default/src/DicomLocalDataSource/index.js | 3 ++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/extensions/cornerstone/src/panels/PanelSegmentation.tsx b/extensions/cornerstone/src/panels/PanelSegmentation.tsx index a402531b8d..e12ce7b0a4 100644 --- a/extensions/cornerstone/src/panels/PanelSegmentation.tsx +++ b/extensions/cornerstone/src/panels/PanelSegmentation.tsx @@ -243,13 +243,15 @@ export default function PanelSegmentation({ const firstImageId = referencedImageIds[0]; const instance = metaData.get('instance', firstImageId); - const { SOPInstanceUID, SeriesInstanceUID } = instance; + const SOPInstanceUID = instance.SOPInstanceUID || instance.SopInstanceUID; + const SeriesInstanceUID = instance.SeriesInstanceUID; const displaySet = displaySetService.getDisplaySetForSOPInstanceUID( SOPInstanceUID, SeriesInstanceUID ); - const isExportable = displaySet.isReconstructable; + + const isExportable = displaySet?.isReconstructable; return { segmentationId, diff --git a/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts b/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts index 7236fb526a..b259558545 100644 --- a/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts +++ b/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts @@ -7,6 +7,7 @@ import { imageLoader, Types as csTypes, utilities as csUtils, + metaData, } from '@cornerstonejs/core'; import { Enums as csToolsEnums, @@ -360,11 +361,11 @@ class SegmentationService extends PubSubService { options.segments && Object.keys(options.segments).length > 0 ? options.segments : { - 1: { - label: 'Segment 1', - active: true, - }, + 1: { + label: 'Segment 1', + active: true, }, + }, cachedStats: { info: `S${displaySet.SeriesNumber}: ${displaySet.SeriesDescription}`, }, @@ -381,8 +382,8 @@ class SegmentationService extends PubSubService { segmentationId?: string; type: SegmentationRepresentations; } = { - type: LABELMAP, - } + type: LABELMAP, + } ): Promise { const { type } = options; let { segmentationId } = options; @@ -414,7 +415,10 @@ class SegmentationService extends PubSubService { imageIds as string[] ); - segDisplaySet.images = derivedSegmentationImages; + segDisplaySet.images = derivedSegmentationImages.map(image => ({ + ...image, + ...metaData.get('instance', image.referencedImageId), + })); const segmentsInfo = segDisplaySet.segMetadata.data; @@ -531,8 +535,8 @@ class SegmentationService extends PubSubService { segmentationId?: string; type: SegmentationRepresentations; } = { - type: CONTOUR, - } + type: CONTOUR, + } ): Promise { const { type } = options; let { segmentationId } = options; diff --git a/extensions/default/src/DicomLocalDataSource/index.js b/extensions/default/src/DicomLocalDataSource/index.js index a0ea9fb4ff..d049b404a9 100644 --- a/extensions/default/src/DicomLocalDataSource/index.js +++ b/extensions/default/src/DicomLocalDataSource/index.js @@ -221,7 +221,8 @@ function createDicomLocalApi(dicomLocalConfig) { // return instance.imageId; // } - const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance; + const { StudyInstanceUID, SeriesInstanceUID } = instance; + const SOPInstanceUID = instance.SOPInstanceUID || instance.SopInstanceUID; const storedInstance = DicomMetadataStore.getInstance( StudyInstanceUID, SeriesInstanceUID,