fix(bugs): Update dependencies and enhance UI components (#4478)
This commit is contained in:
1 parent
61e3a9cb52
commit
05d41c5206
34 files changed
+275
-147
No files matched your search
@@ -46,8 +46,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.1.17",
|
||||
"@cornerstonejs/core": "^2.1.17",
|
||||
"@cornerstonejs/adapters": "^2.2.1",
|
||||
"@cornerstonejs/core": "^2.2.1",
|
||||
"@kitware/vtk.js": "32.1.0",
|
||||
"react-color": "^2.19.3"
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.1.17",
|
||||
"@cornerstonejs/core": "^2.1.17",
|
||||
"@cornerstonejs/adapters": "^2.2.1",
|
||||
"@cornerstonejs/core": "^2.2.1",
|
||||
"@kitware/vtk.js": "32.1.0",
|
||||
"react-color": "^2.19.3"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { LoadingIndicatorTotalPercent, useViewportGrid, ViewportActionArrows } f
|
||||
import createSEGToolGroupAndAddTools from '../utils/initSEGToolGroup';
|
||||
import promptHydrateSEG from '../utils/promptHydrateSEG';
|
||||
import _getStatusComponent from './_getStatusComponent';
|
||||
import { useSegmentationPresentationStore } from '@ohif/extension-cornerstone';
|
||||
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
||||
|
||||
const SEG_TOOLGROUP_BASE_NAME = 'SEGToolGroup';
|
||||
@@ -251,6 +250,14 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) {
|
||||
if (toolGroup) {
|
||||
return;
|
||||
}
|
||||
|
||||
// keep the already stored segmentationPresentation for this viewport in memory
|
||||
// so that we can restore it after hydrating the SEG
|
||||
commandsManager.runCommand('updateStoredSegmentationPresentation', {
|
||||
displaySet: segDisplaySet,
|
||||
type: SegmentationRepresentations.Labelmap,
|
||||
});
|
||||
|
||||
// always start fresh for this viewport since it is special type of viewport
|
||||
// that should only show one segmentation at a time.
|
||||
segmentationService.clearSegmentationRepresentations(viewportId);
|
||||
|
||||
@@ -46,9 +46,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.1.17",
|
||||
"@cornerstonejs/core": "^2.1.17",
|
||||
"@cornerstonejs/tools": "^2.1.17",
|
||||
"@cornerstonejs/adapters": "^2.2.1",
|
||||
"@cornerstonejs/core": "^2.2.1",
|
||||
"@cornerstonejs/tools": "^2.2.1",
|
||||
"classnames": "^2.3.2"
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/core": "^2.1.17",
|
||||
"@cornerstonejs/tools": "^2.1.17",
|
||||
"@cornerstonejs/core": "^2.2.1",
|
||||
"@cornerstonejs/tools": "^2.2.1",
|
||||
"classnames": "^2.3.2"
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@
|
||||
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
|
||||
"@cornerstonejs/codec-openjpeg": "^1.2.4",
|
||||
"@cornerstonejs/codec-openjph": "^2.4.5",
|
||||
"@cornerstonejs/dicom-image-loader": "^2.1.17",
|
||||
"@cornerstonejs/dicom-image-loader": "^2.2.1",
|
||||
"@icr/polyseg-wasm": "^0.4.0",
|
||||
"@ohif/core": "3.9.0-beta.109",
|
||||
"@ohif/ui": "3.9.0-beta.109",
|
||||
@@ -55,9 +55,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.1.17",
|
||||
"@cornerstonejs/core": "^2.1.17",
|
||||
"@cornerstonejs/tools": "^2.1.17",
|
||||
"@cornerstonejs/adapters": "^2.2.1",
|
||||
"@cornerstonejs/core": "^2.2.1",
|
||||
"@cornerstonejs/tools": "^2.2.1",
|
||||
"@icr/polyseg-wasm": "^0.4.0",
|
||||
"@kitware/vtk.js": "32.1.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
|
||||
@@ -111,16 +111,14 @@ function commandsModule({
|
||||
commandsManager.run(options, optionsToUse);
|
||||
},
|
||||
updateStoredSegmentationPresentation: ({ displaySet, type }) => {
|
||||
const { setSegmentationPresentation } = useSegmentationPresentationStore.getState();
|
||||
const { addSegmentationPresentationItem } = useSegmentationPresentationStore.getState();
|
||||
|
||||
const referencedDisplaySetInstanceUID = displaySet.referencedDisplaySetInstanceUID;
|
||||
setSegmentationPresentation(referencedDisplaySetInstanceUID, [
|
||||
{
|
||||
segmentationId: displaySet.displaySetInstanceUID,
|
||||
hydrated: true,
|
||||
type,
|
||||
},
|
||||
]);
|
||||
addSegmentationPresentationItem(referencedDisplaySetInstanceUID, {
|
||||
segmentationId: displaySet.displaySetInstanceUID,
|
||||
hydrated: true,
|
||||
type,
|
||||
});
|
||||
},
|
||||
updateStoredPositionPresentation: ({ viewportId, displaySetInstanceUID }) => {
|
||||
const presentations = cornerstoneViewportService.getPresentations(viewportId);
|
||||
@@ -1043,7 +1041,7 @@ function commandsModule({
|
||||
* @param props.key - The style key to set
|
||||
* @param props.value - The style value
|
||||
*/
|
||||
setSegmentationStyleCommand: ({ segmentationId, type, key, value }) => {
|
||||
setSegmentationStyleCommand: ({ type, key, value }) => {
|
||||
const { segmentationService } = servicesManager.services;
|
||||
segmentationService.setStyle({ type }, { [key]: value });
|
||||
},
|
||||
@@ -1150,12 +1148,17 @@ function commandsModule({
|
||||
const segment = segmentation.segments[segmentIndex];
|
||||
const { label } = segment;
|
||||
|
||||
callInputDialog(uiDialogService, label, (label, actionId) => {
|
||||
const callback = (label, actionId) => {
|
||||
if (label === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
segmentationService.setSegmentLabel(segmentationId, segmentIndex, label);
|
||||
};
|
||||
|
||||
callInputDialog(uiDialogService, label, callback, false, {
|
||||
dialogTitle: 'Edit Segment Label',
|
||||
inputLabel: 'Enter new label',
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1169,12 +1172,17 @@ function commandsModule({
|
||||
|
||||
const { label } = segmentation;
|
||||
|
||||
callInputDialog(uiDialogService, label, (label, actionId) => {
|
||||
const callback = (label, actionId) => {
|
||||
if (label === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
segmentationService.addOrUpdateSegmentation({ segmentationId, label });
|
||||
};
|
||||
|
||||
callInputDialog(uiDialogService, label, callback, false, {
|
||||
dialogTitle: 'Edit Segmentation Label',
|
||||
inputLabel: 'Enter new label',
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import { metaData } from '@cornerstonejs/core';
|
||||
export default function PanelSegmentation({
|
||||
servicesManager,
|
||||
commandsManager,
|
||||
extensionManager,
|
||||
configuration,
|
||||
children,
|
||||
}: withAppTypes) {
|
||||
const { customizationService, viewportGridService, displaySetService } = servicesManager.services;
|
||||
@@ -91,23 +89,23 @@ export default function PanelSegmentation({
|
||||
commandsManager.run('deleteSegmentation', { segmentationId });
|
||||
},
|
||||
|
||||
setFillAlpha: (type, value) => {
|
||||
setFillAlpha: ({ type }, value) => {
|
||||
commandsManager.run('setFillAlpha', { type, value });
|
||||
},
|
||||
|
||||
setOutlineWidth: (type, value) => {
|
||||
setOutlineWidth: ({ type }, value) => {
|
||||
commandsManager.run('setOutlineWidth', { type, value });
|
||||
},
|
||||
|
||||
setRenderFill: (type, value) => {
|
||||
setRenderFill: ({ type }, value) => {
|
||||
commandsManager.run('setRenderFill', { type, value });
|
||||
},
|
||||
|
||||
setRenderOutline: (type, value) => {
|
||||
setRenderOutline: ({ type }, value) => {
|
||||
commandsManager.run('setRenderOutline', { type, value });
|
||||
},
|
||||
|
||||
setFillAlphaInactive: (type, value) => {
|
||||
setFillAlphaInactive: ({ type }, value) => {
|
||||
commandsManager.run('setFillAlphaInactive', { type, value });
|
||||
},
|
||||
|
||||
@@ -152,6 +150,14 @@ export default function PanelSegmentation({
|
||||
const exportOptions = segmentationsWithRepresentations.map(({ segmentation }) => {
|
||||
const { representationData, segmentationId } = segmentation;
|
||||
const { Labelmap } = representationData;
|
||||
|
||||
if (!Labelmap) {
|
||||
return {
|
||||
segmentationId,
|
||||
isExportable: true,
|
||||
};
|
||||
}
|
||||
|
||||
const referencedImageIds = Labelmap.referencedImageIds;
|
||||
const firstImageId = referencedImageIds[0];
|
||||
|
||||
|
||||
@@ -100,10 +100,16 @@ class SegmentationService extends PubSubService {
|
||||
this._segmentationIdToColorLUTIndexMap = new Map();
|
||||
|
||||
this.servicesManager = servicesManager;
|
||||
}
|
||||
|
||||
public onModeEnter(): void {
|
||||
this._initSegmentationService();
|
||||
}
|
||||
|
||||
public onModeExit(): void {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a segmentation by its ID.
|
||||
*
|
||||
@@ -1386,7 +1392,11 @@ class SegmentationService extends PubSubService {
|
||||
const frameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
||||
const segImage = cache.getImage(imageIds[0]);
|
||||
|
||||
if (segImage?.FrameOfReferenceUID === frameOfReferenceUID) {
|
||||
if (
|
||||
segImage?.FrameOfReferenceUID &&
|
||||
frameOfReferenceUID &&
|
||||
segImage.FrameOfReferenceUID === frameOfReferenceUID
|
||||
) {
|
||||
const isConverted = await this.convertStackToVolumeViewport(viewport);
|
||||
triggerSegmentationRepresentationModified(
|
||||
viewportId,
|
||||
|
||||
@@ -763,6 +763,10 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
});
|
||||
}
|
||||
|
||||
if (!volumesNotLoaded.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This returns the async continuation only
|
||||
return this.setVolumesForViewport(viewport, volumeInputArray, presentations);
|
||||
}
|
||||
@@ -1114,8 +1118,8 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
|
||||
const { segmentationService } = this.servicesManager.services;
|
||||
|
||||
segmentationPresentation.forEach((presentation: SegmentationPresentationItem) => {
|
||||
const { segmentationId, type, hydrated } = presentation;
|
||||
segmentationPresentation.forEach((presentationItem: SegmentationPresentationItem) => {
|
||||
const { segmentationId, type, hydrated } = presentationItem;
|
||||
|
||||
if (hydrated) {
|
||||
segmentationService.addSegmentationRepresentation(viewport.id, {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
import { SegmentationPresentation } from '../types/Presentation';
|
||||
import { SegmentationPresentation, SegmentationPresentationItem } from '../types/Presentation';
|
||||
import { JOIN_STR } from './presentationUtils';
|
||||
import { getViewportOrientationFromImageOrientationPatient } from '../utils/getViewportOrientationFromImageOrientationPatient';
|
||||
|
||||
@@ -62,10 +62,9 @@ type SegmentationPresentationStore = {
|
||||
* @param segmentationPresentation - The `SegmentationPresentation` to add.
|
||||
* @param servicesManager - The services manager instance.
|
||||
*/
|
||||
addSegmentationPresentation: (
|
||||
addSegmentationPresentationItem: (
|
||||
presentationId: string,
|
||||
segmentationPresentation: SegmentationPresentation,
|
||||
{ servicesManager }: { servicesManager: AppTypes.ServicesManager }
|
||||
segmentationPresentationItem: SegmentationPresentationItem
|
||||
) => void;
|
||||
|
||||
/**
|
||||
@@ -183,33 +182,52 @@ const createSegmentationPresentationStore = set => ({
|
||||
set({ segmentationPresentationStore: {} }, false, 'clearSegmentationPresentationStore'),
|
||||
|
||||
/**
|
||||
* Adds a new segmentation presentation to the store.
|
||||
* Adds a new segmentation presentation item to the store.
|
||||
*
|
||||
* segmentationPresentationItem: {
|
||||
* segmentationId: string;
|
||||
* type: SegmentationRepresentations;
|
||||
* hydrated: boolean | null;
|
||||
* config?: unknown;
|
||||
* }
|
||||
*/
|
||||
addSegmentationPresentation: (
|
||||
addSegmentationPresentationItem: (
|
||||
presentationId: string,
|
||||
segmentationPresentation: SegmentationPresentation,
|
||||
{ servicesManager }: { servicesManager: AppTypes.ServicesManager }
|
||||
segmentationPresentationItem: SegmentationPresentationItem
|
||||
) =>
|
||||
set(
|
||||
state => ({
|
||||
segmentationPresentationStore: {
|
||||
...state.segmentationPresentationStore,
|
||||
[presentationId]: segmentationPresentation,
|
||||
[presentationId]: [
|
||||
...(state.segmentationPresentationStore[presentationId] || []),
|
||||
segmentationPresentationItem,
|
||||
],
|
||||
},
|
||||
}),
|
||||
false,
|
||||
'addSegmentationPresentation'
|
||||
'addSegmentationPresentationItem'
|
||||
),
|
||||
|
||||
/**
|
||||
* Sets the segmentation presentation for a given presentation ID.
|
||||
* Sets the segmentation presentation for a given presentation ID. A segmentation
|
||||
* presentation is an array of SegmentationPresentationItem.
|
||||
*
|
||||
* segmentationPresentationItem: {
|
||||
* segmentationId: string;
|
||||
* type: SegmentationRepresentations;
|
||||
* hydrated: boolean | null;
|
||||
* config?: unknown;
|
||||
* }
|
||||
*
|
||||
* segmentationPresentation: SegmentationPresentationItem[]
|
||||
*/
|
||||
setSegmentationPresentation: (presentationId: string, value: SegmentationPresentation) =>
|
||||
setSegmentationPresentation: (presentationId: string, values: SegmentationPresentation) =>
|
||||
set(
|
||||
state => ({
|
||||
segmentationPresentationStore: {
|
||||
...state.segmentationPresentationStore,
|
||||
[presentationId]: value,
|
||||
[presentationId]: values,
|
||||
},
|
||||
}),
|
||||
false,
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ import getDisplayUnit from './getDisplayUnit';
|
||||
export const getStatisticDisplayString = (numbers, unit, key) => {
|
||||
if (Array.isArray(numbers) && numbers.length > 0) {
|
||||
const results = numbers.map(number => utils.roundNumber(number, 2));
|
||||
return `${key.charAt(0).toUpperCase() + key.slice(1)}: ${results.join(', ')} <small>${getDisplayUnit(unit)}</small>`;
|
||||
return `${key.charAt(0).toUpperCase() + key.slice(1)}: ${results.join(', ')} ${getDisplayUnit(unit)}`;
|
||||
}
|
||||
|
||||
const result = utils.roundNumber(numbers, 2);
|
||||
return `${key.charAt(0).toUpperCase() + key.slice(1)}: ${result} <small>${getDisplayUnit(unit)}</small>`;
|
||||
return `${key.charAt(0).toUpperCase() + key.slice(1)}: ${result} ${getDisplayUnit(unit)}`;
|
||||
};
|
||||
@@ -23,16 +23,26 @@ const SidePanelWithServices = ({
|
||||
|
||||
// Tracks whether this SidePanel has been opened at least once since this SidePanel was inserted into the DOM.
|
||||
// Thus going to the Study List page and back to the viewer resets this flag for a SidePanel.
|
||||
const [hasBeenOpened, setHasBeenOpened] = useState(false);
|
||||
const [sidePanelOpen, setSidePanelOpen] = useState(activeTabIndexProp !== null);
|
||||
const [activeTabIndex, setActiveTabIndex] = useState(activeTabIndexProp);
|
||||
const [tabs, setTabs] = useState(tabsProp ?? panelService.getPanels(side));
|
||||
|
||||
const handleSidePanelOpen = useCallback(() => {
|
||||
setHasBeenOpened(true);
|
||||
}, []);
|
||||
|
||||
const handleActiveTabIndexChange = useCallback(({ activeTabIndex }) => {
|
||||
setActiveTabIndex(activeTabIndex);
|
||||
setSidePanelOpen(activeTabIndex !== null);
|
||||
}, []);
|
||||
|
||||
const handleOpen = useCallback(() => {
|
||||
setSidePanelOpen(true);
|
||||
// If panel is being opened but no tab is active, set first tab as active
|
||||
if (activeTabIndex === null && tabs.length > 0) {
|
||||
setActiveTabIndex(0);
|
||||
}
|
||||
}, [activeTabIndex, tabs]);
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
setSidePanelOpen(false);
|
||||
setActiveTabIndex(null);
|
||||
}, []);
|
||||
|
||||
/** update the active tab index from outside */
|
||||
@@ -61,7 +71,7 @@ const SidePanelWithServices = ({
|
||||
const activatePanelSubscription = panelService.subscribe(
|
||||
panelService.EVENTS.ACTIVATE_PANEL,
|
||||
(activatePanelEvent: Types.ActivatePanelEvent) => {
|
||||
if (!hasBeenOpened || activatePanelEvent.forceActive) {
|
||||
if (sidePanelOpen || activatePanelEvent.forceActive) {
|
||||
const tabIndex = tabs.findIndex(tab => tab.id === activatePanelEvent.panelId);
|
||||
if (tabIndex !== -1) {
|
||||
setActiveTabIndex(tabIndex);
|
||||
@@ -73,7 +83,7 @@ const SidePanelWithServices = ({
|
||||
return () => {
|
||||
activatePanelSubscription.unsubscribe();
|
||||
};
|
||||
}, [tabs, hasBeenOpened, panelService]);
|
||||
}, [tabs, sidePanelOpen, panelService]);
|
||||
|
||||
return (
|
||||
<SidePanel
|
||||
@@ -81,10 +91,11 @@ const SidePanelWithServices = ({
|
||||
side={side}
|
||||
tabs={tabs}
|
||||
activeTabIndex={activeTabIndex}
|
||||
onOpen={handleSidePanelOpen}
|
||||
onOpen={handleOpen}
|
||||
onClose={handleClose}
|
||||
onActiveTabIndexChange={handleActiveTabIndexChange}
|
||||
expandedWidth={expandedWidth}
|
||||
></SidePanel>
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
"start": "yarn run dev"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@cornerstonejs/core": "^2.1.17",
|
||||
"@cornerstonejs/tools": "^2.1.17",
|
||||
"@cornerstonejs/core": "^2.2.1",
|
||||
"@cornerstonejs/tools": "^2.2.1",
|
||||
"@ohif/core": "3.9.0-beta.109",
|
||||
"@ohif/extension-cornerstone-dicom-sr": "3.9.0-beta.109",
|
||||
"@ohif/extension-default": "3.9.0-beta.109",
|
||||
|
||||
@@ -98,6 +98,9 @@ function TrackedCornerstoneViewport(
|
||||
useEffect(() => {
|
||||
if (isTracked) {
|
||||
annotation.config.style.setViewportToolStyles(viewportId, {
|
||||
ReferenceLines: {
|
||||
lineDash: '4,4',
|
||||
},
|
||||
global: {
|
||||
lineDash: '',
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user