@ohif/extension-cornerstone 3.14.0-beta.11 → 3.14.0-beta.110
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 +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 +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,547 @@
|
|
|
1
|
+
import { cache, imageLoadPoolManager, Enums } from '@cornerstonejs/core';
|
|
2
|
+
import getInterleavedFrames from './getInterleavedFrames';
|
|
3
|
+
import zip from 'lodash.zip';
|
|
4
|
+
import compact from 'lodash.compact';
|
|
5
|
+
import flatten from 'lodash.flatten';
|
|
6
|
+
import interleaveCenterLoader from './interleaveCenterLoader';
|
|
7
|
+
|
|
8
|
+
jest.mock('@cornerstonejs/core', () => ({
|
|
9
|
+
cache: {
|
|
10
|
+
getVolume: jest.fn(),
|
|
11
|
+
},
|
|
12
|
+
imageLoadPoolManager: {
|
|
13
|
+
addRequest: jest.fn(),
|
|
14
|
+
},
|
|
15
|
+
Enums: {
|
|
16
|
+
RequestType: {
|
|
17
|
+
Prefetch: 'Prefetch',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
jest.mock('./getInterleavedFrames', () => jest.fn());
|
|
23
|
+
jest.mock('lodash.zip', () => jest.fn());
|
|
24
|
+
jest.mock('lodash.compact', () => jest.fn());
|
|
25
|
+
jest.mock('lodash.flatten', () => jest.fn());
|
|
26
|
+
|
|
27
|
+
describe('interleaveCenterLoader', () => {
|
|
28
|
+
const mockVolumeInput = {
|
|
29
|
+
volumeId: 'test-volume-id',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const mockVolume = {
|
|
33
|
+
metadata: {
|
|
34
|
+
SeriesInstanceUID: 'test-series-uid',
|
|
35
|
+
},
|
|
36
|
+
getImageLoadRequests: jest.fn(),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const mockImageLoadRequest = {
|
|
40
|
+
imageId: 'test-image-id',
|
|
41
|
+
callLoadImage: jest.fn(),
|
|
42
|
+
additionalDetails: 'test-details',
|
|
43
|
+
imageIdIndex: 0,
|
|
44
|
+
options: { test: 'option' },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const mockDisplaySetsInfo = [
|
|
48
|
+
{
|
|
49
|
+
displaySetInstanceUID: 'test-volume-id',
|
|
50
|
+
displaySetOptions: {},
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const mockMatchDetails = new Map([
|
|
55
|
+
[
|
|
56
|
+
'viewport-1',
|
|
57
|
+
{
|
|
58
|
+
displaySetsInfo: mockDisplaySetsInfo,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
const defaultParameters = {
|
|
64
|
+
data: {
|
|
65
|
+
viewportId: 'test-viewport-id',
|
|
66
|
+
volumeInputArray: [mockVolumeInput],
|
|
67
|
+
},
|
|
68
|
+
displaySetsMatchDetails: {},
|
|
69
|
+
viewportMatchDetails: mockMatchDetails,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
beforeEach(() => {
|
|
73
|
+
jest.clearAllMocks();
|
|
74
|
+
(cache.getVolume as jest.Mock).mockReturnValue(mockVolume);
|
|
75
|
+
mockVolume.getImageLoadRequests.mockReturnValue([mockImageLoadRequest]);
|
|
76
|
+
(getInterleavedFrames as jest.Mock).mockReturnValue([{ imageId: 'test-image-id' }]);
|
|
77
|
+
(zip as jest.Mock).mockImplementation((...args) => args[0]);
|
|
78
|
+
(compact as jest.Mock).mockImplementation(input => input?.filter(Boolean) ?? []);
|
|
79
|
+
(flatten as jest.Mock).mockImplementation(input => input?.flat() ?? []);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should store viewport and volume input array mapping on first call', () => {
|
|
83
|
+
interleaveCenterLoader(defaultParameters);
|
|
84
|
+
|
|
85
|
+
expect(cache.getVolume).toHaveBeenCalledWith(mockVolumeInput.volumeId);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should return early when volume is not found', () => {
|
|
89
|
+
(cache.getVolume as jest.Mock).mockReturnValue(null);
|
|
90
|
+
|
|
91
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
92
|
+
|
|
93
|
+
expect(result).toBeUndefined();
|
|
94
|
+
expect(mockVolume.getImageLoadRequests).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should return early when volume input array size does not match display set UIDs', () => {
|
|
98
|
+
const mockMatchDetailsWithDifferentSize = new Map([
|
|
99
|
+
[
|
|
100
|
+
'viewport-1',
|
|
101
|
+
{
|
|
102
|
+
displaySetsInfo: [
|
|
103
|
+
{ displaySetInstanceUID: 'display-set-1' },
|
|
104
|
+
{ displaySetInstanceUID: 'display-set-2' },
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
const result = interleaveCenterLoader({
|
|
111
|
+
...defaultParameters,
|
|
112
|
+
viewportMatchDetails: mockMatchDetailsWithDifferentSize,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(result).toBeUndefined();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should process volume and create interleaved requests', () => {
|
|
119
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
120
|
+
|
|
121
|
+
expect(cache.getVolume).toHaveBeenCalledWith(mockVolumeInput.volumeId);
|
|
122
|
+
expect(mockVolume.getImageLoadRequests).toHaveBeenCalled();
|
|
123
|
+
expect(getInterleavedFrames).toHaveBeenCalledWith(['test-image-id']);
|
|
124
|
+
expect(zip).toHaveBeenCalled();
|
|
125
|
+
expect(compact).toHaveBeenCalled();
|
|
126
|
+
expect(flatten).toHaveBeenCalled();
|
|
127
|
+
expect(result).toBeInstanceOf(Map);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should add requests to imageLoadPoolManager with correct parameters', () => {
|
|
131
|
+
interleaveCenterLoader(defaultParameters);
|
|
132
|
+
|
|
133
|
+
expect(imageLoadPoolManager.addRequest).toHaveBeenCalledWith(
|
|
134
|
+
expect.any(Function),
|
|
135
|
+
Enums.RequestType.Prefetch,
|
|
136
|
+
mockImageLoadRequest.additionalDetails,
|
|
137
|
+
0
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should bind callLoadImage with correct parameters', () => {
|
|
142
|
+
interleaveCenterLoader(defaultParameters);
|
|
143
|
+
|
|
144
|
+
const addRequestCall = (imageLoadPoolManager.addRequest as jest.Mock).mock.calls[0];
|
|
145
|
+
const boundFunction = addRequestCall[0];
|
|
146
|
+
|
|
147
|
+
boundFunction();
|
|
148
|
+
|
|
149
|
+
expect(mockImageLoadRequest.callLoadImage).toHaveBeenCalledWith(
|
|
150
|
+
mockImageLoadRequest.imageId,
|
|
151
|
+
mockImageLoadRequest.imageIdIndex,
|
|
152
|
+
mockImageLoadRequest.options
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('should handle volumes without image load requests', () => {
|
|
157
|
+
mockVolume.getImageLoadRequests.mockReturnValue([]);
|
|
158
|
+
|
|
159
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
160
|
+
|
|
161
|
+
expect(zip).toHaveBeenCalledWith();
|
|
162
|
+
expect(result).toBeInstanceOf(Map);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should handle volumes with empty requests array', () => {
|
|
166
|
+
mockVolume.getImageLoadRequests.mockReturnValue([]);
|
|
167
|
+
|
|
168
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
169
|
+
|
|
170
|
+
expect(getInterleavedFrames).not.toHaveBeenCalled();
|
|
171
|
+
expect(result).toBeInstanceOf(Map);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should handle volumes with null first request', () => {
|
|
175
|
+
mockVolume.getImageLoadRequests.mockReturnValue([null]);
|
|
176
|
+
|
|
177
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
178
|
+
|
|
179
|
+
expect(getInterleavedFrames).not.toHaveBeenCalled();
|
|
180
|
+
expect(result).toBeInstanceOf(Map);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should handle volumes with requests without imageId', () => {
|
|
184
|
+
const requestWithoutImageId = {
|
|
185
|
+
callLoadImage: jest.fn(),
|
|
186
|
+
additionalDetails: 'test-details',
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
mockVolume.getImageLoadRequests.mockReturnValue([requestWithoutImageId]);
|
|
190
|
+
|
|
191
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
192
|
+
|
|
193
|
+
expect(getInterleavedFrames).not.toHaveBeenCalled();
|
|
194
|
+
expect(result).toBeInstanceOf(Map);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('should handle multiple volume inputs', () => {
|
|
198
|
+
const mockVolumeInput2 = {
|
|
199
|
+
volumeId: 'test-volume-id-2',
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const mockVolume2 = {
|
|
203
|
+
metadata: {
|
|
204
|
+
SeriesInstanceUID: 'test-series-uid-2',
|
|
205
|
+
},
|
|
206
|
+
getImageLoadRequests: jest.fn().mockReturnValue([mockImageLoadRequest]),
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
(cache.getVolume as jest.Mock)
|
|
210
|
+
.mockReturnValueOnce(mockVolume)
|
|
211
|
+
.mockReturnValueOnce(mockVolume2)
|
|
212
|
+
.mockReturnValueOnce(mockVolume)
|
|
213
|
+
.mockReturnValueOnce(mockVolume2);
|
|
214
|
+
|
|
215
|
+
const mockMatchDetailsWithMultipleVolumes = new Map([
|
|
216
|
+
[
|
|
217
|
+
'viewport-1',
|
|
218
|
+
{
|
|
219
|
+
displaySetsInfo: [
|
|
220
|
+
{ displaySetInstanceUID: 'test-volume-id' },
|
|
221
|
+
{ displaySetInstanceUID: 'test-volume-id-2' },
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
]);
|
|
226
|
+
|
|
227
|
+
interleaveCenterLoader({
|
|
228
|
+
...defaultParameters,
|
|
229
|
+
data: {
|
|
230
|
+
...defaultParameters.data,
|
|
231
|
+
volumeInputArray: [mockVolumeInput, mockVolumeInput2],
|
|
232
|
+
},
|
|
233
|
+
viewportMatchDetails: mockMatchDetailsWithMultipleVolumes,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
expect(cache.getVolume).toHaveBeenCalledWith(mockVolumeInput.volumeId);
|
|
237
|
+
expect(cache.getVolume).toHaveBeenCalledWith(mockVolumeInput2.volumeId);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('should handle duplicate volume IDs by not adding them again', () => {
|
|
241
|
+
const duplicateVolumeInput = {
|
|
242
|
+
volumeId: mockVolumeInput.volumeId,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
interleaveCenterLoader({
|
|
246
|
+
...defaultParameters,
|
|
247
|
+
data: {
|
|
248
|
+
...defaultParameters.data,
|
|
249
|
+
volumeInputArray: [mockVolumeInput, duplicateVolumeInput],
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
expect(cache.getVolume).toHaveBeenCalledTimes(3);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('should clear internal maps after processing', () => {
|
|
257
|
+
const firstResult = interleaveCenterLoader(defaultParameters);
|
|
258
|
+
const secondResult = interleaveCenterLoader(defaultParameters);
|
|
259
|
+
|
|
260
|
+
expect(firstResult).toBeInstanceOf(Map);
|
|
261
|
+
expect(secondResult).toBeInstanceOf(Map);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('should handle multiple image load requests', () => {
|
|
265
|
+
const mockImageLoadRequest2 = {
|
|
266
|
+
imageId: 'test-image-id-2',
|
|
267
|
+
callLoadImage: jest.fn(),
|
|
268
|
+
additionalDetails: 'test-details-2',
|
|
269
|
+
imageIdIndex: 1,
|
|
270
|
+
options: { test: 'option2' },
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
mockVolume.getImageLoadRequests.mockReturnValue([mockImageLoadRequest, mockImageLoadRequest2]);
|
|
274
|
+
|
|
275
|
+
(getInterleavedFrames as jest.Mock).mockReturnValue([
|
|
276
|
+
{ imageId: 'test-image-id' },
|
|
277
|
+
{ imageId: 'test-image-id-2' },
|
|
278
|
+
]);
|
|
279
|
+
|
|
280
|
+
(compact as jest.Mock).mockReturnValue([mockImageLoadRequest, mockImageLoadRequest2]);
|
|
281
|
+
(flatten as jest.Mock).mockReturnValue([mockImageLoadRequest, mockImageLoadRequest2]);
|
|
282
|
+
|
|
283
|
+
interleaveCenterLoader(defaultParameters);
|
|
284
|
+
|
|
285
|
+
expect(getInterleavedFrames).toHaveBeenCalledWith(['test-image-id', 'test-image-id-2']);
|
|
286
|
+
expect(imageLoadPoolManager.addRequest).toHaveBeenCalledTimes(2);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('should handle getInterleavedFrames returning empty array', () => {
|
|
290
|
+
(getInterleavedFrames as jest.Mock).mockReturnValue([]);
|
|
291
|
+
|
|
292
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
293
|
+
|
|
294
|
+
expect(imageLoadPoolManager.addRequest).not.toHaveBeenCalled();
|
|
295
|
+
expect(result).toBeInstanceOf(Map);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should handle zip returning empty result', () => {
|
|
299
|
+
(zip as jest.Mock).mockReturnValue([]);
|
|
300
|
+
|
|
301
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
302
|
+
|
|
303
|
+
expect(compact).toHaveBeenCalledWith([]);
|
|
304
|
+
expect(result).toBeInstanceOf(Map);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('should handle compact filtering out null values', () => {
|
|
308
|
+
(compact as jest.Mock).mockReturnValue([]);
|
|
309
|
+
|
|
310
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
311
|
+
|
|
312
|
+
expect(imageLoadPoolManager.addRequest).not.toHaveBeenCalled();
|
|
313
|
+
expect(result).toBeInstanceOf(Map);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('should map imageIds to requests correctly', () => {
|
|
317
|
+
const mockImageLoadRequest2 = {
|
|
318
|
+
imageId: 'test-image-id-2',
|
|
319
|
+
callLoadImage: jest.fn(),
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
mockVolume.getImageLoadRequests.mockReturnValue([mockImageLoadRequest, mockImageLoadRequest2]);
|
|
323
|
+
|
|
324
|
+
(getInterleavedFrames as jest.Mock).mockReturnValue([
|
|
325
|
+
{ imageId: 'test-image-id-2' },
|
|
326
|
+
{ imageId: 'test-image-id' },
|
|
327
|
+
]);
|
|
328
|
+
|
|
329
|
+
interleaveCenterLoader(defaultParameters);
|
|
330
|
+
|
|
331
|
+
expect(getInterleavedFrames).toHaveBeenCalledWith(['test-image-id', 'test-image-id-2']);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('should return copy of viewport volume input array map', () => {
|
|
335
|
+
const result = interleaveCenterLoader(defaultParameters);
|
|
336
|
+
|
|
337
|
+
expect(result.has(defaultParameters.data.viewportId)).toBe(true);
|
|
338
|
+
expect(result.get(defaultParameters.data.viewportId)).toEqual(
|
|
339
|
+
defaultParameters.data.volumeInputArray
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('should handle multiple match details with different displaySets', () => {
|
|
344
|
+
const mockMultipleMatchDetails = new Map([
|
|
345
|
+
[
|
|
346
|
+
'viewport-1',
|
|
347
|
+
{
|
|
348
|
+
displaySetsInfo: [{ displaySetInstanceUID: 'display-set-1' }],
|
|
349
|
+
},
|
|
350
|
+
],
|
|
351
|
+
[
|
|
352
|
+
'viewport-2',
|
|
353
|
+
{
|
|
354
|
+
displaySetsInfo: [{ displaySetInstanceUID: 'display-set-2' }],
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
]);
|
|
358
|
+
|
|
359
|
+
const result = interleaveCenterLoader({
|
|
360
|
+
...defaultParameters,
|
|
361
|
+
viewportMatchDetails: mockMultipleMatchDetails,
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
expect(result).toBeUndefined();
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('should handle empty match details', () => {
|
|
368
|
+
const emptyMatchDetails = new Map();
|
|
369
|
+
|
|
370
|
+
const result = interleaveCenterLoader({
|
|
371
|
+
...defaultParameters,
|
|
372
|
+
viewportMatchDetails: emptyMatchDetails,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
expect(result).toBeUndefined();
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('should handle empty volumeInputArray', () => {
|
|
379
|
+
const result = interleaveCenterLoader({
|
|
380
|
+
...defaultParameters,
|
|
381
|
+
data: {
|
|
382
|
+
...defaultParameters.data,
|
|
383
|
+
volumeInputArray: [],
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
expect(result).toBeUndefined();
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it('should handle requests with missing properties gracefully', () => {
|
|
391
|
+
const incompleteRequest = {
|
|
392
|
+
imageId: 'test-image-id',
|
|
393
|
+
callLoadImage: jest.fn(),
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
mockVolume.getImageLoadRequests.mockReturnValue([incompleteRequest]);
|
|
397
|
+
(getInterleavedFrames as jest.Mock).mockReturnValue([{ imageId: 'test-image-id' }]);
|
|
398
|
+
(compact as jest.Mock).mockReturnValue([incompleteRequest]);
|
|
399
|
+
(flatten as jest.Mock).mockReturnValue([incompleteRequest]);
|
|
400
|
+
|
|
401
|
+
interleaveCenterLoader(defaultParameters);
|
|
402
|
+
|
|
403
|
+
expect(imageLoadPoolManager.addRequest).toHaveBeenCalledWith(
|
|
404
|
+
expect.any(Function),
|
|
405
|
+
Enums.RequestType.Prefetch,
|
|
406
|
+
undefined,
|
|
407
|
+
0
|
|
408
|
+
);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it('should process different viewport IDs separately', () => {
|
|
412
|
+
const firstResult = interleaveCenterLoader({
|
|
413
|
+
...defaultParameters,
|
|
414
|
+
data: {
|
|
415
|
+
viewportId: 'viewport-1',
|
|
416
|
+
volumeInputArray: [mockVolumeInput],
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
const secondResult = interleaveCenterLoader({
|
|
421
|
+
...defaultParameters,
|
|
422
|
+
data: {
|
|
423
|
+
viewportId: 'viewport-2',
|
|
424
|
+
volumeInputArray: [mockVolumeInput],
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
expect(firstResult.has('viewport-1')).toBe(true);
|
|
429
|
+
expect(secondResult.has('viewport-2')).toBe(true);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it('should accumulate state across multiple calls before processing', () => {
|
|
433
|
+
const mockVolumeInput2 = {
|
|
434
|
+
volumeId: 'test-volume-id-2',
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
const mockVolume2 = {
|
|
438
|
+
metadata: {
|
|
439
|
+
SeriesInstanceUID: 'test-series-uid-2',
|
|
440
|
+
},
|
|
441
|
+
getImageLoadRequests: jest.fn().mockReturnValue([mockImageLoadRequest]),
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
(cache.getVolume as jest.Mock)
|
|
445
|
+
.mockReturnValueOnce(mockVolume)
|
|
446
|
+
.mockReturnValueOnce(mockVolume)
|
|
447
|
+
.mockReturnValueOnce(mockVolume2);
|
|
448
|
+
|
|
449
|
+
const firstCall = interleaveCenterLoader({
|
|
450
|
+
...defaultParameters,
|
|
451
|
+
data: {
|
|
452
|
+
viewportId: 'viewport-1',
|
|
453
|
+
volumeInputArray: [mockVolumeInput],
|
|
454
|
+
},
|
|
455
|
+
viewportMatchDetails: new Map([
|
|
456
|
+
[
|
|
457
|
+
'viewport-1',
|
|
458
|
+
{
|
|
459
|
+
displaySetsInfo: [
|
|
460
|
+
{ displaySetInstanceUID: 'test-volume-id' },
|
|
461
|
+
{ displaySetInstanceUID: 'missing-volume-id' },
|
|
462
|
+
],
|
|
463
|
+
},
|
|
464
|
+
],
|
|
465
|
+
]),
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
expect(firstCall).toBeUndefined();
|
|
469
|
+
|
|
470
|
+
const secondCall = interleaveCenterLoader({
|
|
471
|
+
...defaultParameters,
|
|
472
|
+
data: {
|
|
473
|
+
viewportId: 'viewport-2',
|
|
474
|
+
volumeInputArray: [mockVolumeInput2],
|
|
475
|
+
},
|
|
476
|
+
viewportMatchDetails: new Map([
|
|
477
|
+
[
|
|
478
|
+
'viewport-1',
|
|
479
|
+
{
|
|
480
|
+
displaySetsInfo: [{ displaySetInstanceUID: 'test-volume-id' }],
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
'viewport-2',
|
|
485
|
+
{
|
|
486
|
+
displaySetsInfo: [{ displaySetInstanceUID: 'test-volume-id-2' }],
|
|
487
|
+
},
|
|
488
|
+
],
|
|
489
|
+
]),
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
expect(secondCall).toBeInstanceOf(Map);
|
|
493
|
+
expect(secondCall.has('viewport-1')).toBe(true);
|
|
494
|
+
expect(secondCall.has('viewport-2')).toBe(true);
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
it('should handle volume with undefined metadata', () => {
|
|
498
|
+
const mockVolumeWithoutMetadata = {
|
|
499
|
+
getImageLoadRequests: jest.fn().mockReturnValue([]),
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
(cache.getVolume as jest.Mock).mockReturnValue(mockVolumeWithoutMetadata);
|
|
503
|
+
|
|
504
|
+
expect(() => interleaveCenterLoader(defaultParameters)).toThrow();
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('should handle multiple volumes with same image requests', () => {
|
|
508
|
+
const mockVolume2 = {
|
|
509
|
+
metadata: { SeriesInstanceUID: 'test-series-uid-2' },
|
|
510
|
+
getImageLoadRequests: jest.fn().mockReturnValue([mockImageLoadRequest]),
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
const mockVolumeInput2 = { volumeId: 'test-volume-id-2' };
|
|
514
|
+
|
|
515
|
+
(cache.getVolume as jest.Mock)
|
|
516
|
+
.mockReturnValueOnce(mockVolume)
|
|
517
|
+
.mockReturnValueOnce(mockVolume2)
|
|
518
|
+
.mockReturnValueOnce(mockVolume)
|
|
519
|
+
.mockReturnValueOnce(mockVolume2);
|
|
520
|
+
|
|
521
|
+
const mockMatchDetailsWithBothVolumes = new Map([
|
|
522
|
+
[
|
|
523
|
+
'viewport-1',
|
|
524
|
+
{
|
|
525
|
+
displaySetsInfo: [
|
|
526
|
+
{ displaySetInstanceUID: 'test-volume-id' },
|
|
527
|
+
{ displaySetInstanceUID: 'test-volume-id-2' },
|
|
528
|
+
],
|
|
529
|
+
},
|
|
530
|
+
],
|
|
531
|
+
]);
|
|
532
|
+
|
|
533
|
+
(compact as jest.Mock).mockReturnValue([mockImageLoadRequest]);
|
|
534
|
+
(flatten as jest.Mock).mockReturnValue([mockImageLoadRequest]);
|
|
535
|
+
|
|
536
|
+
interleaveCenterLoader({
|
|
537
|
+
...defaultParameters,
|
|
538
|
+
data: {
|
|
539
|
+
...defaultParameters.data,
|
|
540
|
+
volumeInputArray: [mockVolumeInput, mockVolumeInput2],
|
|
541
|
+
},
|
|
542
|
+
viewportMatchDetails: mockMatchDetailsWithBothVolumes,
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
expect(imageLoadPoolManager.addRequest).toHaveBeenCalledTimes(2);
|
|
546
|
+
});
|
|
547
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { cache, imageLoadPoolManager, Enums } from '@cornerstonejs/core';
|
|
2
|
+
import getInterleavedFrames from './getInterleavedFrames';
|
|
3
|
+
import zip from 'lodash.zip';
|
|
4
|
+
import compact from 'lodash.compact';
|
|
5
|
+
import flatten from 'lodash.flatten';
|
|
6
|
+
|
|
7
|
+
// Map of volumeId and SeriesInstanceId
|
|
8
|
+
const volumeIdMapsToLoad = new Map<string, string>();
|
|
9
|
+
const viewportIdVolumeInputArrayMap = new Map<string, unknown[]>();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This function caches the volumeUIDs until all the volumes inside the
|
|
13
|
+
* hanging protocol are initialized. Then it goes through the imageIds
|
|
14
|
+
* of the volumes, and interleave them, in order for the volumes to be loaded
|
|
15
|
+
* together from middle to the start and the end.
|
|
16
|
+
* @param {Object} props image loading properties from Cornerstone ViewportService
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export default function interleaveCenterLoader({
|
|
20
|
+
data: { viewportId, volumeInputArray },
|
|
21
|
+
displaySetsMatchDetails,
|
|
22
|
+
viewportMatchDetails: matchDetails,
|
|
23
|
+
}) {
|
|
24
|
+
viewportIdVolumeInputArrayMap.set(viewportId, volumeInputArray);
|
|
25
|
+
|
|
26
|
+
// Based on the volumeInputs store the volumeIds and SeriesInstanceIds
|
|
27
|
+
// to keep track of the volumes being loaded
|
|
28
|
+
for (const volumeInput of volumeInputArray) {
|
|
29
|
+
const { volumeId } = volumeInput;
|
|
30
|
+
const volume = cache.getVolume(volumeId);
|
|
31
|
+
|
|
32
|
+
if (!volume) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// if the volumeUID is not in the volumeUIDs array, add it
|
|
37
|
+
if (!volumeIdMapsToLoad.has(volumeId)) {
|
|
38
|
+
const { metadata } = volume;
|
|
39
|
+
volumeIdMapsToLoad.set(volumeId, metadata.SeriesInstanceUID);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The following is checking if all the viewports that were matched in the HP has been
|
|
45
|
+
* successfully created their cornerstone viewport or not. Todo: This can be
|
|
46
|
+
* improved by not checking it, and as soon as the matched DisplaySets have their
|
|
47
|
+
* volume loaded, we start the loading, but that comes at the cost of viewports
|
|
48
|
+
* not being created yet (e.g., in a 10 viewport ptCT fusion, when one ct viewport and one
|
|
49
|
+
* pt viewport are created we have a guarantee that the volumes are created in the cache
|
|
50
|
+
* but the rest of the viewports (fusion, mip etc.) are not created yet. So
|
|
51
|
+
* we can't initiate setting the volumes for those viewports. One solution can be
|
|
52
|
+
* to add an event when a viewport is created (not enabled element event) and then
|
|
53
|
+
* listen to it and as the other viewports are created we can set the volumes for them
|
|
54
|
+
* since volumes are already started loading.
|
|
55
|
+
*/
|
|
56
|
+
const uniqueViewportVolumeDisplaySetUIDs = new Set();
|
|
57
|
+
viewportIdVolumeInputArrayMap.forEach((volumeInputArray, viewportId) => {
|
|
58
|
+
volumeInputArray.forEach(volumeInput => {
|
|
59
|
+
const { volumeId } = volumeInput;
|
|
60
|
+
uniqueViewportVolumeDisplaySetUIDs.add(volumeId);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const uniqueMatchedDisplaySetUIDs = new Set();
|
|
65
|
+
|
|
66
|
+
matchDetails.forEach(matchDetail => {
|
|
67
|
+
const { displaySetsInfo } = matchDetail;
|
|
68
|
+
displaySetsInfo.forEach(({ displaySetInstanceUID }) => {
|
|
69
|
+
uniqueMatchedDisplaySetUIDs.add(displaySetInstanceUID);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (uniqueViewportVolumeDisplaySetUIDs.size !== uniqueMatchedDisplaySetUIDs.size) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const volumeIds = Array.from(volumeIdMapsToLoad.keys()).slice();
|
|
78
|
+
// get volumes from cache
|
|
79
|
+
const volumes = volumeIds.map(volumeId => {
|
|
80
|
+
return cache.getVolume(volumeId);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// iterate over all volumes, and get their imageIds, and interleave
|
|
84
|
+
// the imageIds and save them in AllRequests for later use
|
|
85
|
+
const AllRequests = [];
|
|
86
|
+
volumes.forEach(volume => {
|
|
87
|
+
const requests = volume.getImageLoadRequests?.() ?? [];
|
|
88
|
+
|
|
89
|
+
if (!requests.length || !requests[0] || !requests[0].imageId) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const requestImageIds = requests.map(request => {
|
|
94
|
+
return request.imageId;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const imageIds = getInterleavedFrames(requestImageIds);
|
|
98
|
+
|
|
99
|
+
const reOrderedRequests = imageIds.map(({ imageId }) => {
|
|
100
|
+
const request = requests.find(req => req.imageId === imageId);
|
|
101
|
+
return request;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
AllRequests.push(reOrderedRequests);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// flatten the AllRequests array, which will result in a list of all the
|
|
108
|
+
// imageIds for all the volumes but interleaved
|
|
109
|
+
const interleavedRequests = compact(flatten(zip(...AllRequests)));
|
|
110
|
+
|
|
111
|
+
// set the finalRequests to the imageLoadPoolManager
|
|
112
|
+
const finalRequests = [];
|
|
113
|
+
interleavedRequests.forEach(request => {
|
|
114
|
+
const { imageId } = request;
|
|
115
|
+
|
|
116
|
+
AllRequests.forEach(volumeRequests => {
|
|
117
|
+
const volumeImageIdRequest = volumeRequests.find(req => req.imageId === imageId);
|
|
118
|
+
if (volumeImageIdRequest) {
|
|
119
|
+
finalRequests.push(volumeImageIdRequest);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const requestType = Enums.RequestType.Prefetch;
|
|
125
|
+
const priority = 0;
|
|
126
|
+
|
|
127
|
+
finalRequests.forEach(({ callLoadImage, additionalDetails, imageId, imageIdIndex, options }) => {
|
|
128
|
+
const callLoadImageBound = callLoadImage.bind(null, imageId, imageIdIndex, options);
|
|
129
|
+
|
|
130
|
+
imageLoadPoolManager.addRequest(callLoadImageBound, requestType, additionalDetails, priority);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// clear the volumeIdMapsToLoad
|
|
134
|
+
volumeIdMapsToLoad.clear();
|
|
135
|
+
|
|
136
|
+
// copy the viewportIdVolumeInputArrayMap
|
|
137
|
+
const viewportIdVolumeInputArrayMapCopy = new Map(viewportIdVolumeInputArrayMap);
|
|
138
|
+
|
|
139
|
+
// reset the viewportIdVolumeInputArrayMap
|
|
140
|
+
viewportIdVolumeInputArrayMap.clear();
|
|
141
|
+
|
|
142
|
+
return viewportIdVolumeInputArrayMapCopy;
|
|
143
|
+
}
|