@ohif/extension-cornerstone 3.14.0-beta.97 → 3.14.0-beta.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/915.ohif-extension-cornerstone.umd.js +1 -1
- package/dist/ohif-extension-cornerstone.umd.js +1 -5
- package/package.json +18 -8
- package/src/Viewport/OHIFCornerstoneViewport.css +46 -0
- package/src/Viewport/OHIFCornerstoneViewport.tsx +502 -0
- package/src/Viewport/Overlays/CornerstoneOverlays.tsx +103 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.css +25 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.tsx +469 -0
- package/src/Viewport/Overlays/ViewportImageScrollbar.tsx +106 -0
- package/src/Viewport/Overlays/ViewportImageSliceLoadingIndicator.tsx +87 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.css +41 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.tsx +136 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/ViewportSliceProgressScrollbar.tsx +195 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/helpers.ts +46 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/hooks.ts +383 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/index.ts +1 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/types.ts +17 -0
- package/src/Viewport/Overlays/utils.ts +66 -0
- package/src/commandsModule.ts +2951 -0
- package/src/components/AccordionGroup/AccordionGroup.tsx +195 -0
- package/src/components/AccordionGroup/index.ts +4 -0
- package/src/components/ActiveViewportWindowLevel/ActiveViewportWindowLevel.tsx +23 -0
- package/src/components/ActiveViewportWindowLevel/index.js +1 -0
- package/src/components/AdvancedRenderingControls/AdvancedRenderingControls.tsx +149 -0
- package/src/components/AdvancedRenderingControls/index.ts +1 -0
- package/src/components/CinePlayer/CinePlayer.tsx +247 -0
- package/src/components/CinePlayer/index.ts +3 -0
- package/src/components/DicomUpload/DicomUpload.tsx +111 -0
- package/src/components/DicomUpload/DicomUploadProgress.tsx +396 -0
- package/src/components/DicomUpload/DicomUploadProgressItem.tsx +119 -0
- package/src/components/ExportSegmentationSubMenuItem.tsx +75 -0
- package/src/components/MeasurementItems.tsx +70 -0
- package/src/components/MeasurementTableNested.tsx +30 -0
- package/src/components/MeasurementsMenu.tsx +84 -0
- package/src/components/MeasurementsOrAdditionalFindings.tsx +82 -0
- package/src/components/ModalityLoadBadge/ModalityLoadBadge.tsx +171 -0
- package/src/components/ModalityLoadBadge/index.ts +1 -0
- package/src/components/NavigationComponent/NavigationComponent.tsx +138 -0
- package/src/components/NavigationComponent/index.ts +3 -0
- package/src/components/OHIFViewportActionCorners.tsx +94 -0
- package/src/components/OpacityMenu/OpacityMenu.tsx +54 -0
- package/src/components/OpacityMenu/OpacityMenuWrapper.tsx +85 -0
- package/src/components/OpacityMenu/index.ts +2 -0
- package/src/components/PanelAccordionTrigger.tsx +48 -0
- package/src/components/SegmentationToolConfig.tsx +71 -0
- package/src/components/SegmentationUtilityButton.tsx +61 -0
- package/src/components/SelectItemWithModality.tsx +29 -0
- package/src/components/SeriesMeasurements.tsx +90 -0
- package/src/components/SeriesSummaryFromDisplaySet.tsx +21 -0
- package/src/components/StudyMeasurements.tsx +88 -0
- package/src/components/StudyMeasurementsActions.tsx +75 -0
- package/src/components/StudySummaryFromMetadata.test.ts +47 -0
- package/src/components/StudySummaryFromMetadata.tsx +31 -0
- package/src/components/StudySummaryWithActions.tsx +14 -0
- package/src/components/ThresholdMenu/ThresholdMenu.tsx +104 -0
- package/src/components/ThresholdMenu/ThresholdMenuWrapper.tsx +85 -0
- package/src/components/ThresholdMenu/index.ts +2 -0
- package/src/components/TrackingStatus/TrackingStatus.tsx +32 -0
- package/src/components/TrackingStatus/index.ts +1 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenu.tsx +190 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenuWrapper.tsx +85 -0
- package/src/components/VOIManualControlMenu/index.ts +2 -0
- package/src/components/ViewportColorbar/ViewportColorbar.tsx +150 -0
- package/src/components/ViewportColorbar/ViewportColorbarsContainer.tsx +125 -0
- package/src/components/ViewportColorbar/index.ts +5 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenu.tsx +538 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenuWrapper.tsx +91 -0
- package/src/components/ViewportDataOverlaySettingMenu/utils.ts +118 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenu.tsx +249 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +29 -0
- package/src/components/ViewportWindowLevel/ViewportWindowLevel.tsx +261 -0
- package/src/components/ViewportWindowLevel/getViewportVolumeHistogram.ts +72 -0
- package/src/components/ViewportWindowLevel/histogramWorker.js +97 -0
- package/src/components/ViewportWindowLevel/index.js +1 -0
- package/src/components/ViewportWindowLevel/utils.ts +176 -0
- package/src/components/WindowLevelActionMenu/Colorbar.tsx +30 -0
- package/src/components/WindowLevelActionMenu/Colormap.tsx +121 -0
- package/src/components/WindowLevelActionMenu/VolumeLighting.tsx +82 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingOptions.tsx +38 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresets.tsx +36 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresetsContent.tsx +78 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingQuality.tsx +64 -0
- package/src/components/WindowLevelActionMenu/VolumeShade.tsx +47 -0
- package/src/components/WindowLevelActionMenu/VolumeShift.tsx +92 -0
- package/src/components/WindowLevelActionMenu/WindowLevel.tsx +157 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx +102 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenuWrapper.tsx +131 -0
- package/src/components/WindowLevelActionMenu/defaultWindowLevelPresets.ts +23 -0
- package/src/components/WindowLevelActionMenu/index.ts +11 -0
- package/src/components/WindowLevelActionMenu/windowLevelPresetHotkeys.test.ts +19 -0
- package/src/components/index.ts +12 -0
- package/src/constants/index.ts +13 -0
- package/src/customizations/CustomDropdownMenuContent.tsx +106 -0
- package/src/customizations/CustomSegmentStatisticsHeader.tsx +140 -0
- package/src/customizations/captureViewportModalCustomization.tsx +175 -0
- package/src/customizations/colorbarCustomization.ts +93 -0
- package/src/customizations/gpuSettingsPresetCustomization.ts +8 -0
- package/src/customizations/layoutSelectorCustomization.ts +104 -0
- package/src/customizations/measurementsCustomization.ts +124 -0
- package/src/customizations/miscCustomization.ts +22 -0
- package/src/customizations/modalityColorMapCustomization.ts +23 -0
- package/src/customizations/segmentationHydrationCustomization.ts +16 -0
- package/src/customizations/segmentationPanelCustomization.tsx +119 -0
- package/src/customizations/segmentationToolbarCustomization.ts +964 -0
- package/src/customizations/toolGroupToolsCustomization.ts +204 -0
- package/src/customizations/toolbarButtonsCustomization.ts +805 -0
- package/src/customizations/viewportClickCommandsCustomization.ts +15 -0
- package/src/customizations/viewportDownloadWarningCustomization.tsx +6 -0
- package/src/customizations/viewportOverlayCustomization.tsx +46 -0
- package/src/customizations/viewportScrollbarCustomization.tsx +27 -0
- package/src/customizations/viewportToolsCustomization.ts +33 -0
- package/src/customizations/volumeRenderingCustomization.ts +14 -0
- package/src/customizations/windowLevelPresetsCustomization.ts +5 -0
- package/src/enums.ts +9 -0
- package/src/getCustomizationModule.tsx +54 -0
- package/src/getHangingProtocolModule.ts +47 -0
- package/src/getPanelModule.tsx +128 -0
- package/src/getSopClassHandlerModule.js +284 -0
- package/src/getToolbarModule.tsx +622 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActiveViewportSegmentationRepresentations.ts +14 -0
- package/src/hooks/useMeasurementTracking.ts +132 -0
- package/src/hooks/useMeasurements.ts +104 -0
- package/src/hooks/useSegmentations.ts +147 -0
- package/src/hooks/useViewportDisplaySets.ts +284 -0
- package/src/hooks/useViewportHover.ts +77 -0
- package/src/hooks/useViewportRendering.tsx +868 -0
- package/src/hooks/useViewportSegmentations.ts +245 -0
- package/src/hps/fourUp.ts +117 -0
- package/src/hps/frameView.ts +1581 -0
- package/src/hps/main3D.ts +142 -0
- package/src/hps/mpr.ts +197 -0
- package/src/hps/mprAnd3DVolumeViewport.ts +124 -0
- package/src/hps/only3D.ts +70 -0
- package/src/hps/primary3D.ts +142 -0
- package/src/hps/primaryAxial.ts +114 -0
- package/src/id.js +5 -0
- package/src/index.tsx +350 -0
- package/src/init.tsx +445 -0
- package/src/initCineService.ts +75 -0
- package/src/initContextMenu.ts +94 -0
- package/src/initCornerstoneTools.js +188 -0
- package/src/initDoubleClick.ts +82 -0
- package/src/initMeasurementService.ts +576 -0
- package/src/initStudyPrefetcherService.ts +33 -0
- package/src/initWADOImageLoader.js +56 -0
- package/src/panels/PanelMeasurement.tsx +84 -0
- package/src/panels/PanelSegmentation.tsx +338 -0
- package/src/services/ColorbarService/ColorbarService.ts +242 -0
- package/src/services/ColorbarService/index.ts +2 -0
- package/src/services/CornerstoneCacheService/CornerstoneCacheService.ts +326 -0
- package/src/services/CornerstoneCacheService/index.js +3 -0
- package/src/services/SegmentationService/RTSTRUCT/mapROIContoursToRTStructData.ts +36 -0
- package/src/services/SegmentationService/SegmentationService.test.ts +3698 -0
- package/src/services/SegmentationService/SegmentationService.ts +2376 -0
- package/src/services/SegmentationService/backends/ISegmentationBackend.ts +102 -0
- package/src/services/SegmentationService/backends/ISegmentationServiceInternals.ts +44 -0
- package/src/services/SegmentationService/backends/LegacySegmentationBackend.ts +139 -0
- package/src/services/SegmentationService/backends/NextSegmentationBackend.ts +159 -0
- package/src/services/SegmentationService/backends/index.ts +4 -0
- package/src/services/SegmentationService/index.ts +3 -0
- package/src/services/SyncGroupService/SyncGroupService.ts +264 -0
- package/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts +118 -0
- package/src/services/SyncGroupService/index.js +3 -0
- package/src/services/ToolGroupService/ToolGroupService.test.ts +83 -0
- package/src/services/ToolGroupService/ToolGroupService.ts +541 -0
- package/src/services/ToolGroupService/index.js +3 -0
- package/src/services/ViewedDataService/ViewedDataService.ts +58 -0
- package/src/services/ViewedDataService/index.ts +3 -0
- package/src/services/ViewportService/CornerstoneViewportService.ts +1814 -0
- package/src/services/ViewportService/IViewportService.ts +64 -0
- package/src/services/ViewportService/Viewport.ts +372 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.contract.test.ts +467 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.ts +179 -0
- package/src/services/ViewportService/adapter/LegacyViewportAdapter.ts +240 -0
- package/src/services/ViewportService/adapter/NextViewportAdapter.ts +241 -0
- package/src/services/ViewportService/adapter/getViewportAdapter.ts +62 -0
- package/src/services/ViewportService/adapter/index.ts +16 -0
- package/src/services/ViewportService/backends/IViewportBackend.ts +195 -0
- package/src/services/ViewportService/backends/IViewportOperations.ts +98 -0
- package/src/services/ViewportService/backends/IViewportServiceInternals.ts +47 -0
- package/src/services/ViewportService/backends/LegacyViewportBackend.ts +264 -0
- package/src/services/ViewportService/backends/LegacyViewportOperations.ts +272 -0
- package/src/services/ViewportService/backends/NextViewportBackend.ts +671 -0
- package/src/services/ViewportService/backends/NextViewportOperations.ts +169 -0
- package/src/services/ViewportService/backends/README.md +62 -0
- package/src/services/ViewportService/backends/dataIdRegistry.ts +121 -0
- package/src/services/ViewportService/backends/viewportOperations.ts +71 -0
- package/src/services/ViewportService/constants.ts +3 -0
- package/src/state.ts +34 -0
- package/src/stores/index.ts +5 -0
- package/src/stores/presentationUtils.ts +42 -0
- package/src/stores/useLutPresentationStore.ts +166 -0
- package/src/stores/usePositionPresentationStore.ts +172 -0
- package/src/stores/useSegmentationPresentationStore.test.ts +146 -0
- package/src/stores/useSegmentationPresentationStore.ts +417 -0
- package/src/stores/useSelectedSegmentationsForViewportStore.ts +85 -0
- package/src/stores/useSynchronizersStore.ts +84 -0
- package/src/synchronizers/frameViewSynchronizer.ts +52 -0
- package/src/tools/CalibrationLineTool.ts +97 -0
- package/src/tools/ImageOverlayViewerTool.tsx +279 -0
- package/src/tools/OverlayPlaneModuleProvider.ts +40 -0
- package/src/tools/WindowLevelTool.test.ts +55 -0
- package/src/tools/WindowLevelTool.ts +22 -0
- package/src/types/AppTypes.ts +70 -0
- package/src/types/Colorbar.ts +114 -0
- package/src/types/Colormap.ts +16 -0
- package/src/types/CornerstoneCacheService.ts +40 -0
- package/src/types/CornerstoneServices.ts +18 -0
- package/src/types/Presentation.ts +83 -0
- package/src/types/SelectedSegmentationByTypeMap.ts +3 -0
- package/src/types/ViewportPresets.ts +53 -0
- package/src/types/VolumeLighting.ts +7 -0
- package/src/types/VolumeRenderingConfig.ts +8 -0
- package/src/types/WindowLevel.ts +5 -0
- package/src/types/index.ts +10 -0
- package/src/utils/ActiveViewportBehavior.tsx +80 -0
- package/src/utils/CornerstoneViewportDownloadForm.tsx +319 -0
- package/src/utils/DicomFileUploader.ts +204 -0
- package/src/utils/JumpPresets.ts +14 -0
- package/src/utils/autoHydrateViewportTypes.ts +69 -0
- package/src/utils/colormaps.js +1597 -0
- package/src/utils/createSegmentationForViewport.ts +83 -0
- package/src/utils/dicomLoaderService.js +225 -0
- package/src/utils/ecgMetadata.test.ts +137 -0
- package/src/utils/ecgMetadata.ts +109 -0
- package/src/utils/findNearbyToolData.test.ts +125 -0
- package/src/utils/findNearbyToolData.ts +21 -0
- package/src/utils/generateSegmentationCSVReport.test.ts +324 -0
- package/src/utils/generateSegmentationCSVReport.ts +131 -0
- package/src/utils/getActiveViewportEnabledElement.test.ts +70 -0
- package/src/utils/getActiveViewportEnabledElement.ts +8 -0
- package/src/utils/getCenterExtent.test.ts +313 -0
- package/src/utils/getCenterExtent.ts +46 -0
- package/src/utils/getCornerstoneBlendMode.test.ts +59 -0
- package/src/utils/getCornerstoneBlendMode.ts +25 -0
- package/src/utils/getCornerstoneOrientation.test.ts +78 -0
- package/src/utils/getCornerstoneOrientation.ts +31 -0
- package/src/utils/getCornerstoneViewportType.test.ts +169 -0
- package/src/utils/getCornerstoneViewportType.ts +88 -0
- package/src/utils/getInterleavedFrames.test.ts +85 -0
- package/src/utils/getInterleavedFrames.ts +73 -0
- package/src/utils/getLegacyViewportType.ts +64 -0
- package/src/utils/getNthFrames.test.ts +145 -0
- package/src/utils/getNthFrames.ts +31 -0
- package/src/utils/getViewportEnabledElement.test.ts +83 -0
- package/src/utils/getViewportEnabledElement.ts +8 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.test.ts +50 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.ts +56 -0
- package/src/utils/hydrationUtils.test.ts +572 -0
- package/src/utils/hydrationUtils.ts +197 -0
- package/src/utils/imageSliceSync/calculateViewportRegistrations.ts +28 -0
- package/src/utils/imageSliceSync/toggleImageSliceSync.ts +101 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/initGpuSettingsPreset.ts +51 -0
- package/src/utils/initViewTiming.test.ts +342 -0
- package/src/utils/initViewTiming.ts +52 -0
- package/src/utils/initWebWorkerProgressHandler.test.ts +381 -0
- package/src/utils/initWebWorkerProgressHandler.ts +110 -0
- package/src/utils/interleave.test.ts +304 -0
- package/src/utils/interleave.ts +32 -0
- package/src/utils/interleaveCenterLoader.test.ts +547 -0
- package/src/utils/interleaveCenterLoader.ts +143 -0
- package/src/utils/interleaveTopToBottom.test.ts +487 -0
- package/src/utils/interleaveTopToBottom.ts +132 -0
- package/src/utils/isAnyDisplaySetCommon.ts +18 -0
- package/src/utils/isDisplaySetOverlayable.ts +96 -0
- package/src/utils/isMeasurementWithinViewport.test.ts +340 -0
- package/src/utils/isMeasurementWithinViewport.ts +33 -0
- package/src/utils/isReferenceViewable.test.ts +581 -0
- package/src/utils/isReferenceViewable.ts +95 -0
- package/src/utils/loadDisplaySetData.ts +49 -0
- package/src/utils/measurementServiceMappings/Angle.ts +200 -0
- package/src/utils/measurementServiceMappings/ArrowAnnotate.ts +176 -0
- package/src/utils/measurementServiceMappings/Bidirectional.ts +193 -0
- package/src/utils/measurementServiceMappings/CircleROI.ts +227 -0
- package/src/utils/measurementServiceMappings/CobbAngle.ts +206 -0
- package/src/utils/measurementServiceMappings/EllipticalROI.ts +221 -0
- package/src/utils/measurementServiceMappings/Length.ts +206 -0
- package/src/utils/measurementServiceMappings/LivewireContour.ts +175 -0
- package/src/utils/measurementServiceMappings/PlanarFreehandROI.ts +228 -0
- package/src/utils/measurementServiceMappings/Probe.ts +192 -0
- package/src/utils/measurementServiceMappings/RectangleROI.ts +225 -0
- package/src/utils/measurementServiceMappings/SegmentBidirectional.ts +184 -0
- package/src/utils/measurementServiceMappings/SplineROI.ts +227 -0
- package/src/utils/measurementServiceMappings/UltrasoundDirectional.ts +214 -0
- package/src/utils/measurementServiceMappings/UltrasoundPleuraBLine.ts +179 -0
- package/src/utils/measurementServiceMappings/constants/supportedTools.js +21 -0
- package/src/utils/measurementServiceMappings/index.ts +3 -0
- package/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts +324 -0
- package/src/utils/measurementServiceMappings/utils/getDisplayUnit.js +3 -0
- package/src/utils/measurementServiceMappings/utils/getHandlesFromPoints.js +14 -0
- package/src/utils/measurementServiceMappings/utils/getIsLocked.ts +5 -0
- package/src/utils/measurementServiceMappings/utils/getIsVisible.ts +6 -0
- package/src/utils/measurementServiceMappings/utils/getSOPInstanceAttributes.js +66 -0
- package/src/utils/measurementServiceMappings/utils/getValueDisplayString.js +12 -0
- package/src/utils/measurementServiceMappings/utils/index.ts +17 -0
- package/src/utils/measurementServiceMappings/utils/selection.ts +33 -0
- package/src/utils/mpr/getProtocolViewportStructureFromGridViewports.ts +74 -0
- package/src/utils/nextViewportPolicies.ts +41 -0
- package/src/utils/nextViewports.ts +157 -0
- package/src/utils/nthLoader.test.ts +317 -0
- package/src/utils/nthLoader.ts +78 -0
- package/src/utils/presentations/getViewportPresentations.test.ts +280 -0
- package/src/utils/presentations/getViewportPresentations.ts +151 -0
- package/src/utils/promptHydrationDialog.test.ts +490 -0
- package/src/utils/promptHydrationDialog.ts +197 -0
- package/src/utils/removeViewportSegmentationRepresentations.test.ts +129 -0
- package/src/utils/removeViewportSegmentationRepresentations.ts +17 -0
- package/src/utils/segmentUtils.test.ts +515 -0
- package/src/utils/segmentUtils.ts +46 -0
- package/src/utils/segmentationExportUtils.test.ts +100 -0
- package/src/utils/segmentationExportUtils.ts +171 -0
- package/src/utils/segmentationHandlers.test.ts +614 -0
- package/src/utils/segmentationHandlers.ts +164 -0
- package/src/utils/setUpAnnotationEventHandlers.ts +26 -0
- package/src/utils/setUpSegmentationEventHandlers.test.ts +372 -0
- package/src/utils/setUpSegmentationEventHandlers.ts +122 -0
- package/src/utils/toggleVOISliceSync.test.ts +606 -0
- package/src/utils/toggleVOISliceSync.ts +103 -0
- package/src/utils/transitions.test.ts +351 -0
- package/src/utils/transitions.ts +300 -0
- package/src/utils/updateSegmentationStats.test.ts +942 -0
- package/src/utils/updateSegmentationStats.ts +192 -0
- package/src/utils/viewportDataShape.ts +85 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import debounce from 'lodash.debounce';
|
|
3
|
+
import { roundNumber } from '@ohif/core/src/utils';
|
|
4
|
+
import {
|
|
5
|
+
SegmentationData,
|
|
6
|
+
SegmentationRepresentation,
|
|
7
|
+
} from '../services/SegmentationService/SegmentationService';
|
|
8
|
+
import { useSystem } from '@ohif/core';
|
|
9
|
+
const excludedModalities = ['SM', 'OT', 'DOC', 'ECG'];
|
|
10
|
+
|
|
11
|
+
function mapSegmentationToDisplay(segmentation, customizationService) {
|
|
12
|
+
const { label, segments, fallbackLabel } = segmentation;
|
|
13
|
+
|
|
14
|
+
// Get the readable text mapping once
|
|
15
|
+
const readableTextMap = customizationService.getCustomization('panelSegmentation.readableText');
|
|
16
|
+
|
|
17
|
+
// Helper function to recursively map cachedStats to readable display text
|
|
18
|
+
function mapStatsToDisplay(stats, indent = 0) {
|
|
19
|
+
const primary = [];
|
|
20
|
+
const indentation = ' '.repeat(indent);
|
|
21
|
+
|
|
22
|
+
for (const key in stats) {
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(stats, key)) {
|
|
24
|
+
const value = stats[key];
|
|
25
|
+
const readableText = readableTextMap?.[key];
|
|
26
|
+
|
|
27
|
+
if (!readableText) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
32
|
+
// Add empty row before category (except for the first category)
|
|
33
|
+
if (primary.length > 0) {
|
|
34
|
+
primary.push('');
|
|
35
|
+
}
|
|
36
|
+
// Add category title
|
|
37
|
+
primary.push(`${indentation}${readableText}`);
|
|
38
|
+
// Recursively handle nested objects
|
|
39
|
+
primary.push(...mapStatsToDisplay(value, indent + 1));
|
|
40
|
+
} else {
|
|
41
|
+
// For non-nested values, don't add empty rows
|
|
42
|
+
primary.push(`${indentation}${readableText}: ${roundNumber(value, 2)}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return primary;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Get customization for display text mapping
|
|
51
|
+
const displayTextMapper = segment => {
|
|
52
|
+
const defaultDisplay = {
|
|
53
|
+
primary: [],
|
|
54
|
+
secondary: [],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// If the segment has cachedStats, map it to readable text
|
|
58
|
+
if (segment.cachedStats) {
|
|
59
|
+
const primary = mapStatsToDisplay(segment.cachedStats);
|
|
60
|
+
defaultDisplay.primary = primary;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return defaultDisplay;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const updatedSegments = {};
|
|
67
|
+
|
|
68
|
+
Object.entries(segments).forEach(([segmentIndex, segment]) => {
|
|
69
|
+
updatedSegments[segmentIndex] = {
|
|
70
|
+
...segment,
|
|
71
|
+
displayText: displayTextMapper(segment),
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Map the segments and apply the display text mapper
|
|
76
|
+
return {
|
|
77
|
+
...segmentation,
|
|
78
|
+
label,
|
|
79
|
+
fallbackLabel,
|
|
80
|
+
segments: updatedSegments,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Represents the combination of segmentation data and its representation in a viewport.
|
|
86
|
+
*/
|
|
87
|
+
type ViewportSegmentationRepresentation = {
|
|
88
|
+
segmentationsWithRepresentations: {
|
|
89
|
+
representation: SegmentationRepresentation;
|
|
90
|
+
segmentation: SegmentationData;
|
|
91
|
+
}[];
|
|
92
|
+
disabled: boolean;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Custom hook that provides segmentation data and their representations for the active viewport.
|
|
97
|
+
* @param options - The options object.
|
|
98
|
+
* @param options.servicesManager - The services manager object.
|
|
99
|
+
* @param options.subscribeToDataModified - Whether to subscribe to segmentation data modifications.
|
|
100
|
+
* @param options.debounceTime - Debounce time in milliseconds for updates.
|
|
101
|
+
* @returns An array of segmentation data and their representations for the active viewport.
|
|
102
|
+
*/
|
|
103
|
+
export function useViewportSegmentations({
|
|
104
|
+
viewportId,
|
|
105
|
+
subscribeToDataModified = false,
|
|
106
|
+
debounceTime = 0,
|
|
107
|
+
}: {
|
|
108
|
+
viewportId: string;
|
|
109
|
+
subscribeToDataModified?: boolean;
|
|
110
|
+
debounceTime?: number;
|
|
111
|
+
}): ViewportSegmentationRepresentation {
|
|
112
|
+
const { servicesManager } = useSystem();
|
|
113
|
+
const { segmentationService, viewportGridService, customizationService, displaySetService } =
|
|
114
|
+
servicesManager.services;
|
|
115
|
+
|
|
116
|
+
const [segmentationsWithRepresentations, setSegmentationsWithRepresentations] =
|
|
117
|
+
useState<ViewportSegmentationRepresentation>({
|
|
118
|
+
segmentationsWithRepresentations: [],
|
|
119
|
+
disabled: false,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const update = () => {
|
|
124
|
+
const displaySetUIDs = viewportGridService.getDisplaySetsUIDsForViewport(viewportId);
|
|
125
|
+
|
|
126
|
+
if (!displaySetUIDs?.length) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const displaySet = displaySetService.getDisplaySetByUID(displaySetUIDs[0]);
|
|
131
|
+
|
|
132
|
+
if (!displaySet) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (excludedModalities.includes(displaySet.Modality)) {
|
|
137
|
+
setSegmentationsWithRepresentations(prev => ({
|
|
138
|
+
segmentationsWithRepresentations: [],
|
|
139
|
+
disabled: true,
|
|
140
|
+
}));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const segmentations = segmentationService.getSegmentations();
|
|
145
|
+
|
|
146
|
+
if (!segmentations?.length) {
|
|
147
|
+
setSegmentationsWithRepresentations(prev => ({
|
|
148
|
+
segmentationsWithRepresentations: [],
|
|
149
|
+
disabled: false,
|
|
150
|
+
}));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const representations = segmentationService.getSegmentationRepresentations(viewportId);
|
|
155
|
+
|
|
156
|
+
// Deduplicate representations by segmentationId to prevent showing
|
|
157
|
+
// the same segmentation multiple times in the panel when it has
|
|
158
|
+
// multiple representation types (e.g., labelmap and surface)
|
|
159
|
+
const uniqueSegmentationMap = new Map();
|
|
160
|
+
representations.forEach(representation => {
|
|
161
|
+
if (!uniqueSegmentationMap.has(representation.segmentationId)) {
|
|
162
|
+
uniqueSegmentationMap.set(representation.segmentationId, representation);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const newSegmentationsWithRepresentations = Array.from(uniqueSegmentationMap.values()).map(
|
|
167
|
+
representation => {
|
|
168
|
+
const segmentation = segmentationService.getSegmentation(representation.segmentationId);
|
|
169
|
+
const mappedSegmentation = mapSegmentationToDisplay(segmentation, customizationService);
|
|
170
|
+
return {
|
|
171
|
+
representation,
|
|
172
|
+
segmentation: mappedSegmentation,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
setSegmentationsWithRepresentations({
|
|
178
|
+
segmentationsWithRepresentations: newSegmentationsWithRepresentations,
|
|
179
|
+
disabled: false,
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const debouncedUpdate =
|
|
184
|
+
debounceTime > 0 ? debounce(update, debounceTime, { leading: true, trailing: true }) : update;
|
|
185
|
+
|
|
186
|
+
update();
|
|
187
|
+
|
|
188
|
+
const subscriptions = [
|
|
189
|
+
segmentationService.subscribe(
|
|
190
|
+
segmentationService.EVENTS.SEGMENTATION_MODIFIED,
|
|
191
|
+
debouncedUpdate
|
|
192
|
+
),
|
|
193
|
+
segmentationService.subscribe(
|
|
194
|
+
segmentationService.EVENTS.SEGMENTATION_REMOVED,
|
|
195
|
+
debouncedUpdate
|
|
196
|
+
),
|
|
197
|
+
segmentationService.subscribe(
|
|
198
|
+
segmentationService.EVENTS.SEGMENTATION_REPRESENTATION_MODIFIED,
|
|
199
|
+
debouncedUpdate
|
|
200
|
+
),
|
|
201
|
+
// What this hook reads is `getSegmentationRepresentations(viewportId)`, so a
|
|
202
|
+
// representation leaving the viewport changes its answer and has to re-run it.
|
|
203
|
+
// Without this, "Remove from Viewport" cleared the overlay from the image but
|
|
204
|
+
// left the segmentation listed in the panel: the data was already correct, the
|
|
205
|
+
// panel simply never asked again. Nothing else covers it — a hydrated
|
|
206
|
+
// segmentation is not a display set in the viewport, so removing it moves no
|
|
207
|
+
// grid state and fires no grid event either.
|
|
208
|
+
segmentationService.subscribe(
|
|
209
|
+
segmentationService.EVENTS.SEGMENTATION_REPRESENTATION_REMOVED,
|
|
210
|
+
debouncedUpdate
|
|
211
|
+
),
|
|
212
|
+
viewportGridService.subscribe(
|
|
213
|
+
viewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,
|
|
214
|
+
debouncedUpdate
|
|
215
|
+
),
|
|
216
|
+
viewportGridService.subscribe(viewportGridService.EVENTS.GRID_STATE_CHANGED, debouncedUpdate),
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
if (subscribeToDataModified) {
|
|
220
|
+
subscriptions.push(
|
|
221
|
+
segmentationService.subscribe(
|
|
222
|
+
segmentationService.EVENTS.SEGMENTATION_DATA_MODIFIED,
|
|
223
|
+
debouncedUpdate
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return () => {
|
|
229
|
+
subscriptions.forEach(subscription => subscription.unsubscribe());
|
|
230
|
+
if (debounceTime > 0) {
|
|
231
|
+
debouncedUpdate.cancel();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}, [
|
|
235
|
+
segmentationService,
|
|
236
|
+
viewportGridService,
|
|
237
|
+
customizationService,
|
|
238
|
+
displaySetService,
|
|
239
|
+
debounceTime,
|
|
240
|
+
subscribeToDataModified,
|
|
241
|
+
viewportId,
|
|
242
|
+
]);
|
|
243
|
+
|
|
244
|
+
return segmentationsWithRepresentations;
|
|
245
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { HYDRATE_SEG_SYNC_GROUP, VOI_SYNC_GROUP } from './mpr';
|
|
2
|
+
import i18n from 'i18next';
|
|
3
|
+
export const fourUp = {
|
|
4
|
+
id: 'fourUp',
|
|
5
|
+
locked: true,
|
|
6
|
+
name: i18n.t('Hps:3D four up'),
|
|
7
|
+
icon: 'layout-advanced-3d-four-up',
|
|
8
|
+
isPreset: true,
|
|
9
|
+
createdDate: '2023-03-15T10:29:44.894Z',
|
|
10
|
+
modifiedDate: '2023-03-15T10:29:44.894Z',
|
|
11
|
+
availableTo: {},
|
|
12
|
+
editableBy: {},
|
|
13
|
+
protocolMatchingRules: [],
|
|
14
|
+
imageLoadStrategy: 'interleaveCenter',
|
|
15
|
+
displaySetSelectors: {
|
|
16
|
+
activeDisplaySet: {
|
|
17
|
+
seriesMatchingRules: [
|
|
18
|
+
{
|
|
19
|
+
weight: 1,
|
|
20
|
+
attribute: 'isReconstructable',
|
|
21
|
+
constraint: {
|
|
22
|
+
equals: {
|
|
23
|
+
value: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
stages: [
|
|
32
|
+
{
|
|
33
|
+
id: 'fourUpStage',
|
|
34
|
+
name: 'fourUp',
|
|
35
|
+
viewportStructure: {
|
|
36
|
+
layoutType: 'grid',
|
|
37
|
+
properties: {
|
|
38
|
+
rows: 2,
|
|
39
|
+
columns: 2,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
viewports: [
|
|
43
|
+
{
|
|
44
|
+
viewportOptions: {
|
|
45
|
+
toolGroupId: 'mpr',
|
|
46
|
+
viewportType: 'volume',
|
|
47
|
+
orientation: 'axial',
|
|
48
|
+
initialImageOptions: {
|
|
49
|
+
preset: 'middle',
|
|
50
|
+
},
|
|
51
|
+
syncGroups: [VOI_SYNC_GROUP, HYDRATE_SEG_SYNC_GROUP],
|
|
52
|
+
},
|
|
53
|
+
displaySets: [
|
|
54
|
+
{
|
|
55
|
+
id: 'activeDisplaySet',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
viewportOptions: {
|
|
61
|
+
toolGroupId: 'volume3d',
|
|
62
|
+
viewportType: 'volume3d',
|
|
63
|
+
orientation: 'coronal',
|
|
64
|
+
customViewportProps: {
|
|
65
|
+
hideOverlays: true,
|
|
66
|
+
},
|
|
67
|
+
syncGroups: [HYDRATE_SEG_SYNC_GROUP],
|
|
68
|
+
},
|
|
69
|
+
displaySets: [
|
|
70
|
+
{
|
|
71
|
+
id: 'activeDisplaySet',
|
|
72
|
+
options: {
|
|
73
|
+
displayPreset: {
|
|
74
|
+
CT: 'CT-Bone',
|
|
75
|
+
MR: 'MR-Default',
|
|
76
|
+
default: 'CT-Bone',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
viewportOptions: {
|
|
84
|
+
toolGroupId: 'mpr',
|
|
85
|
+
viewportType: 'volume',
|
|
86
|
+
orientation: 'coronal',
|
|
87
|
+
initialImageOptions: {
|
|
88
|
+
preset: 'middle',
|
|
89
|
+
},
|
|
90
|
+
syncGroups: [VOI_SYNC_GROUP, HYDRATE_SEG_SYNC_GROUP],
|
|
91
|
+
},
|
|
92
|
+
displaySets: [
|
|
93
|
+
{
|
|
94
|
+
id: 'activeDisplaySet',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
viewportOptions: {
|
|
100
|
+
toolGroupId: 'mpr',
|
|
101
|
+
viewportType: 'volume',
|
|
102
|
+
orientation: 'sagittal',
|
|
103
|
+
initialImageOptions: {
|
|
104
|
+
preset: 'middle',
|
|
105
|
+
},
|
|
106
|
+
syncGroups: [VOI_SYNC_GROUP, HYDRATE_SEG_SYNC_GROUP],
|
|
107
|
+
},
|
|
108
|
+
displaySets: [
|
|
109
|
+
{
|
|
110
|
+
id: 'activeDisplaySet',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|