fix(rt): dont convert to volume for RTSTRUCT (#4157)
Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
1 parent
b0af8ec553
commit
7745c092bb
9 files changed
+78
-55
No files matched your search
+26
-15
@@ -143,14 +143,25 @@ class CornerstoneCacheService {
|
||||
return newViewportData;
|
||||
}
|
||||
|
||||
private _getStackViewportData(
|
||||
private async _getStackViewportData(
|
||||
dataSource,
|
||||
displaySets,
|
||||
initialImageIndex,
|
||||
viewportType: Enums.ViewportType
|
||||
): StackViewportData {
|
||||
// For Stack Viewport we don't have fusion currently
|
||||
const displaySet = displaySets[0];
|
||||
): Promise<StackViewportData> {
|
||||
const overlayDisplaySets = displaySets.filter(ds => ds.isOverlayDisplaySet);
|
||||
const nonOverlayDisplaySets = displaySets.filter(ds => !ds.isOverlayDisplaySet);
|
||||
|
||||
// load overlays if they are not loaded
|
||||
for (const overlayDisplaySet of overlayDisplaySets) {
|
||||
if (overlayDisplaySet.load && overlayDisplaySet.load instanceof Function) {
|
||||
const { userAuthenticationService } = this.servicesManager.services;
|
||||
const headers = userAuthenticationService.getAuthorizationHeader();
|
||||
await overlayDisplaySet.load({ headers });
|
||||
}
|
||||
}
|
||||
|
||||
const displaySet = nonOverlayDisplaySets[0];
|
||||
|
||||
let stackImageIds = this.stackImageIds.get(displaySet.displaySetInstanceUID);
|
||||
|
||||
@@ -159,23 +170,23 @@ class CornerstoneCacheService {
|
||||
this.stackImageIds.set(displaySet.displaySetInstanceUID, stackImageIds);
|
||||
}
|
||||
|
||||
const { displaySetInstanceUID, StudyInstanceUID, isCompositeStack } = displaySet;
|
||||
// Ensuring the first non-overlay `displaySet` is always the primary one
|
||||
const StackViewportData = [displaySet, ...overlayDisplaySets].map(ds => {
|
||||
const { displaySetInstanceUID, StudyInstanceUID, isCompositeStack } = ds;
|
||||
|
||||
const StackViewportData: StackViewportData = {
|
||||
viewportType,
|
||||
data: {
|
||||
return {
|
||||
StudyInstanceUID,
|
||||
displaySetInstanceUID,
|
||||
isCompositeStack,
|
||||
imageIds: stackImageIds,
|
||||
},
|
||||
initialImageIndex,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
viewportType,
|
||||
data: StackViewportData,
|
||||
};
|
||||
|
||||
if (typeof initialImageIndex === 'number') {
|
||||
StackViewportData.data.initialImageIndex = initialImageIndex;
|
||||
}
|
||||
|
||||
return StackViewportData;
|
||||
}
|
||||
|
||||
private async _getVolumeViewportData(
|
||||
|
||||
@@ -557,9 +557,14 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
): Promise<void> {
|
||||
const displaySetOptions = viewportInfo.getDisplaySetOptions();
|
||||
|
||||
const { imageIds, initialImageIndex, displaySetInstanceUID } = viewportData.data;
|
||||
const displaySetInstanceUIDs = viewportData.data.map(data => data.displaySetInstanceUID);
|
||||
|
||||
this.viewportsDisplaySets.set(viewport.id, [displaySetInstanceUID]);
|
||||
// based on the cache service construct always the first one is the non-overlay
|
||||
// and the rest are overlays
|
||||
|
||||
this.viewportsDisplaySets.set(viewport.id, [...displaySetInstanceUIDs]);
|
||||
|
||||
const { initialImageIndex, imageIds } = viewportData.data[0];
|
||||
|
||||
let initialImageIndexToUse =
|
||||
presentations?.positionPresentation?.initialImageIndex ?? initialImageIndex;
|
||||
@@ -588,6 +593,8 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
}
|
||||
}
|
||||
|
||||
this._handleOverlays(viewport);
|
||||
|
||||
return viewport.setStack(imageIds, initialImageIndexToUse).then(() => {
|
||||
viewport.setProperties({ ...properties });
|
||||
this.setPresentations(viewport.id, presentations);
|
||||
@@ -772,24 +779,7 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
|
||||
this.setPresentations(viewport.id, presentations);
|
||||
|
||||
// load any secondary displaySets
|
||||
const displaySetInstanceUIDs = this.viewportsDisplaySets.get(viewport.id);
|
||||
|
||||
// can be SEG or RTSTRUCT for now
|
||||
const overlayDisplaySet = displaySetInstanceUIDs
|
||||
.map(displaySetService.getDisplaySetByUID)
|
||||
.find(displaySet => displaySet?.isOverlayDisplaySet);
|
||||
|
||||
if (overlayDisplaySet) {
|
||||
this.addOverlayRepresentationForDisplaySet(overlayDisplaySet, viewport);
|
||||
} else {
|
||||
// If the displaySet is not a SEG displaySet we assume it is a primary displaySet
|
||||
// and we can look into hydrated segmentations to check if any of them are
|
||||
// associated with the primary displaySet
|
||||
|
||||
// get segmentations only returns the hydrated segmentations
|
||||
this._addSegmentationRepresentationToToolGroupIfNecessary(displaySetInstanceUIDs, viewport);
|
||||
}
|
||||
this._handleOverlays(viewport);
|
||||
|
||||
const toolGroup = toolGroupService.getToolGroupForViewport(viewport.id);
|
||||
csToolsUtils.segmentation.triggerSegmentationRender(toolGroup.id);
|
||||
@@ -809,6 +799,28 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
});
|
||||
}
|
||||
|
||||
private _handleOverlays(viewport: Types.IStackViewport | Types.IVolumeViewport) {
|
||||
const { displaySetService } = this.servicesManager.services;
|
||||
|
||||
// load any secondary displaySets
|
||||
const displaySetInstanceUIDs = this.viewportsDisplaySets.get(viewport.id);
|
||||
|
||||
// can be SEG or RTSTRUCT for now
|
||||
const overlayDisplaySet = displaySetInstanceUIDs
|
||||
.map(displaySetService.getDisplaySetByUID)
|
||||
.find(displaySet => displaySet?.isOverlayDisplaySet);
|
||||
if (overlayDisplaySet) {
|
||||
this.addOverlayRepresentationForDisplaySet(overlayDisplaySet, viewport);
|
||||
} else {
|
||||
// If the displaySet is not a SEG displaySet we assume it is a primary displaySet
|
||||
// and we can look into hydrated segmentations to check if any of them are
|
||||
// associated with the primary displaySet
|
||||
|
||||
// get segmentations only returns the hydrated segmentations
|
||||
this._addSegmentationRepresentationToToolGroupIfNecessary(displaySetInstanceUIDs, viewport);
|
||||
}
|
||||
}
|
||||
|
||||
private _addSegmentationRepresentationToToolGroupIfNecessary(
|
||||
displaySetInstanceUIDs: string[],
|
||||
viewport: any
|
||||
|
||||
Reference in new issue
Block a user