fix(seg): jump to the first slice in SEG and RT that has data (#4605)
This commit is contained in:
1 parent
7586006e7f
commit
9bf24d6dc5
15 files changed
+123
-60
No files matched your search
@@ -97,6 +97,7 @@ function OHIFCornerstonePMAPViewport(props: withAppTypes) {
|
||||
viewportType: 'volume',
|
||||
orientation: viewportOptions.orientation,
|
||||
viewportId: viewportOptions.viewportId,
|
||||
presentationIds: viewportOptions.presentationIds,
|
||||
}}
|
||||
displaySetOptions={[{}, pmapDisplaySetOptions]}
|
||||
></Component>
|
||||
|
||||
@@ -126,6 +126,7 @@ export default async function loadRTStruct(extensionManager, rtStructDisplaySet,
|
||||
SeriesInstanceUID: instance.SeriesInstanceUID,
|
||||
ROIContours: [],
|
||||
visible: true,
|
||||
ReferencedSOPInstanceUIDsSet: new Set(),
|
||||
};
|
||||
|
||||
for (let i = 0; i < ROIContourSequence.length; i++) {
|
||||
@@ -142,7 +143,8 @@ export default async function loadRTStruct(extensionManager, rtStructDisplaySet,
|
||||
|
||||
const contourPoints = [];
|
||||
for (let c = 0; c < ContourSequenceArray.length; c++) {
|
||||
const { ContourData, NumberOfContourPoints, ContourGeometricType } = ContourSequenceArray[c];
|
||||
const { ContourData, NumberOfContourPoints, ContourGeometricType, ContourImageSequence } =
|
||||
ContourSequenceArray[c];
|
||||
|
||||
let isSupported = false;
|
||||
|
||||
@@ -172,6 +174,12 @@ export default async function loadRTStruct(extensionManager, rtStructDisplaySet,
|
||||
type: ContourGeometricType,
|
||||
isSupported,
|
||||
});
|
||||
|
||||
if (ContourImageSequence?.ReferencedSOPInstanceUID) {
|
||||
structureSet.ReferencedSOPInstanceUIDsSet.add(
|
||||
ContourImageSequence?.ReferencedSOPInstanceUID
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_setROIContourMetadata(
|
||||
|
||||
@@ -6,7 +6,7 @@ import promptHydrateRT from '../utils/promptHydrateRT';
|
||||
import _getStatusComponent from './_getStatusComponent';
|
||||
|
||||
import createRTToolGroupAndAddTools from '../utils/initRTToolGroup';
|
||||
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
||||
import { usePositionPresentationStore } from '@ohif/extension-cornerstone';
|
||||
|
||||
const RT_TOOLGROUP_BASE_NAME = 'RTToolGroup';
|
||||
|
||||
@@ -43,8 +43,8 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) {
|
||||
const [viewportGrid, viewportGridService] = useViewportGrid();
|
||||
|
||||
// States
|
||||
const [isToolGroupCreated, setToolGroupCreated] = useState(false);
|
||||
const [selectedSegment, setSelectedSegment] = useState(1);
|
||||
const { setPositionPresentation } = usePositionPresentationStore();
|
||||
|
||||
// Hydration means that the RT is opened and segments are loaded into the
|
||||
// segmentation panel, and RT is also rendered on any viewport that is in the
|
||||
@@ -123,6 +123,7 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) {
|
||||
toolGroupId: toolGroupId,
|
||||
orientation: viewportOptions.orientation,
|
||||
viewportId: viewportOptions.viewportId,
|
||||
presentationIds: viewportOptions.presentationIds,
|
||||
}}
|
||||
onElementEnabled={evt => {
|
||||
props.onElementEnabled?.(evt);
|
||||
@@ -185,6 +186,19 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) {
|
||||
setRtIsLoading(false);
|
||||
}
|
||||
|
||||
if (rtDisplaySet?.firstSegmentedSliceImageId && viewportOptions?.presentationIds) {
|
||||
const { firstSegmentedSliceImageId } = rtDisplaySet;
|
||||
const { presentationIds } = viewportOptions;
|
||||
|
||||
setPositionPresentation(presentationIds.positionPresentationId, {
|
||||
viewportType: 'stack',
|
||||
viewReference: {
|
||||
referencedImageId: firstSegmentedSliceImageId,
|
||||
},
|
||||
viewPresentation: {},
|
||||
});
|
||||
}
|
||||
|
||||
if (evt.overlappingSegments) {
|
||||
uiNotificationService.show({
|
||||
title: 'Overlapping Segments',
|
||||
@@ -247,8 +261,6 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) {
|
||||
|
||||
toolGroup = createRTToolGroupAndAddTools(toolGroupService, customizationService, toolGroupId);
|
||||
|
||||
setToolGroupCreated(true);
|
||||
|
||||
return () => {
|
||||
// remove the segmentation representations if seg displayset changed
|
||||
segmentationService.removeSegmentationRepresentations(viewportId);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { LoadingIndicatorTotalPercent, useViewportGrid, ViewportActionArrows } f
|
||||
import createSEGToolGroupAndAddTools from '../utils/initSEGToolGroup';
|
||||
import promptHydrateSEG from '../utils/promptHydrateSEG';
|
||||
import _getStatusComponent from './_getStatusComponent';
|
||||
import { usePositionPresentationStore } from '@ohif/extension-cornerstone';
|
||||
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
||||
|
||||
const SEG_TOOLGROUP_BASE_NAME = 'SEGToolGroup';
|
||||
@@ -41,6 +42,7 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) {
|
||||
|
||||
// States
|
||||
const [selectedSegment, setSelectedSegment] = useState(1);
|
||||
const { setPositionPresentation } = usePositionPresentationStore();
|
||||
|
||||
// Hydration means that the SEG is opened and segments are loaded into the
|
||||
// segmentation panel, and SEG is also rendered on any viewport that is in the
|
||||
@@ -198,6 +200,17 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) {
|
||||
if (evt.segDisplaySet.displaySetInstanceUID === segDisplaySet.displaySetInstanceUID) {
|
||||
setSegIsLoading(false);
|
||||
}
|
||||
|
||||
if (segDisplaySet?.firstSegmentedSliceImageId && viewportOptions?.presentationIds) {
|
||||
const { firstSegmentedSliceImageId } = segDisplaySet;
|
||||
const { presentationIds } = viewportOptions;
|
||||
|
||||
setPositionPresentation(presentationIds.positionPresentationId, {
|
||||
viewReference: {
|
||||
referencedImageId: firstSegmentedSliceImageId,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
+10
-22
@@ -16,22 +16,13 @@ const MEASUREMENT_TRACKING_EXTENSION_ID = '@ohif/extension-measurement-tracking'
|
||||
const SR_TOOLGROUP_BASE_NAME = 'SRToolGroup';
|
||||
|
||||
function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
const {
|
||||
children,
|
||||
dataSource,
|
||||
displaySets,
|
||||
viewportOptions,
|
||||
servicesManager,
|
||||
extensionManager,
|
||||
} = props;
|
||||
const { children, dataSource, displaySets, viewportOptions, servicesManager, extensionManager } =
|
||||
props;
|
||||
|
||||
const [appConfig] = useAppConfig();
|
||||
|
||||
const {
|
||||
displaySetService,
|
||||
measurementService,
|
||||
viewportActionCornersService,
|
||||
} = servicesManager.services;
|
||||
const { displaySetService, measurementService, viewportActionCornersService } =
|
||||
servicesManager.services;
|
||||
|
||||
const viewportId = viewportOptions.viewportId;
|
||||
|
||||
@@ -44,7 +35,6 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
|
||||
const { setPositionPresentation } = usePositionPresentationStore();
|
||||
|
||||
|
||||
const [viewportGrid, viewportGridService] = useViewportGrid();
|
||||
const [measurementSelected, setMeasurementSelected] = useState(0);
|
||||
const [measurementCount, setMeasurementCount] = useState(1);
|
||||
@@ -160,13 +150,13 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
setActiveImageDisplaySetData(referencedDisplaySet);
|
||||
setReferencedDisplaySetMetadata(referencedDisplaySetMetadata);
|
||||
|
||||
const { presentationIds } = viewportOptions
|
||||
const measurement = srDisplaySet.measurements[newMeasurementSelected]
|
||||
setPositionPresentation(presentationIds.positionPresentationId, {
|
||||
const { presentationIds } = viewportOptions;
|
||||
const measurement = srDisplaySet.measurements[newMeasurementSelected];
|
||||
setPositionPresentation(presentationIds.positionPresentationId, {
|
||||
viewReference: {
|
||||
referencedImageId: measurement.imageId
|
||||
}
|
||||
})
|
||||
referencedImageId: measurement.imageId,
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
[dataSource, srDisplaySet, activeImageDisplaySetData, viewportId]
|
||||
@@ -188,8 +178,6 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Component
|
||||
{...props}
|
||||
|
||||
@@ -20,7 +20,7 @@ const frameView: Types.HangingProtocol.Protocol = {
|
||||
},
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
weight: 20,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
|
||||
@@ -479,14 +479,24 @@ class SegmentationService extends PubSubService {
|
||||
// We should parse the segmentation as separate slices to support overlapping segments.
|
||||
// This parsing should occur in the CornerstoneJS library adapters.
|
||||
// For now, we use the volume returned from the library and chop it here.
|
||||
let firstSegmentedSliceImageId = null;
|
||||
for (let i = 0; i < derivedSegmentationImages.length; i++) {
|
||||
const voxelManager = derivedSegmentationImages[i]
|
||||
.voxelManager as csTypes.IVoxelManager<number>;
|
||||
const scalarData = voxelManager.getScalarData();
|
||||
scalarData.set(volumeScalarData.slice(i * scalarData.length, (i + 1) * scalarData.length));
|
||||
const sliceData = volumeScalarData.slice(i * scalarData.length, (i + 1) * scalarData.length);
|
||||
scalarData.set(sliceData);
|
||||
voxelManager.setScalarData(scalarData);
|
||||
|
||||
// Check if this slice has any non-zero voxels and we haven't found one yet
|
||||
if (!firstSegmentedSliceImageId && sliceData.some(value => value !== 0)) {
|
||||
firstSegmentedSliceImageId = derivedSegmentationImages[i].referencedImageId;
|
||||
}
|
||||
}
|
||||
|
||||
// assign the first non zero voxel image id to the segDisplaySet
|
||||
segDisplaySet.firstSegmentedSliceImageId = firstSegmentedSliceImageId;
|
||||
|
||||
this._broadcastEvent(EVENTS.SEGMENTATION_LOADING_COMPLETE, {
|
||||
segmentationId,
|
||||
segDisplaySet,
|
||||
@@ -543,7 +553,19 @@ class SegmentationService extends PubSubService {
|
||||
}
|
||||
|
||||
const rtDisplaySetUID = rtDisplaySet.displaySetInstanceUID;
|
||||
const referencedDisplaySet = this.servicesManager.services.displaySetService.getDisplaySetByUID(
|
||||
rtDisplaySet.referencedDisplaySetInstanceUID
|
||||
);
|
||||
|
||||
const referencedImageIdsWithGeometry = Array.from(structureSet.ReferencedSOPInstanceUIDsSet);
|
||||
|
||||
const referencedImageIds = referencedDisplaySet.instances.map(image => image.imageId);
|
||||
// find the first image id that contains a referenced SOP instance UID
|
||||
const firstSegmentedSliceImageId = referencedImageIds.find(imageId =>
|
||||
referencedImageIdsWithGeometry.some(referencedId => imageId.includes(referencedId))
|
||||
);
|
||||
|
||||
rtDisplaySet.firstSegmentedSliceImageId = firstSegmentedSliceImageId;
|
||||
// Map ROI contours to RT Struct Data
|
||||
const allRTStructData = mapROIContoursToRTStructData(structureSet, rtDisplaySetUID);
|
||||
|
||||
|
||||
@@ -605,10 +605,6 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
let initialImageIndexToUse =
|
||||
presentations?.positionPresentation?.initialImageIndex ?? initialImageIndex;
|
||||
|
||||
if (initialImageIndexToUse === undefined || initialImageIndexToUse === null) {
|
||||
initialImageIndexToUse = this._getInitialImageIndexForViewport(viewportInfo, imageIds) || 0;
|
||||
}
|
||||
|
||||
const { rotation, flipHorizontal, displayArea } = viewportInfo.getViewportOptions();
|
||||
|
||||
const properties = { ...presentations.lutPresentation?.properties };
|
||||
@@ -637,12 +633,26 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
});
|
||||
|
||||
let imageIdsToSet = imageIds;
|
||||
const res = this._processExtraDisplaySetsForViewport(viewport);
|
||||
imageIdsToSet = res?.imageIds ?? imageIdsToSet;
|
||||
const overlayProcessingResult = this._processExtraDisplaySetsForViewport(viewport);
|
||||
imageIdsToSet = overlayProcessingResult?.imageIds ?? imageIdsToSet;
|
||||
|
||||
const referencedImageId = presentations?.positionPresentation?.viewReference?.referencedImageId;
|
||||
if (referencedImageId) {
|
||||
initialImageIndexToUse = imageIdsToSet.indexOf(referencedImageId);
|
||||
}
|
||||
|
||||
if (initialImageIndexToUse === undefined || initialImageIndexToUse === null) {
|
||||
initialImageIndexToUse = this._getInitialImageIndexForViewport(viewportInfo, imageIds) || 0;
|
||||
}
|
||||
|
||||
return viewport.setStack(imageIdsToSet, initialImageIndexToUse).then(() => {
|
||||
viewport.setProperties({ ...properties });
|
||||
this.setPresentations(viewport.id, presentations, viewportInfo);
|
||||
|
||||
if (overlayProcessingResult?.addOverlayFn) {
|
||||
overlayProcessingResult.addOverlayFn();
|
||||
}
|
||||
|
||||
if (displayArea) {
|
||||
viewport.setDisplayArea(displayArea);
|
||||
}
|
||||
@@ -827,10 +837,14 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
});
|
||||
|
||||
// For SEG and RT viewports
|
||||
this._processExtraDisplaySetsForViewport(viewport);
|
||||
const { addOverlayFn } = this._processExtraDisplaySetsForViewport(viewport) || {};
|
||||
|
||||
await viewport.setVolumes(volumeInputArray);
|
||||
|
||||
if (addOverlayFn) {
|
||||
addOverlayFn();
|
||||
}
|
||||
|
||||
volumesProperties.forEach(({ properties, volumeId }) => {
|
||||
viewport.setProperties(properties, volumeId);
|
||||
});
|
||||
@@ -880,8 +894,12 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
segOrRTSOverlayDisplaySet.referencedDisplaySetInstanceUID
|
||||
);
|
||||
const imageIds = referenceDisplaySet.images.map(image => image.imageId);
|
||||
this.addOverlayRepresentationForDisplaySet(segOrRTSOverlayDisplaySet, viewport);
|
||||
return { imageIds };
|
||||
|
||||
return {
|
||||
imageIds,
|
||||
addOverlayFn: () =>
|
||||
this.addOverlayRepresentationForDisplaySet(segOrRTSOverlayDisplaySet, viewport),
|
||||
};
|
||||
}
|
||||
|
||||
private addOverlayRepresentationForDisplaySet(
|
||||
|
||||
@@ -63,7 +63,7 @@ const defaultProtocol = {
|
||||
// It has no affect if nothing is specified in the URL.
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
weight: 20,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ const defaultDisplaySetSelector = {
|
||||
// It has no affect if nothing is specified in the URL.
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
weight: 20,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
@@ -56,7 +56,7 @@ const priorDisplaySetSelector = {
|
||||
// It has no affect if nothing is specified in the URL.
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
weight: 20,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
|
||||
@@ -50,7 +50,7 @@ const hpMN: Types.HangingProtocol.Protocol = {
|
||||
// It has no affect if nothing is specified in the URL.
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
weight: 20,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ const hpScale: Types.HangingProtocol.Protocol = {
|
||||
// It has no affect if nothing is specified in the URL.
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
weight: 20,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
|
||||
@@ -188,7 +188,7 @@ const hpTestSwitch: Types.HangingProtocol.Protocol = {
|
||||
// It has no affect if nothing is specified in the URL.
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
weight: 20,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user