@ohif/extension-cornerstone 3.14.0-beta.11 → 3.14.0-beta.111
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 +33 -25
- package/src/Viewport/OHIFCornerstoneViewport.css +46 -0
- package/src/Viewport/OHIFCornerstoneViewport.tsx +498 -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 +2962 -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/FidelityIndicator/FidelityIndicator.tsx +152 -0
- package/src/components/FidelityIndicator/index.ts +1 -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 +109 -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 +13 -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 +9 -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/useViewportFidelity.ts +243 -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 +448 -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,326 @@
|
|
|
1
|
+
import { Types } from '@ohif/core';
|
|
2
|
+
import { cache as cs3DCache, Enums, volumeLoader } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
import getCornerstoneViewportType from '../../utils/getCornerstoneViewportType';
|
|
5
|
+
import { loadDisplaySetData } from '../../utils/loadDisplaySetData';
|
|
6
|
+
import { StackViewportData, VolumeViewportData } from '../../types/CornerstoneCacheService';
|
|
7
|
+
import { VOLUME_LOADER_SCHEME } from '../../constants';
|
|
8
|
+
|
|
9
|
+
class CornerstoneCacheService {
|
|
10
|
+
static REGISTRATION = {
|
|
11
|
+
name: 'cornerstoneCacheService',
|
|
12
|
+
altName: 'CornerstoneCacheService',
|
|
13
|
+
create: ({ servicesManager }: Types.Extensions.ExtensionParams): CornerstoneCacheService => {
|
|
14
|
+
return new CornerstoneCacheService(servicesManager);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
stackImageIds: Map<string, string[]> = new Map();
|
|
19
|
+
volumeImageIds: Map<string, string[]> = new Map();
|
|
20
|
+
readonly servicesManager: AppTypes.ServicesManager;
|
|
21
|
+
|
|
22
|
+
constructor(servicesManager: AppTypes.ServicesManager) {
|
|
23
|
+
this.servicesManager = servicesManager;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public getCacheSize() {
|
|
27
|
+
return cs3DCache.getCacheSize();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public getCacheFreeSpace() {
|
|
31
|
+
return cs3DCache.getBytesAvailable();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public async createViewportData(
|
|
35
|
+
displaySets: Types.DisplaySet[],
|
|
36
|
+
viewportOptions: AppTypes.ViewportGrid.GridViewportOptions,
|
|
37
|
+
dataSource: unknown,
|
|
38
|
+
initialImageIndex?: number
|
|
39
|
+
): Promise<StackViewportData | VolumeViewportData> {
|
|
40
|
+
const viewportType = viewportOptions.viewportType as string;
|
|
41
|
+
|
|
42
|
+
const cs3DViewportType = getCornerstoneViewportType(viewportType, displaySets);
|
|
43
|
+
let viewportData: StackViewportData | VolumeViewportData;
|
|
44
|
+
|
|
45
|
+
// Native Generic ("next") viewport types (e.g. PLANAR_NEXT) intentionally
|
|
46
|
+
// collapse the stack/volume distinction into a single type, so they cannot
|
|
47
|
+
// drive the stack-vs-volume data-builder decision below. Resolve the data
|
|
48
|
+
// shape from the legacy mapping (which preserves that distinction) and keep
|
|
49
|
+
// the resolved native type as the produced viewportData's viewportType.
|
|
50
|
+
let dataShapeType = getCornerstoneViewportType(viewportType, displaySets, false);
|
|
51
|
+
|
|
52
|
+
// A data overlay (fusion) of two or more reconstructable image display sets
|
|
53
|
+
// must render as a volume viewport so the source and overlay share one
|
|
54
|
+
// representation (volume slice). Without this, a next (PLANAR_NEXT) viewport
|
|
55
|
+
// keeps the source in vtkImage (stack) mode while the added overlay is a
|
|
56
|
+
// vtkVolumeSlice, producing the broken/unstable fusion. SEG/RT overlays are
|
|
57
|
+
// non-reconstructable, so they are not affected.
|
|
58
|
+
//
|
|
59
|
+
// Scoped to the native (PLANAR_NEXT) path via cs3DViewportType — NOT the flag, and
|
|
60
|
+
// NOT the legacy lane: a legacy stack-shaped reconstructable overlay must keep its
|
|
61
|
+
// existing stack build so the flag-off path stays byte-identical.
|
|
62
|
+
const isReconstructableFusion =
|
|
63
|
+
displaySets.length > 1 && displaySets.every(ds => ds.isReconstructable);
|
|
64
|
+
if (
|
|
65
|
+
isReconstructableFusion &&
|
|
66
|
+
dataShapeType === Enums.ViewportType.STACK &&
|
|
67
|
+
cs3DViewportType === Enums.ViewportType.PLANAR_NEXT
|
|
68
|
+
) {
|
|
69
|
+
dataShapeType = Enums.ViewportType.ORTHOGRAPHIC;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (
|
|
73
|
+
dataShapeType === Enums.ViewportType.ORTHOGRAPHIC ||
|
|
74
|
+
dataShapeType === Enums.ViewportType.VOLUME_3D
|
|
75
|
+
) {
|
|
76
|
+
viewportData = await this._getVolumeViewportData(dataSource, displaySets, cs3DViewportType);
|
|
77
|
+
} else if (dataShapeType === Enums.ViewportType.STACK) {
|
|
78
|
+
// Everything else looks like a stack
|
|
79
|
+
viewportData = await this._getStackViewportData(
|
|
80
|
+
dataSource,
|
|
81
|
+
displaySets,
|
|
82
|
+
initialImageIndex,
|
|
83
|
+
cs3DViewportType
|
|
84
|
+
);
|
|
85
|
+
} else {
|
|
86
|
+
viewportData = await this._getOtherViewportData(
|
|
87
|
+
dataSource,
|
|
88
|
+
displaySets,
|
|
89
|
+
initialImageIndex,
|
|
90
|
+
cs3DViewportType
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
viewportData.viewportType = cs3DViewportType;
|
|
95
|
+
// Persist the legacy stack/volume shape so consumers can distinguish stack from
|
|
96
|
+
// volume content even when viewportType is a native Generic type (PLANAR_NEXT).
|
|
97
|
+
viewportData.dataShapeType = dataShapeType;
|
|
98
|
+
|
|
99
|
+
return viewportData;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public async invalidateViewportData(
|
|
103
|
+
viewportData: VolumeViewportData | StackViewportData,
|
|
104
|
+
invalidatedDisplaySetInstanceUID: string,
|
|
105
|
+
dataSource,
|
|
106
|
+
displaySetService
|
|
107
|
+
): Promise<VolumeViewportData | StackViewportData> {
|
|
108
|
+
// Decide stack-vs-volume rebuild from the persisted data shape, NOT viewportType:
|
|
109
|
+
// native viewports collapse both onto PLANAR_NEXT, so a native stack would
|
|
110
|
+
// otherwise fall through to the volume rebuild and re-mount as volume data.
|
|
111
|
+
// Falls back to viewportType for legacy/older viewportData (byte-identical off-path).
|
|
112
|
+
const dataShapeType = viewportData.dataShapeType ?? viewportData.viewportType;
|
|
113
|
+
|
|
114
|
+
if (dataShapeType === Enums.ViewportType.STACK) {
|
|
115
|
+
const displaySet = displaySetService.getDisplaySetByUID(invalidatedDisplaySetInstanceUID);
|
|
116
|
+
const imageIds = this._getCornerstoneStackImageIds(displaySet, dataSource);
|
|
117
|
+
|
|
118
|
+
// remove images from the cache to be able to re-load them
|
|
119
|
+
imageIds.forEach(imageId => {
|
|
120
|
+
if (cs3DCache.getImageLoadObject(imageId)) {
|
|
121
|
+
cs3DCache.removeImageLoadObject(imageId);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
// Preserve the original viewportType (legacy STACK or native PLANAR_NEXT);
|
|
127
|
+
// the rebuilt data shape, not this field, drives the native re-mount dispatch.
|
|
128
|
+
viewportType: viewportData.viewportType,
|
|
129
|
+
dataShapeType: Enums.ViewportType.STACK,
|
|
130
|
+
data: {
|
|
131
|
+
StudyInstanceUID: displaySet.StudyInstanceUID,
|
|
132
|
+
displaySetInstanceUID: invalidatedDisplaySetInstanceUID,
|
|
133
|
+
imageIds,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Todo: grab the volume and get the id from the viewport itself
|
|
139
|
+
const volumeId = `${VOLUME_LOADER_SCHEME}:${invalidatedDisplaySetInstanceUID}`;
|
|
140
|
+
|
|
141
|
+
const volume = cs3DCache.getVolume(volumeId);
|
|
142
|
+
|
|
143
|
+
if (volume) {
|
|
144
|
+
if (volume.imageIds) {
|
|
145
|
+
// also for each imageId in the volume, remove the imageId from the cache
|
|
146
|
+
// since that will hold the old metadata as well
|
|
147
|
+
|
|
148
|
+
volume.imageIds.forEach(imageId => {
|
|
149
|
+
if (cs3DCache.getImageLoadObject(imageId)) {
|
|
150
|
+
cs3DCache.removeImageLoadObject(imageId, { force: true });
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// this shouldn't be via removeVolumeLoadObject, since that will
|
|
156
|
+
// remove the texture as well, but here we really just need a remove
|
|
157
|
+
// from registry so that we load it again
|
|
158
|
+
cs3DCache._volumeCache.delete(volumeId);
|
|
159
|
+
this.volumeImageIds.delete(volumeId);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const displaySets = viewportData.data.map(({ displaySetInstanceUID }) =>
|
|
163
|
+
displaySetService.getDisplaySetByUID(displaySetInstanceUID)
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const newViewportData = await this._getVolumeViewportData(
|
|
167
|
+
dataSource,
|
|
168
|
+
displaySets,
|
|
169
|
+
viewportData.viewportType
|
|
170
|
+
);
|
|
171
|
+
newViewportData.dataShapeType = dataShapeType;
|
|
172
|
+
|
|
173
|
+
return newViewportData;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private async _getOtherViewportData(
|
|
177
|
+
dataSource,
|
|
178
|
+
displaySets,
|
|
179
|
+
_initialImageIndex,
|
|
180
|
+
viewportType: Enums.ViewportType
|
|
181
|
+
): Promise<StackViewportData> {
|
|
182
|
+
// TODO - handle overlays and secondary display sets, but for now assume
|
|
183
|
+
// the 1st display set is the one of interest
|
|
184
|
+
const [displaySet] = displaySets;
|
|
185
|
+
if (!displaySet.imageIds) {
|
|
186
|
+
displaySet.imagesIds = this._getCornerstoneStackImageIds(displaySet, dataSource);
|
|
187
|
+
}
|
|
188
|
+
const { imageIds: data, viewportType: dsViewportType } = displaySet;
|
|
189
|
+
return {
|
|
190
|
+
viewportType: dsViewportType || viewportType,
|
|
191
|
+
data: displaySets,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private async _getStackViewportData(
|
|
196
|
+
dataSource,
|
|
197
|
+
displaySets,
|
|
198
|
+
initialImageIndex,
|
|
199
|
+
viewportType: Enums.ViewportType
|
|
200
|
+
): Promise<StackViewportData> {
|
|
201
|
+
// Overlays are loaded before the loop below so that a segmentation can
|
|
202
|
+
// back-fill the imageIds of the series it references.
|
|
203
|
+
const overlayDisplaySets = displaySets.filter(ds => ds.isOverlayDisplaySet);
|
|
204
|
+
for (const overlayDisplaySet of overlayDisplaySets) {
|
|
205
|
+
await loadDisplaySetData(overlayDisplaySet, this.servicesManager);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Ensuring the first non-overlay `displaySet` is always the primary one
|
|
209
|
+
const StackViewportData = [];
|
|
210
|
+
for (const displaySet of displaySets) {
|
|
211
|
+
const { displaySetInstanceUID, StudyInstanceUID, isCompositeStack } = displaySet;
|
|
212
|
+
|
|
213
|
+
await loadDisplaySetData(displaySet, this.servicesManager);
|
|
214
|
+
|
|
215
|
+
let stackImageIds = this.stackImageIds.get(displaySet.displaySetInstanceUID);
|
|
216
|
+
|
|
217
|
+
if (!stackImageIds) {
|
|
218
|
+
stackImageIds = this._getCornerstoneStackImageIds(displaySet, dataSource);
|
|
219
|
+
// assign imageIds to the displaySet
|
|
220
|
+
displaySet.imageIds = stackImageIds;
|
|
221
|
+
this.stackImageIds.set(displaySet.displaySetInstanceUID, stackImageIds);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
StackViewportData.push({
|
|
225
|
+
StudyInstanceUID,
|
|
226
|
+
displaySetInstanceUID,
|
|
227
|
+
isCompositeStack,
|
|
228
|
+
imageIds: stackImageIds,
|
|
229
|
+
initialImageIndex,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
viewportType,
|
|
235
|
+
data: StackViewportData,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private async _getVolumeViewportData(
|
|
240
|
+
dataSource,
|
|
241
|
+
displaySets,
|
|
242
|
+
viewportType: Enums.ViewportType
|
|
243
|
+
): Promise<VolumeViewportData> {
|
|
244
|
+
// Todo: Check the cache for multiple scenarios to see if we need to
|
|
245
|
+
// decache the volume data from other viewports or not
|
|
246
|
+
|
|
247
|
+
const volumeData = [];
|
|
248
|
+
|
|
249
|
+
for (const displaySet of displaySets) {
|
|
250
|
+
const { Modality } = displaySet;
|
|
251
|
+
const isParametricMap = Modality === 'PMAP';
|
|
252
|
+
const isSegOrRtstruct = Modality === 'SEG' || Modality === 'RTSTRUCT';
|
|
253
|
+
|
|
254
|
+
// Don't create volumes for the displaySets that have custom load
|
|
255
|
+
// function (e.g., SEG, RT, since they rely on the reference volumes
|
|
256
|
+
// and they take care of their own loading after they are created in their
|
|
257
|
+
// getSOPClassHandler method
|
|
258
|
+
|
|
259
|
+
if (displaySet.load instanceof Function) {
|
|
260
|
+
await loadDisplaySetData(displaySet, this.servicesManager);
|
|
261
|
+
|
|
262
|
+
// Parametric maps have a `load` method but it should not be loaded in the
|
|
263
|
+
// same way as SEG and RTSTRUCT but like a normal volume
|
|
264
|
+
if (!isParametricMap) {
|
|
265
|
+
volumeData.push({
|
|
266
|
+
studyInstanceUID: displaySet.StudyInstanceUID,
|
|
267
|
+
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Todo: do some cache check and empty the cache if needed
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const volumeLoaderSchema = displaySet.volumeLoaderSchema ?? VOLUME_LOADER_SCHEME;
|
|
276
|
+
const volumeId = `${volumeLoaderSchema}:${displaySet.displaySetInstanceUID}`;
|
|
277
|
+
let volumeImageIds = this.volumeImageIds.get(displaySet.displaySetInstanceUID);
|
|
278
|
+
let volume = cs3DCache.getVolume(volumeId);
|
|
279
|
+
|
|
280
|
+
// Parametric maps do not have image ids but they already have volume data
|
|
281
|
+
// therefore a new volume should not be created.
|
|
282
|
+
if (!isParametricMap && !isSegOrRtstruct && (!volumeImageIds || !volume)) {
|
|
283
|
+
volumeImageIds = this._getCornerstoneVolumeImageIds(displaySet, dataSource);
|
|
284
|
+
|
|
285
|
+
volume = await volumeLoader.createAndCacheVolume(volumeId, {
|
|
286
|
+
imageIds: volumeImageIds,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
this.volumeImageIds.set(displaySet.displaySetInstanceUID, volumeImageIds);
|
|
290
|
+
|
|
291
|
+
// Add imageIds to the displaySet for volumes
|
|
292
|
+
displaySet.imageIds = volumeImageIds;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
volumeData.push({
|
|
296
|
+
StudyInstanceUID: displaySet.StudyInstanceUID,
|
|
297
|
+
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
|
298
|
+
volume,
|
|
299
|
+
volumeId,
|
|
300
|
+
imageIds: volumeImageIds,
|
|
301
|
+
isDynamicVolume: displaySet.isDynamicVolume,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return {
|
|
306
|
+
viewportType,
|
|
307
|
+
data: volumeData,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private _getCornerstoneStackImageIds(displaySet, dataSource): string[] {
|
|
312
|
+
return dataSource.getImageIdsForDisplaySet(displaySet);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private _getCornerstoneVolumeImageIds(displaySet, dataSource): string[] {
|
|
316
|
+
if (displaySet.imageIds) {
|
|
317
|
+
return displaySet.imageIds;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const stackImageIds = this._getCornerstoneStackImageIds(displaySet, dataSource);
|
|
321
|
+
|
|
322
|
+
return stackImageIds;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export default CornerstoneCacheService;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a DICOM RT Struct ROI Contour to a RTStruct data that can be used
|
|
3
|
+
* in Segmentation Service
|
|
4
|
+
*
|
|
5
|
+
* @param structureSet - A DICOM RT Struct ROI Contour
|
|
6
|
+
* @param rtDisplaySetUID - A CornerstoneTools DisplaySet UID
|
|
7
|
+
* @returns An array of object that includes data, id, segmentIndex, color
|
|
8
|
+
* and geometry Id
|
|
9
|
+
*/
|
|
10
|
+
export function mapROIContoursToRTStructData(structureSet: unknown, rtDisplaySetUID: unknown) {
|
|
11
|
+
return structureSet.ROIContours.map(
|
|
12
|
+
({ contourPoints, ROINumber, ROIName, colorArray, ROIGroup }) => {
|
|
13
|
+
const data = contourPoints.map(({ points, ...rest }) => {
|
|
14
|
+
const newPoints = points.map(({ x, y, z }) => {
|
|
15
|
+
return [x, y, z];
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
...rest,
|
|
20
|
+
points: newPoints,
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const id = ROIName || ROINumber;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
data,
|
|
28
|
+
id,
|
|
29
|
+
segmentIndex: ROINumber,
|
|
30
|
+
color: colorArray,
|
|
31
|
+
group: ROIGroup,
|
|
32
|
+
geometryId: `${rtDisplaySetUID}:${id}:segmentIndex-${ROINumber}`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|