@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,206 @@
|
|
|
1
|
+
import SUPPORTED_TOOLS from './constants/supportedTools';
|
|
2
|
+
import { getIsLocked } from './utils/getIsLocked';
|
|
3
|
+
import { getIsVisible } from './utils/getIsVisible';
|
|
4
|
+
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
|
5
|
+
import { utils } from '@ohif/core';
|
|
6
|
+
|
|
7
|
+
const Length = {
|
|
8
|
+
toAnnotation: measurement => {},
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Maps cornerstone annotation event data to measurement service format.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} cornerstone Cornerstone event data
|
|
14
|
+
* @return {Measurement} Measurement instance
|
|
15
|
+
*/
|
|
16
|
+
toMeasurement: (
|
|
17
|
+
csToolsEventDetail,
|
|
18
|
+
displaySetService,
|
|
19
|
+
cornerstoneViewportService,
|
|
20
|
+
getValueTypeFromToolType,
|
|
21
|
+
customizationService
|
|
22
|
+
) => {
|
|
23
|
+
const { annotation } = csToolsEventDetail;
|
|
24
|
+
const { metadata, data, annotationUID } = annotation;
|
|
25
|
+
|
|
26
|
+
const isLocked = getIsLocked(annotationUID);
|
|
27
|
+
const isVisible = getIsVisible(annotationUID);
|
|
28
|
+
// const colorString = config.style.getStyleProperty('color', { annotationUID });
|
|
29
|
+
|
|
30
|
+
// color string is like 'rgb(255, 255, 255)' we need them to be in RGBA array [255, 255, 255, 255]
|
|
31
|
+
// Todo: this should be in a utility
|
|
32
|
+
// const color = colorString.replace('rgb(', '').replace(')', '').split(',').map(Number);
|
|
33
|
+
|
|
34
|
+
if (!metadata || !data) {
|
|
35
|
+
console.warn('Length tool: Missing metadata or data');
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { toolName, referencedImageId, FrameOfReferenceUID } = metadata;
|
|
40
|
+
const validToolType = SUPPORTED_TOOLS.includes(toolName);
|
|
41
|
+
|
|
42
|
+
if (!validToolType) {
|
|
43
|
+
throw new Error('Tool not supported');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } = getSOPInstanceAttributes(
|
|
47
|
+
referencedImageId,
|
|
48
|
+
displaySetService,
|
|
49
|
+
annotation
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
let displaySet;
|
|
53
|
+
|
|
54
|
+
if (SOPInstanceUID) {
|
|
55
|
+
displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
|
|
56
|
+
SOPInstanceUID,
|
|
57
|
+
SeriesInstanceUID
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { points, textBox } = data.handles;
|
|
64
|
+
|
|
65
|
+
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
|
66
|
+
|
|
67
|
+
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
|
68
|
+
const getReport = () =>
|
|
69
|
+
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
uid: annotationUID,
|
|
73
|
+
SOPInstanceUID,
|
|
74
|
+
FrameOfReferenceUID,
|
|
75
|
+
points,
|
|
76
|
+
textBox,
|
|
77
|
+
isLocked,
|
|
78
|
+
isVisible,
|
|
79
|
+
metadata,
|
|
80
|
+
referenceSeriesUID: SeriesInstanceUID,
|
|
81
|
+
referenceStudyUID: StudyInstanceUID,
|
|
82
|
+
referencedImageId,
|
|
83
|
+
frameNumber: mappedAnnotations[0]?.frameNumber || 1,
|
|
84
|
+
toolName: metadata.toolName,
|
|
85
|
+
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
|
86
|
+
label: data.label,
|
|
87
|
+
displayText: displayText,
|
|
88
|
+
data: data.cachedStats,
|
|
89
|
+
type: getValueTypeFromToolType(toolName),
|
|
90
|
+
getReport,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
function getMappedAnnotations(annotation, displaySetService) {
|
|
96
|
+
const { metadata, data } = annotation;
|
|
97
|
+
const { cachedStats } = data;
|
|
98
|
+
const { referencedImageId } = metadata;
|
|
99
|
+
const targets = Object.keys(cachedStats);
|
|
100
|
+
|
|
101
|
+
if (!targets.length) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const annotations = [];
|
|
106
|
+
Object.keys(cachedStats).forEach(targetId => {
|
|
107
|
+
const targetStats = cachedStats[targetId];
|
|
108
|
+
|
|
109
|
+
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } = getSOPInstanceAttributes(
|
|
110
|
+
referencedImageId,
|
|
111
|
+
displaySetService,
|
|
112
|
+
annotation
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
|
116
|
+
|
|
117
|
+
const { SeriesNumber } = displaySet;
|
|
118
|
+
const { length, unit = 'mm' } = targetStats;
|
|
119
|
+
|
|
120
|
+
annotations.push({
|
|
121
|
+
SeriesInstanceUID,
|
|
122
|
+
SOPInstanceUID,
|
|
123
|
+
SeriesNumber,
|
|
124
|
+
frameNumber,
|
|
125
|
+
unit,
|
|
126
|
+
length,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return annotations;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/*
|
|
134
|
+
This function is used to convert the measurement data to a format that is
|
|
135
|
+
suitable for the report generation (e.g. for the csv report). The report
|
|
136
|
+
returns a list of columns and corresponding values.
|
|
137
|
+
*/
|
|
138
|
+
function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService) {
|
|
139
|
+
const columns = [];
|
|
140
|
+
const values = [];
|
|
141
|
+
|
|
142
|
+
// Add Type
|
|
143
|
+
columns.push('AnnotationType');
|
|
144
|
+
values.push('Cornerstone:Length');
|
|
145
|
+
|
|
146
|
+
mappedAnnotations.forEach(annotation => {
|
|
147
|
+
const { length, unit } = annotation;
|
|
148
|
+
columns.push(`Length`);
|
|
149
|
+
values.push(length);
|
|
150
|
+
columns.push('Unit');
|
|
151
|
+
values.push(unit);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (FrameOfReferenceUID) {
|
|
155
|
+
columns.push('FrameOfReferenceUID');
|
|
156
|
+
values.push(FrameOfReferenceUID);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (points) {
|
|
160
|
+
columns.push('points');
|
|
161
|
+
// points has the form of [[x1, y1, z1], [x2, y2, z2], ...]
|
|
162
|
+
// convert it to string of [[x1 y1 z1];[x2 y2 z2];...]
|
|
163
|
+
// so that it can be used in the csv report
|
|
164
|
+
values.push(points.map(p => p.join(' ')).join(';'));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
columns,
|
|
169
|
+
values,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function getDisplayText(mappedAnnotations, displaySet) {
|
|
174
|
+
const displayText = {
|
|
175
|
+
primary: [],
|
|
176
|
+
secondary: [],
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if (!mappedAnnotations || !mappedAnnotations.length) {
|
|
180
|
+
return displayText;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Length is the same for all series
|
|
184
|
+
const { length, SeriesNumber, SOPInstanceUID, frameNumber, unit } = mappedAnnotations[0];
|
|
185
|
+
|
|
186
|
+
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
|
187
|
+
|
|
188
|
+
let InstanceNumber;
|
|
189
|
+
if (instance) {
|
|
190
|
+
InstanceNumber = instance.InstanceNumber;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
|
194
|
+
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
|
195
|
+
|
|
196
|
+
if (length === null || length === undefined) {
|
|
197
|
+
return displayText;
|
|
198
|
+
}
|
|
199
|
+
const roundedLength = utils.roundNumber(length, 2);
|
|
200
|
+
displayText.primary.push(`${roundedLength} ${unit}`);
|
|
201
|
+
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
|
202
|
+
|
|
203
|
+
return displayText;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export default Length;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import SUPPORTED_TOOLS from './constants/supportedTools';
|
|
2
|
+
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
|
3
|
+
import { getDisplayUnit } from './utils';
|
|
4
|
+
import { utils } from '@ohif/core';
|
|
5
|
+
import { getIsLocked } from './utils/getIsLocked';
|
|
6
|
+
import { getIsVisible } from './utils/getIsVisible';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a mapping utility for Livewire measurements.
|
|
9
|
+
*/
|
|
10
|
+
const LivewireContour = {
|
|
11
|
+
toAnnotation: measurement => {},
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Maps cornerstone annotation event data to measurement service format.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} csToolsEventDetail Cornerstone event data
|
|
17
|
+
* @param {DisplaySetService} DisplaySetService Service for managing display sets
|
|
18
|
+
* @param {CornerstoneViewportService} CornerstoneViewportService Service for managing viewports
|
|
19
|
+
* @param {Function} getValueTypeFromToolType Function to get value type from tool type
|
|
20
|
+
* @returns {Measurement} Measurement instance
|
|
21
|
+
*/
|
|
22
|
+
toMeasurement: (
|
|
23
|
+
csToolsEventDetail,
|
|
24
|
+
displaySetService,
|
|
25
|
+
CornerstoneViewportService,
|
|
26
|
+
getValueTypeFromToolType,
|
|
27
|
+
customizationService
|
|
28
|
+
) => {
|
|
29
|
+
const { annotation } = csToolsEventDetail;
|
|
30
|
+
const { metadata, data, annotationUID } = annotation;
|
|
31
|
+
|
|
32
|
+
const isLocked = getIsLocked(annotationUID);
|
|
33
|
+
const isVisible = getIsVisible(annotationUID);
|
|
34
|
+
if (!metadata || !data) {
|
|
35
|
+
console.warn('Livewire tool: Missing metadata or data');
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { toolName, referencedImageId, FrameOfReferenceUID } = metadata;
|
|
40
|
+
const validToolType = SUPPORTED_TOOLS.includes(toolName);
|
|
41
|
+
if (!validToolType) {
|
|
42
|
+
throw new Error(`Tool ${toolName} not supported`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { SOPInstanceUID, SeriesInstanceUID, frameNumber, StudyInstanceUID } =
|
|
46
|
+
getSOPInstanceAttributes(referencedImageId, displaySetService, annotation);
|
|
47
|
+
|
|
48
|
+
let displaySet;
|
|
49
|
+
if (SOPInstanceUID) {
|
|
50
|
+
displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
|
|
51
|
+
SOPInstanceUID,
|
|
52
|
+
SeriesInstanceUID
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
uid: annotationUID,
|
|
60
|
+
SOPInstanceUID,
|
|
61
|
+
FrameOfReferenceUID,
|
|
62
|
+
points: data.contour.polyline,
|
|
63
|
+
textBox: data.handles.textBox,
|
|
64
|
+
metadata,
|
|
65
|
+
frameNumber,
|
|
66
|
+
referenceSeriesUID: SeriesInstanceUID,
|
|
67
|
+
referencedImageId,
|
|
68
|
+
referenceStudyUID: StudyInstanceUID,
|
|
69
|
+
toolName: metadata.toolName,
|
|
70
|
+
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
|
71
|
+
label: data.label,
|
|
72
|
+
isLocked,
|
|
73
|
+
isVisible,
|
|
74
|
+
displayText: getDisplayText(annotation, displaySet, displaySetService),
|
|
75
|
+
data: data.cachedStats,
|
|
76
|
+
type: getValueTypeFromToolType(toolName),
|
|
77
|
+
getReport: () => getColumnValueReport(annotation, customizationService),
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* This function is used to convert the measurement data to a
|
|
84
|
+
* format that is suitable for report generation (e.g. for the csv report).
|
|
85
|
+
* The report returns a list of columns and corresponding values.
|
|
86
|
+
*
|
|
87
|
+
* @param {object} annotation
|
|
88
|
+
* @returns {object} Report's content from this tool
|
|
89
|
+
*/
|
|
90
|
+
function getColumnValueReport(annotation, customizationService) {
|
|
91
|
+
const columns = [];
|
|
92
|
+
const values = [];
|
|
93
|
+
|
|
94
|
+
/** Add type */
|
|
95
|
+
columns.push('AnnotationType');
|
|
96
|
+
values.push('Cornerstone:Livewire');
|
|
97
|
+
|
|
98
|
+
/** Add cachedStats */
|
|
99
|
+
const { metadata, data } = annotation;
|
|
100
|
+
|
|
101
|
+
/** Add FOR */
|
|
102
|
+
if (metadata.FrameOfReferenceUID) {
|
|
103
|
+
columns.push('FrameOfReferenceUID');
|
|
104
|
+
values.push(metadata.FrameOfReferenceUID);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Add points */
|
|
108
|
+
if (data.contour.polyline) {
|
|
109
|
+
/**
|
|
110
|
+
* Points has the form of [[x1, y1, z1], [x2, y2, z2], ...]
|
|
111
|
+
* convert it to string of [[x1 y1 z1];[x2 y2 z2];...]
|
|
112
|
+
* so that it can be used in the CSV report
|
|
113
|
+
*/
|
|
114
|
+
columns.push('points');
|
|
115
|
+
values.push(data.contour.polyline.map(p => p.join(' ')).join(';'));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return { columns, values };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Retrieves the display text for an annotation in a display set.
|
|
123
|
+
*
|
|
124
|
+
* @param {Object} annotation - The annotation object.
|
|
125
|
+
* @param {Object} displaySet - The display set object.
|
|
126
|
+
* @returns {object} - An object with primary and secondary text arrays.
|
|
127
|
+
*/
|
|
128
|
+
function getDisplayText(annotation, displaySet, displaySetService) {
|
|
129
|
+
const { metadata, data } = annotation;
|
|
130
|
+
|
|
131
|
+
const displayText = {
|
|
132
|
+
primary: [],
|
|
133
|
+
secondary: [],
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if (!data.cachedStats || !data.cachedStats[`imageId:${metadata.referencedImageId}`]) {
|
|
137
|
+
return displayText;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const { area, areaUnit } = data.cachedStats[`imageId:${metadata.referencedImageId}`];
|
|
141
|
+
|
|
142
|
+
const { SOPInstanceUID, frameNumber } = getSOPInstanceAttributes(
|
|
143
|
+
metadata.referencedImageId,
|
|
144
|
+
displaySetService,
|
|
145
|
+
annotation
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
|
149
|
+
let InstanceNumber;
|
|
150
|
+
if (instance) {
|
|
151
|
+
InstanceNumber = instance.InstanceNumber;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
|
155
|
+
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
|
156
|
+
|
|
157
|
+
const { SeriesNumber } = displaySet;
|
|
158
|
+
let seriesText = null;
|
|
159
|
+
if (SeriesNumber !== undefined) {
|
|
160
|
+
seriesText = `S: ${SeriesNumber}${instanceText}${frameText}`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (area) {
|
|
164
|
+
const roundedArea = utils.roundNumber(area || 0, 2);
|
|
165
|
+
displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (seriesText) {
|
|
169
|
+
displayText.secondary.push(seriesText);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return displayText;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export default LivewireContour;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import SUPPORTED_TOOLS from './constants/supportedTools';
|
|
2
|
+
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
|
|
3
|
+
import { utils } from '@ohif/core';
|
|
4
|
+
import { getIsLocked } from './utils/getIsLocked';
|
|
5
|
+
import { getIsVisible } from './utils/getIsVisible';
|
|
6
|
+
import { getDisplayUnit } from './utils';
|
|
7
|
+
import { getStatisticDisplayString } from './utils/getValueDisplayString';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a mapping utility for Planar Freehand ROI measurements.
|
|
10
|
+
*/
|
|
11
|
+
const PlanarFreehandROI = {
|
|
12
|
+
toAnnotation: measurement => {},
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Maps cornerstone annotation event data to measurement service format.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object} csToolsEventDetail Cornerstone event data
|
|
18
|
+
* @param {DisplaySetService} displaySetService Service for managing display sets
|
|
19
|
+
* @param {CornerstoneViewportService} CornerstoneViewportService Service for managing viewports
|
|
20
|
+
* @param {Function} getValueTypeFromToolType Function to get value type from tool type
|
|
21
|
+
* @param {CustomizationService} customizationService Service for customization
|
|
22
|
+
* @returns {Measurement | null} Measurement instance or null if invalid
|
|
23
|
+
*/
|
|
24
|
+
toMeasurement: (
|
|
25
|
+
csToolsEventDetail,
|
|
26
|
+
displaySetService,
|
|
27
|
+
CornerstoneViewportService,
|
|
28
|
+
getValueTypeFromToolType,
|
|
29
|
+
customizationService
|
|
30
|
+
) => {
|
|
31
|
+
const { annotation } = csToolsEventDetail;
|
|
32
|
+
const { metadata, data, annotationUID } = annotation;
|
|
33
|
+
|
|
34
|
+
const isLocked = getIsLocked(annotationUID);
|
|
35
|
+
const isVisible = getIsVisible(annotationUID);
|
|
36
|
+
if (!metadata || !data) {
|
|
37
|
+
console.debug('PlanarFreehandROI tool: Missing metadata or data');
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { toolName, referencedImageId, FrameOfReferenceUID } = metadata;
|
|
42
|
+
const validToolType = SUPPORTED_TOOLS.includes(toolName);
|
|
43
|
+
if (!validToolType) {
|
|
44
|
+
throw new Error(`Tool ${toolName} not supported`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const { SOPInstanceUID, SeriesInstanceUID, frameNumber, StudyInstanceUID } =
|
|
48
|
+
getSOPInstanceAttributes(referencedImageId, displaySetService, annotation);
|
|
49
|
+
|
|
50
|
+
let displaySet;
|
|
51
|
+
if (SOPInstanceUID) {
|
|
52
|
+
displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
|
|
53
|
+
SOPInstanceUID,
|
|
54
|
+
SeriesInstanceUID
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
|
|
61
|
+
const displayText = getDisplayText(mappedAnnotations, displaySet);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
uid: annotationUID,
|
|
65
|
+
SOPInstanceUID,
|
|
66
|
+
FrameOfReferenceUID,
|
|
67
|
+
points: data.contour.polyline,
|
|
68
|
+
textBox: data.handles.textBox,
|
|
69
|
+
metadata,
|
|
70
|
+
frameNumber,
|
|
71
|
+
referenceSeriesUID: SeriesInstanceUID,
|
|
72
|
+
referenceStudyUID: StudyInstanceUID,
|
|
73
|
+
referencedImageId,
|
|
74
|
+
toolName: metadata.toolName,
|
|
75
|
+
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
|
76
|
+
label: data.label,
|
|
77
|
+
displayText: displayText,
|
|
78
|
+
data: data.cachedStats,
|
|
79
|
+
type: getValueTypeFromToolType(toolName),
|
|
80
|
+
getReport: () => getColumnValueReport(annotation, customizationService),
|
|
81
|
+
isLocked,
|
|
82
|
+
isVisible,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Maps annotations to a structured format with relevant attributes.
|
|
89
|
+
*
|
|
90
|
+
* @param {Object} annotation The annotation object.
|
|
91
|
+
* @param {DisplaySetService} displaySetService Service for managing display sets.
|
|
92
|
+
* @returns {Array} Mapped annotations.
|
|
93
|
+
*/
|
|
94
|
+
function getMappedAnnotations(annotation, displaySetService) {
|
|
95
|
+
const { metadata, data } = annotation;
|
|
96
|
+
const { cachedStats } = data;
|
|
97
|
+
const { referencedImageId } = metadata;
|
|
98
|
+
|
|
99
|
+
if (!cachedStats) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const targets = Object.keys(cachedStats);
|
|
104
|
+
|
|
105
|
+
if (!targets.length) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const annotations = [];
|
|
110
|
+
Object.keys(cachedStats).forEach(targetId => {
|
|
111
|
+
const targetStats = cachedStats[targetId];
|
|
112
|
+
|
|
113
|
+
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } = getSOPInstanceAttributes(
|
|
114
|
+
referencedImageId,
|
|
115
|
+
displaySetService,
|
|
116
|
+
annotation
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
|
|
120
|
+
|
|
121
|
+
const { SeriesNumber } = displaySet;
|
|
122
|
+
const { mean, stdDev, max, area, Modality, areaUnit, modalityUnit } = targetStats;
|
|
123
|
+
|
|
124
|
+
annotations.push({
|
|
125
|
+
SeriesInstanceUID,
|
|
126
|
+
SOPInstanceUID,
|
|
127
|
+
SeriesNumber,
|
|
128
|
+
frameNumber,
|
|
129
|
+
Modality,
|
|
130
|
+
unit: modalityUnit,
|
|
131
|
+
mean,
|
|
132
|
+
stdDev,
|
|
133
|
+
max,
|
|
134
|
+
area,
|
|
135
|
+
areaUnit,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return annotations;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Converts the measurement data to a format suitable for report generation.
|
|
144
|
+
*
|
|
145
|
+
* @param {object} annotation The annotation object.
|
|
146
|
+
* @param {CustomizationService} customizationService Service for customization.
|
|
147
|
+
* @returns {object} Report's content.
|
|
148
|
+
*/
|
|
149
|
+
function getColumnValueReport(annotation, customizationService) {
|
|
150
|
+
const { PlanarFreehandROI } = customizationService.getCustomization('cornerstone.measurements');
|
|
151
|
+
const { report } = PlanarFreehandROI;
|
|
152
|
+
const columns = [];
|
|
153
|
+
const values = [];
|
|
154
|
+
|
|
155
|
+
/** Add type */
|
|
156
|
+
columns.push('AnnotationType');
|
|
157
|
+
values.push('Cornerstone:PlanarFreehandROI');
|
|
158
|
+
|
|
159
|
+
/** Add cachedStats */
|
|
160
|
+
const { metadata, data } = annotation;
|
|
161
|
+
const stats = data.cachedStats[`imageId:${metadata.referencedImageId}`];
|
|
162
|
+
|
|
163
|
+
report.forEach(({ displayName, value }) => {
|
|
164
|
+
columns.push(displayName);
|
|
165
|
+
stats[value] ? values.push(stats[value]) : values.push('not available');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
/** Add FOR */
|
|
169
|
+
if (metadata.FrameOfReferenceUID) {
|
|
170
|
+
columns.push('FrameOfReferenceUID');
|
|
171
|
+
values.push(metadata.FrameOfReferenceUID);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Add points */
|
|
175
|
+
if (data.contour.polyline) {
|
|
176
|
+
columns.push('points');
|
|
177
|
+
values.push(data.contour.polyline.map(p => p.join(' ')).join(';'));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return { columns, values };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Retrieves the display text for an annotation in a display set.
|
|
185
|
+
*
|
|
186
|
+
* @param {Array} mappedAnnotations The mapped annotations.
|
|
187
|
+
* @param {Object} displaySet The display set object.
|
|
188
|
+
* @returns {Object} Display text with primary and secondary information.
|
|
189
|
+
*/
|
|
190
|
+
function getDisplayText(mappedAnnotations, displaySet) {
|
|
191
|
+
const displayText = {
|
|
192
|
+
primary: [],
|
|
193
|
+
secondary: [],
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
if (!mappedAnnotations || !mappedAnnotations.length) {
|
|
197
|
+
return displayText;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Area is the same for all series
|
|
201
|
+
const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
|
|
202
|
+
|
|
203
|
+
const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
|
|
204
|
+
|
|
205
|
+
let InstanceNumber;
|
|
206
|
+
if (instance) {
|
|
207
|
+
InstanceNumber = instance.InstanceNumber;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
|
|
211
|
+
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
|
|
212
|
+
|
|
213
|
+
const roundedArea = utils.roundNumber(area || 0, 2);
|
|
214
|
+
displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
|
|
215
|
+
|
|
216
|
+
mappedAnnotations.forEach(mappedAnnotation => {
|
|
217
|
+
const { unit, max, SeriesNumber } = mappedAnnotation;
|
|
218
|
+
|
|
219
|
+
const maxStr = getStatisticDisplayString(max, unit, 'max');
|
|
220
|
+
|
|
221
|
+
displayText.primary.push(maxStr);
|
|
222
|
+
displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return displayText;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export default PlanarFreehandROI;
|