@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.
Files changed (328) hide show
  1. package/dist/915.ohif-extension-cornerstone.umd.js +1 -1
  2. package/dist/ohif-extension-cornerstone.umd.js +1 -5
  3. package/package.json +33 -25
  4. package/src/Viewport/OHIFCornerstoneViewport.css +46 -0
  5. package/src/Viewport/OHIFCornerstoneViewport.tsx +502 -0
  6. package/src/Viewport/Overlays/CornerstoneOverlays.tsx +103 -0
  7. package/src/Viewport/Overlays/CustomizableViewportOverlay.css +25 -0
  8. package/src/Viewport/Overlays/CustomizableViewportOverlay.tsx +469 -0
  9. package/src/Viewport/Overlays/ViewportImageScrollbar.tsx +106 -0
  10. package/src/Viewport/Overlays/ViewportImageSliceLoadingIndicator.tsx +87 -0
  11. package/src/Viewport/Overlays/ViewportOrientationMarkers.css +41 -0
  12. package/src/Viewport/Overlays/ViewportOrientationMarkers.tsx +136 -0
  13. package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/ViewportSliceProgressScrollbar.tsx +195 -0
  14. package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/helpers.ts +46 -0
  15. package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/hooks.ts +383 -0
  16. package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/index.ts +1 -0
  17. package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/types.ts +17 -0
  18. package/src/Viewport/Overlays/utils.ts +66 -0
  19. package/src/commandsModule.ts +2962 -0
  20. package/src/components/AccordionGroup/AccordionGroup.tsx +195 -0
  21. package/src/components/AccordionGroup/index.ts +4 -0
  22. package/src/components/ActiveViewportWindowLevel/ActiveViewportWindowLevel.tsx +23 -0
  23. package/src/components/ActiveViewportWindowLevel/index.js +1 -0
  24. package/src/components/AdvancedRenderingControls/AdvancedRenderingControls.tsx +149 -0
  25. package/src/components/AdvancedRenderingControls/index.ts +1 -0
  26. package/src/components/CinePlayer/CinePlayer.tsx +247 -0
  27. package/src/components/CinePlayer/index.ts +3 -0
  28. package/src/components/DicomUpload/DicomUpload.tsx +111 -0
  29. package/src/components/DicomUpload/DicomUploadProgress.tsx +396 -0
  30. package/src/components/DicomUpload/DicomUploadProgressItem.tsx +119 -0
  31. package/src/components/ExportSegmentationSubMenuItem.tsx +75 -0
  32. package/src/components/FidelityIndicator/FidelityIndicator.tsx +152 -0
  33. package/src/components/FidelityIndicator/index.ts +1 -0
  34. package/src/components/MeasurementItems.tsx +70 -0
  35. package/src/components/MeasurementTableNested.tsx +30 -0
  36. package/src/components/MeasurementsMenu.tsx +84 -0
  37. package/src/components/MeasurementsOrAdditionalFindings.tsx +82 -0
  38. package/src/components/ModalityLoadBadge/ModalityLoadBadge.tsx +171 -0
  39. package/src/components/ModalityLoadBadge/index.ts +1 -0
  40. package/src/components/NavigationComponent/NavigationComponent.tsx +138 -0
  41. package/src/components/NavigationComponent/index.ts +3 -0
  42. package/src/components/OHIFViewportActionCorners.tsx +109 -0
  43. package/src/components/OpacityMenu/OpacityMenu.tsx +54 -0
  44. package/src/components/OpacityMenu/OpacityMenuWrapper.tsx +85 -0
  45. package/src/components/OpacityMenu/index.ts +2 -0
  46. package/src/components/PanelAccordionTrigger.tsx +48 -0
  47. package/src/components/SegmentationToolConfig.tsx +71 -0
  48. package/src/components/SegmentationUtilityButton.tsx +61 -0
  49. package/src/components/SelectItemWithModality.tsx +29 -0
  50. package/src/components/SeriesMeasurements.tsx +90 -0
  51. package/src/components/SeriesSummaryFromDisplaySet.tsx +21 -0
  52. package/src/components/StudyMeasurements.tsx +88 -0
  53. package/src/components/StudyMeasurementsActions.tsx +75 -0
  54. package/src/components/StudySummaryFromMetadata.test.ts +47 -0
  55. package/src/components/StudySummaryFromMetadata.tsx +31 -0
  56. package/src/components/StudySummaryWithActions.tsx +14 -0
  57. package/src/components/ThresholdMenu/ThresholdMenu.tsx +104 -0
  58. package/src/components/ThresholdMenu/ThresholdMenuWrapper.tsx +85 -0
  59. package/src/components/ThresholdMenu/index.ts +2 -0
  60. package/src/components/TrackingStatus/TrackingStatus.tsx +32 -0
  61. package/src/components/TrackingStatus/index.ts +1 -0
  62. package/src/components/VOIManualControlMenu/VOIManualControlMenu.tsx +190 -0
  63. package/src/components/VOIManualControlMenu/VOIManualControlMenuWrapper.tsx +85 -0
  64. package/src/components/VOIManualControlMenu/index.ts +2 -0
  65. package/src/components/ViewportColorbar/ViewportColorbar.tsx +150 -0
  66. package/src/components/ViewportColorbar/ViewportColorbarsContainer.tsx +125 -0
  67. package/src/components/ViewportColorbar/index.ts +5 -0
  68. package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenu.tsx +538 -0
  69. package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenuWrapper.tsx +91 -0
  70. package/src/components/ViewportDataOverlaySettingMenu/utils.ts +118 -0
  71. package/src/components/ViewportOrientationMenu/ViewportOrientationMenu.tsx +249 -0
  72. package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +29 -0
  73. package/src/components/ViewportWindowLevel/ViewportWindowLevel.tsx +261 -0
  74. package/src/components/ViewportWindowLevel/getViewportVolumeHistogram.ts +72 -0
  75. package/src/components/ViewportWindowLevel/histogramWorker.js +97 -0
  76. package/src/components/ViewportWindowLevel/index.js +1 -0
  77. package/src/components/ViewportWindowLevel/utils.ts +176 -0
  78. package/src/components/WindowLevelActionMenu/Colorbar.tsx +30 -0
  79. package/src/components/WindowLevelActionMenu/Colormap.tsx +121 -0
  80. package/src/components/WindowLevelActionMenu/VolumeLighting.tsx +82 -0
  81. package/src/components/WindowLevelActionMenu/VolumeRenderingOptions.tsx +38 -0
  82. package/src/components/WindowLevelActionMenu/VolumeRenderingPresets.tsx +36 -0
  83. package/src/components/WindowLevelActionMenu/VolumeRenderingPresetsContent.tsx +78 -0
  84. package/src/components/WindowLevelActionMenu/VolumeRenderingQuality.tsx +64 -0
  85. package/src/components/WindowLevelActionMenu/VolumeShade.tsx +47 -0
  86. package/src/components/WindowLevelActionMenu/VolumeShift.tsx +92 -0
  87. package/src/components/WindowLevelActionMenu/WindowLevel.tsx +157 -0
  88. package/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx +102 -0
  89. package/src/components/WindowLevelActionMenu/WindowLevelActionMenuWrapper.tsx +131 -0
  90. package/src/components/WindowLevelActionMenu/defaultWindowLevelPresets.ts +23 -0
  91. package/src/components/WindowLevelActionMenu/index.ts +11 -0
  92. package/src/components/WindowLevelActionMenu/windowLevelPresetHotkeys.test.ts +19 -0
  93. package/src/components/index.ts +13 -0
  94. package/src/constants/index.ts +13 -0
  95. package/src/customizations/CustomDropdownMenuContent.tsx +106 -0
  96. package/src/customizations/CustomSegmentStatisticsHeader.tsx +140 -0
  97. package/src/customizations/captureViewportModalCustomization.tsx +175 -0
  98. package/src/customizations/colorbarCustomization.ts +93 -0
  99. package/src/customizations/gpuSettingsPresetCustomization.ts +8 -0
  100. package/src/customizations/layoutSelectorCustomization.ts +104 -0
  101. package/src/customizations/measurementsCustomization.ts +124 -0
  102. package/src/customizations/miscCustomization.ts +22 -0
  103. package/src/customizations/modalityColorMapCustomization.ts +23 -0
  104. package/src/customizations/segmentationHydrationCustomization.ts +16 -0
  105. package/src/customizations/segmentationPanelCustomization.tsx +119 -0
  106. package/src/customizations/segmentationToolbarCustomization.ts +964 -0
  107. package/src/customizations/toolGroupToolsCustomization.ts +204 -0
  108. package/src/customizations/toolbarButtonsCustomization.ts +805 -0
  109. package/src/customizations/viewportClickCommandsCustomization.ts +15 -0
  110. package/src/customizations/viewportDownloadWarningCustomization.tsx +6 -0
  111. package/src/customizations/viewportOverlayCustomization.tsx +46 -0
  112. package/src/customizations/viewportScrollbarCustomization.tsx +27 -0
  113. package/src/customizations/viewportToolsCustomization.ts +33 -0
  114. package/src/customizations/volumeRenderingCustomization.ts +14 -0
  115. package/src/customizations/windowLevelPresetsCustomization.ts +5 -0
  116. package/src/enums.ts +9 -0
  117. package/src/getCustomizationModule.tsx +54 -0
  118. package/src/getHangingProtocolModule.ts +47 -0
  119. package/src/getPanelModule.tsx +128 -0
  120. package/src/getSopClassHandlerModule.js +284 -0
  121. package/src/getToolbarModule.tsx +622 -0
  122. package/src/hooks/index.ts +9 -0
  123. package/src/hooks/useActiveViewportSegmentationRepresentations.ts +14 -0
  124. package/src/hooks/useMeasurementTracking.ts +132 -0
  125. package/src/hooks/useMeasurements.ts +104 -0
  126. package/src/hooks/useSegmentations.ts +147 -0
  127. package/src/hooks/useViewportDisplaySets.ts +284 -0
  128. package/src/hooks/useViewportFidelity.ts +243 -0
  129. package/src/hooks/useViewportHover.ts +77 -0
  130. package/src/hooks/useViewportRendering.tsx +868 -0
  131. package/src/hooks/useViewportSegmentations.ts +245 -0
  132. package/src/hps/fourUp.ts +117 -0
  133. package/src/hps/frameView.ts +1581 -0
  134. package/src/hps/main3D.ts +142 -0
  135. package/src/hps/mpr.ts +197 -0
  136. package/src/hps/mprAnd3DVolumeViewport.ts +124 -0
  137. package/src/hps/only3D.ts +70 -0
  138. package/src/hps/primary3D.ts +142 -0
  139. package/src/hps/primaryAxial.ts +114 -0
  140. package/src/id.js +5 -0
  141. package/src/index.tsx +350 -0
  142. package/src/init.tsx +448 -0
  143. package/src/initCineService.ts +75 -0
  144. package/src/initContextMenu.ts +94 -0
  145. package/src/initCornerstoneTools.js +188 -0
  146. package/src/initDoubleClick.ts +82 -0
  147. package/src/initMeasurementService.ts +576 -0
  148. package/src/initStudyPrefetcherService.ts +33 -0
  149. package/src/initWADOImageLoader.js +56 -0
  150. package/src/panels/PanelMeasurement.tsx +84 -0
  151. package/src/panels/PanelSegmentation.tsx +338 -0
  152. package/src/services/ColorbarService/ColorbarService.ts +242 -0
  153. package/src/services/ColorbarService/index.ts +2 -0
  154. package/src/services/CornerstoneCacheService/CornerstoneCacheService.ts +326 -0
  155. package/src/services/CornerstoneCacheService/index.js +3 -0
  156. package/src/services/SegmentationService/RTSTRUCT/mapROIContoursToRTStructData.ts +36 -0
  157. package/src/services/SegmentationService/SegmentationService.test.ts +3698 -0
  158. package/src/services/SegmentationService/SegmentationService.ts +2376 -0
  159. package/src/services/SegmentationService/backends/ISegmentationBackend.ts +102 -0
  160. package/src/services/SegmentationService/backends/ISegmentationServiceInternals.ts +44 -0
  161. package/src/services/SegmentationService/backends/LegacySegmentationBackend.ts +139 -0
  162. package/src/services/SegmentationService/backends/NextSegmentationBackend.ts +159 -0
  163. package/src/services/SegmentationService/backends/index.ts +4 -0
  164. package/src/services/SegmentationService/index.ts +3 -0
  165. package/src/services/SyncGroupService/SyncGroupService.ts +264 -0
  166. package/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts +118 -0
  167. package/src/services/SyncGroupService/index.js +3 -0
  168. package/src/services/ToolGroupService/ToolGroupService.test.ts +83 -0
  169. package/src/services/ToolGroupService/ToolGroupService.ts +541 -0
  170. package/src/services/ToolGroupService/index.js +3 -0
  171. package/src/services/ViewedDataService/ViewedDataService.ts +58 -0
  172. package/src/services/ViewedDataService/index.ts +3 -0
  173. package/src/services/ViewportService/CornerstoneViewportService.ts +1814 -0
  174. package/src/services/ViewportService/IViewportService.ts +64 -0
  175. package/src/services/ViewportService/Viewport.ts +372 -0
  176. package/src/services/ViewportService/adapter/IViewportAdapter.contract.test.ts +467 -0
  177. package/src/services/ViewportService/adapter/IViewportAdapter.ts +179 -0
  178. package/src/services/ViewportService/adapter/LegacyViewportAdapter.ts +240 -0
  179. package/src/services/ViewportService/adapter/NextViewportAdapter.ts +241 -0
  180. package/src/services/ViewportService/adapter/getViewportAdapter.ts +62 -0
  181. package/src/services/ViewportService/adapter/index.ts +16 -0
  182. package/src/services/ViewportService/backends/IViewportBackend.ts +195 -0
  183. package/src/services/ViewportService/backends/IViewportOperations.ts +98 -0
  184. package/src/services/ViewportService/backends/IViewportServiceInternals.ts +47 -0
  185. package/src/services/ViewportService/backends/LegacyViewportBackend.ts +264 -0
  186. package/src/services/ViewportService/backends/LegacyViewportOperations.ts +272 -0
  187. package/src/services/ViewportService/backends/NextViewportBackend.ts +671 -0
  188. package/src/services/ViewportService/backends/NextViewportOperations.ts +169 -0
  189. package/src/services/ViewportService/backends/README.md +62 -0
  190. package/src/services/ViewportService/backends/dataIdRegistry.ts +121 -0
  191. package/src/services/ViewportService/backends/viewportOperations.ts +71 -0
  192. package/src/services/ViewportService/constants.ts +3 -0
  193. package/src/state.ts +34 -0
  194. package/src/stores/index.ts +5 -0
  195. package/src/stores/presentationUtils.ts +42 -0
  196. package/src/stores/useLutPresentationStore.ts +166 -0
  197. package/src/stores/usePositionPresentationStore.ts +172 -0
  198. package/src/stores/useSegmentationPresentationStore.test.ts +146 -0
  199. package/src/stores/useSegmentationPresentationStore.ts +417 -0
  200. package/src/stores/useSelectedSegmentationsForViewportStore.ts +85 -0
  201. package/src/stores/useSynchronizersStore.ts +84 -0
  202. package/src/synchronizers/frameViewSynchronizer.ts +52 -0
  203. package/src/tools/CalibrationLineTool.ts +97 -0
  204. package/src/tools/ImageOverlayViewerTool.tsx +279 -0
  205. package/src/tools/OverlayPlaneModuleProvider.ts +40 -0
  206. package/src/tools/WindowLevelTool.test.ts +55 -0
  207. package/src/tools/WindowLevelTool.ts +22 -0
  208. package/src/types/AppTypes.ts +70 -0
  209. package/src/types/Colorbar.ts +114 -0
  210. package/src/types/Colormap.ts +16 -0
  211. package/src/types/CornerstoneCacheService.ts +40 -0
  212. package/src/types/CornerstoneServices.ts +18 -0
  213. package/src/types/Presentation.ts +83 -0
  214. package/src/types/SelectedSegmentationByTypeMap.ts +3 -0
  215. package/src/types/ViewportPresets.ts +53 -0
  216. package/src/types/VolumeLighting.ts +7 -0
  217. package/src/types/VolumeRenderingConfig.ts +8 -0
  218. package/src/types/WindowLevel.ts +5 -0
  219. package/src/types/index.ts +10 -0
  220. package/src/utils/ActiveViewportBehavior.tsx +80 -0
  221. package/src/utils/CornerstoneViewportDownloadForm.tsx +319 -0
  222. package/src/utils/DicomFileUploader.ts +204 -0
  223. package/src/utils/JumpPresets.ts +14 -0
  224. package/src/utils/autoHydrateViewportTypes.ts +69 -0
  225. package/src/utils/colormaps.js +1597 -0
  226. package/src/utils/createSegmentationForViewport.ts +83 -0
  227. package/src/utils/dicomLoaderService.js +225 -0
  228. package/src/utils/ecgMetadata.test.ts +137 -0
  229. package/src/utils/ecgMetadata.ts +109 -0
  230. package/src/utils/findNearbyToolData.test.ts +125 -0
  231. package/src/utils/findNearbyToolData.ts +21 -0
  232. package/src/utils/generateSegmentationCSVReport.test.ts +324 -0
  233. package/src/utils/generateSegmentationCSVReport.ts +131 -0
  234. package/src/utils/getActiveViewportEnabledElement.test.ts +70 -0
  235. package/src/utils/getActiveViewportEnabledElement.ts +8 -0
  236. package/src/utils/getCenterExtent.test.ts +313 -0
  237. package/src/utils/getCenterExtent.ts +46 -0
  238. package/src/utils/getCornerstoneBlendMode.test.ts +59 -0
  239. package/src/utils/getCornerstoneBlendMode.ts +25 -0
  240. package/src/utils/getCornerstoneOrientation.test.ts +78 -0
  241. package/src/utils/getCornerstoneOrientation.ts +31 -0
  242. package/src/utils/getCornerstoneViewportType.test.ts +169 -0
  243. package/src/utils/getCornerstoneViewportType.ts +88 -0
  244. package/src/utils/getInterleavedFrames.test.ts +85 -0
  245. package/src/utils/getInterleavedFrames.ts +73 -0
  246. package/src/utils/getLegacyViewportType.ts +64 -0
  247. package/src/utils/getNthFrames.test.ts +145 -0
  248. package/src/utils/getNthFrames.ts +31 -0
  249. package/src/utils/getViewportEnabledElement.test.ts +83 -0
  250. package/src/utils/getViewportEnabledElement.ts +8 -0
  251. package/src/utils/getViewportOrientationFromImageOrientationPatient.test.ts +50 -0
  252. package/src/utils/getViewportOrientationFromImageOrientationPatient.ts +56 -0
  253. package/src/utils/hydrationUtils.test.ts +572 -0
  254. package/src/utils/hydrationUtils.ts +197 -0
  255. package/src/utils/imageSliceSync/calculateViewportRegistrations.ts +28 -0
  256. package/src/utils/imageSliceSync/toggleImageSliceSync.ts +101 -0
  257. package/src/utils/index.ts +29 -0
  258. package/src/utils/initGpuSettingsPreset.ts +51 -0
  259. package/src/utils/initViewTiming.test.ts +342 -0
  260. package/src/utils/initViewTiming.ts +52 -0
  261. package/src/utils/initWebWorkerProgressHandler.test.ts +381 -0
  262. package/src/utils/initWebWorkerProgressHandler.ts +110 -0
  263. package/src/utils/interleave.test.ts +304 -0
  264. package/src/utils/interleave.ts +32 -0
  265. package/src/utils/interleaveCenterLoader.test.ts +547 -0
  266. package/src/utils/interleaveCenterLoader.ts +143 -0
  267. package/src/utils/interleaveTopToBottom.test.ts +487 -0
  268. package/src/utils/interleaveTopToBottom.ts +132 -0
  269. package/src/utils/isAnyDisplaySetCommon.ts +18 -0
  270. package/src/utils/isDisplaySetOverlayable.ts +96 -0
  271. package/src/utils/isMeasurementWithinViewport.test.ts +340 -0
  272. package/src/utils/isMeasurementWithinViewport.ts +33 -0
  273. package/src/utils/isReferenceViewable.test.ts +581 -0
  274. package/src/utils/isReferenceViewable.ts +95 -0
  275. package/src/utils/loadDisplaySetData.ts +49 -0
  276. package/src/utils/measurementServiceMappings/Angle.ts +200 -0
  277. package/src/utils/measurementServiceMappings/ArrowAnnotate.ts +176 -0
  278. package/src/utils/measurementServiceMappings/Bidirectional.ts +193 -0
  279. package/src/utils/measurementServiceMappings/CircleROI.ts +227 -0
  280. package/src/utils/measurementServiceMappings/CobbAngle.ts +206 -0
  281. package/src/utils/measurementServiceMappings/EllipticalROI.ts +221 -0
  282. package/src/utils/measurementServiceMappings/Length.ts +206 -0
  283. package/src/utils/measurementServiceMappings/LivewireContour.ts +175 -0
  284. package/src/utils/measurementServiceMappings/PlanarFreehandROI.ts +228 -0
  285. package/src/utils/measurementServiceMappings/Probe.ts +192 -0
  286. package/src/utils/measurementServiceMappings/RectangleROI.ts +225 -0
  287. package/src/utils/measurementServiceMappings/SegmentBidirectional.ts +184 -0
  288. package/src/utils/measurementServiceMappings/SplineROI.ts +227 -0
  289. package/src/utils/measurementServiceMappings/UltrasoundDirectional.ts +214 -0
  290. package/src/utils/measurementServiceMappings/UltrasoundPleuraBLine.ts +179 -0
  291. package/src/utils/measurementServiceMappings/constants/supportedTools.js +21 -0
  292. package/src/utils/measurementServiceMappings/index.ts +3 -0
  293. package/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts +324 -0
  294. package/src/utils/measurementServiceMappings/utils/getDisplayUnit.js +3 -0
  295. package/src/utils/measurementServiceMappings/utils/getHandlesFromPoints.js +14 -0
  296. package/src/utils/measurementServiceMappings/utils/getIsLocked.ts +5 -0
  297. package/src/utils/measurementServiceMappings/utils/getIsVisible.ts +6 -0
  298. package/src/utils/measurementServiceMappings/utils/getSOPInstanceAttributes.js +66 -0
  299. package/src/utils/measurementServiceMappings/utils/getValueDisplayString.js +12 -0
  300. package/src/utils/measurementServiceMappings/utils/index.ts +17 -0
  301. package/src/utils/measurementServiceMappings/utils/selection.ts +33 -0
  302. package/src/utils/mpr/getProtocolViewportStructureFromGridViewports.ts +74 -0
  303. package/src/utils/nextViewportPolicies.ts +41 -0
  304. package/src/utils/nextViewports.ts +157 -0
  305. package/src/utils/nthLoader.test.ts +317 -0
  306. package/src/utils/nthLoader.ts +78 -0
  307. package/src/utils/presentations/getViewportPresentations.test.ts +280 -0
  308. package/src/utils/presentations/getViewportPresentations.ts +151 -0
  309. package/src/utils/promptHydrationDialog.test.ts +490 -0
  310. package/src/utils/promptHydrationDialog.ts +197 -0
  311. package/src/utils/removeViewportSegmentationRepresentations.test.ts +129 -0
  312. package/src/utils/removeViewportSegmentationRepresentations.ts +17 -0
  313. package/src/utils/segmentUtils.test.ts +515 -0
  314. package/src/utils/segmentUtils.ts +46 -0
  315. package/src/utils/segmentationExportUtils.test.ts +100 -0
  316. package/src/utils/segmentationExportUtils.ts +171 -0
  317. package/src/utils/segmentationHandlers.test.ts +614 -0
  318. package/src/utils/segmentationHandlers.ts +164 -0
  319. package/src/utils/setUpAnnotationEventHandlers.ts +26 -0
  320. package/src/utils/setUpSegmentationEventHandlers.test.ts +372 -0
  321. package/src/utils/setUpSegmentationEventHandlers.ts +122 -0
  322. package/src/utils/toggleVOISliceSync.test.ts +606 -0
  323. package/src/utils/toggleVOISliceSync.ts +103 -0
  324. package/src/utils/transitions.test.ts +351 -0
  325. package/src/utils/transitions.ts +300 -0
  326. package/src/utils/updateSegmentationStats.test.ts +942 -0
  327. package/src/utils/updateSegmentationStats.ts +192 -0
  328. package/src/utils/viewportDataShape.ts +85 -0
@@ -0,0 +1,15 @@
1
+ export default {
2
+ cornerstoneViewportClickCommands: {
3
+ doubleClick: ['toggleOneUp'],
4
+ button1: ['closeContextMenu'],
5
+ button3: [
6
+ {
7
+ commandName: 'showCornerstoneContextMenu',
8
+ commandOptions: {
9
+ requireNearbyToolData: true,
10
+ menuId: 'measurementsContextMenu',
11
+ },
12
+ },
13
+ ],
14
+ },
15
+ };
@@ -0,0 +1,6 @@
1
+ export default {
2
+ 'viewportDownload.warningMessage': {
3
+ enabled: true,
4
+ value: 'Not For Diagnostic Use',
5
+ },
6
+ };
@@ -0,0 +1,46 @@
1
+ export default {
2
+ 'viewportOverlay.topLeft': [
3
+ {
4
+ id: 'StudyDate',
5
+ inheritsFrom: 'ohif.overlayItem',
6
+ label: '',
7
+ title: 'Study date',
8
+ condition: ({ referenceInstance }) => referenceInstance?.StudyDate,
9
+ contentF: ({ referenceInstance, formatters: { formatDate } }) =>
10
+ formatDate(referenceInstance.StudyDate),
11
+ },
12
+ {
13
+ id: 'SeriesDescription',
14
+ inheritsFrom: 'ohif.overlayItem',
15
+ label: '',
16
+ title: 'Series description',
17
+ condition: ({ referenceInstance }) => {
18
+ return referenceInstance && referenceInstance.SeriesDescription;
19
+ },
20
+ contentF: ({ referenceInstance }) => referenceInstance.SeriesDescription,
21
+ },
22
+ ],
23
+ 'viewportOverlay.topRight': [],
24
+ 'viewportOverlay.bottomLeft': [
25
+ {
26
+ id: 'WindowLevel',
27
+ inheritsFrom: 'ohif.overlayItem.windowLevel',
28
+ title: 'Window Level',
29
+ },
30
+ {
31
+ id: 'ZoomLevel',
32
+ inheritsFrom: 'ohif.overlayItem.zoomLevel',
33
+ condition: props => {
34
+ const activeToolName = props.toolGroupService.getActiveToolForViewport(props.viewportId);
35
+ return activeToolName === 'Zoom';
36
+ },
37
+ },
38
+ ],
39
+ 'viewportOverlay.bottomRight': [
40
+ {
41
+ id: 'InstanceNumber',
42
+ inheritsFrom: 'ohif.overlayItem.instanceNumber',
43
+ title: 'Instance Number',
44
+ },
45
+ ],
46
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Default customization values for viewport scrollbar behavior.
3
+ * The `progress` scrollbar variant is in full mode for stack viewports and
4
+ * acquisition-plane orthographic viewports.
5
+ * Otherwise, viewports using the `progress` scrollbar show only the indicator.
6
+ *
7
+ * - `viewportScrollbar.variant`: `'progress' | 'legacy'` (default: `'progress'`)
8
+ * - `viewportScrollbar.showLoadedEndpoints`: show loaded-range endpoint caps in full mode
9
+ * - `viewportScrollbar.showLoadedFill`: show loaded/cached fill in full mode
10
+ * - `viewportScrollbar.showViewedFill`: show viewed fill in full mode
11
+ * - `viewportScrollbar.showLoadingPattern`: show loading pattern in full mode while not fully loaded
12
+ * - `viewportScrollbar.viewedDwellMs`: delay before marking current image viewed in full mode (ms)
13
+ * - `viewportScrollbar.loadedBatchIntervalMs`: loaded-state version batch interval in full mode (ms)
14
+ * - `viewportScrollbar.indicator`: optional custom indicator config
15
+ */
16
+ export default function getViewportScrollbarCustomization() {
17
+ return {
18
+ 'viewportScrollbar.variant': 'progress',
19
+ 'viewportScrollbar.showLoadedEndpoints': true,
20
+ 'viewportScrollbar.showLoadedFill': true,
21
+ 'viewportScrollbar.showViewedFill': true,
22
+ 'viewportScrollbar.showLoadingPattern': true,
23
+ 'viewportScrollbar.viewedDwellMs': 0,
24
+ 'viewportScrollbar.loadedBatchIntervalMs': 200,
25
+ 'viewportScrollbar.indicator': {},
26
+ };
27
+ }
@@ -0,0 +1,33 @@
1
+ import { Enums } from '@cornerstonejs/tools';
2
+ import { toolNames } from '../initCornerstoneTools';
3
+
4
+ export default {
5
+ 'cornerstone.overlayViewportTools': {
6
+ active: [
7
+ {
8
+ toolName: toolNames.WindowLevel,
9
+ bindings: [{ mouseButton: Enums.MouseBindings.Primary }],
10
+ },
11
+ {
12
+ toolName: toolNames.Pan,
13
+ bindings: [{ mouseButton: Enums.MouseBindings.Auxiliary }],
14
+ },
15
+ {
16
+ toolName: toolNames.Zoom,
17
+ bindings: [{ mouseButton: Enums.MouseBindings.Secondary }, { numTouchPoints: 2 }],
18
+ },
19
+ {
20
+ toolName: toolNames.StackScroll,
21
+ bindings: [{ mouseButton: Enums.MouseBindings.Wheel }, { numTouchPoints: 3 }],
22
+ },
23
+ ],
24
+ enabled: [
25
+ {
26
+ toolName: toolNames.PlanarFreehandContourSegmentation,
27
+ configuration: {
28
+ displayOnePointAsCrosshairs: true,
29
+ },
30
+ },
31
+ ],
32
+ },
33
+ };
@@ -0,0 +1,14 @@
1
+ import { CONSTANTS } from '@cornerstonejs/core';
2
+
3
+ const { VIEWPORT_PRESETS } = CONSTANTS;
4
+
5
+ export default {
6
+ 'cornerstone.3dVolumeRendering': {
7
+ volumeRenderingPresets: VIEWPORT_PRESETS,
8
+ volumeRenderingQualityRange: {
9
+ min: 1,
10
+ max: 4,
11
+ step: 1,
12
+ },
13
+ },
14
+ };
@@ -0,0 +1,5 @@
1
+ import defaultWindowLevelPresets from '../components/WindowLevelActionMenu/defaultWindowLevelPresets';
2
+
3
+ export default {
4
+ 'cornerstone.windowLevelPresets': defaultWindowLevelPresets,
5
+ };
package/src/enums.ts ADDED
@@ -0,0 +1,9 @@
1
+ export const CORNERSTONE_3D_TOOLS_SOURCE_NAME = 'Cornerstone3DTools';
2
+ export const CORNERSTONE_3D_TOOLS_SOURCE_VERSION = '0.1';
3
+
4
+ const Enums = {
5
+ CORNERSTONE_3D_TOOLS_SOURCE_NAME,
6
+ CORNERSTONE_3D_TOOLS_SOURCE_VERSION,
7
+ };
8
+
9
+ export default Enums;
@@ -0,0 +1,54 @@
1
+ import viewportOverlayCustomization from './customizations/viewportOverlayCustomization';
2
+ import getSegmentationPanelCustomization from './customizations/segmentationPanelCustomization';
3
+ import layoutSelectorCustomization from './customizations/layoutSelectorCustomization';
4
+ import viewportToolsCustomization from './customizations/viewportToolsCustomization';
5
+ import viewportClickCommandsCustomization from './customizations/viewportClickCommandsCustomization';
6
+ import measurementsCustomization from './customizations/measurementsCustomization';
7
+ import volumeRenderingCustomization from './customizations/volumeRenderingCustomization';
8
+ import colorbarCustomization from './customizations/colorbarCustomization';
9
+ import modalityColorMapCustomization from './customizations/modalityColorMapCustomization';
10
+ import segmentationHydrationCustomization from './customizations/segmentationHydrationCustomization';
11
+ import windowLevelPresetsCustomization from './customizations/windowLevelPresetsCustomization';
12
+ import toolbarButtonsCustomization from './customizations/toolbarButtonsCustomization';
13
+ import segmentationToolbarCustomization from './customizations/segmentationToolbarCustomization';
14
+ import getToolGroupToolsCustomization from './customizations/toolGroupToolsCustomization';
15
+ import miscCustomization from './customizations/miscCustomization';
16
+ import captureViewportModalCustomization from './customizations/captureViewportModalCustomization';
17
+ import viewportDownloadWarningCustomization from './customizations/viewportDownloadWarningCustomization';
18
+ import getViewportScrollbarCustomization from './customizations/viewportScrollbarCustomization';
19
+ import gpuSettingsPresetCustomization from './customizations/gpuSettingsPresetCustomization';
20
+
21
+ function getCustomizationModule({ commandsManager, servicesManager, extensionManager }) {
22
+ return [
23
+ {
24
+ name: 'default',
25
+ value: {
26
+ ...viewportOverlayCustomization,
27
+ ...getSegmentationPanelCustomization({
28
+ commandsManager,
29
+ servicesManager,
30
+ extensionManager,
31
+ }),
32
+ ...layoutSelectorCustomization,
33
+ ...viewportToolsCustomization,
34
+ ...viewportClickCommandsCustomization,
35
+ ...measurementsCustomization,
36
+ ...volumeRenderingCustomization,
37
+ ...colorbarCustomization,
38
+ ...modalityColorMapCustomization,
39
+ ...segmentationHydrationCustomization,
40
+ ...windowLevelPresetsCustomization,
41
+ ...toolbarButtonsCustomization,
42
+ ...segmentationToolbarCustomization,
43
+ ...getToolGroupToolsCustomization({ commandsManager }),
44
+ ...miscCustomization,
45
+ ...captureViewportModalCustomization,
46
+ ...viewportDownloadWarningCustomization,
47
+ ...getViewportScrollbarCustomization(),
48
+ ...gpuSettingsPresetCustomization,
49
+ },
50
+ },
51
+ ];
52
+ }
53
+
54
+ export default getCustomizationModule;
@@ -0,0 +1,47 @@
1
+ import { fourUp } from './hps/fourUp';
2
+ import { main3D } from './hps/main3D';
3
+ import { mpr } from './hps/mpr';
4
+ import { mprAnd3DVolumeViewport } from './hps/mprAnd3DVolumeViewport';
5
+ import { only3D } from './hps/only3D';
6
+ import { primary3D } from './hps/primary3D';
7
+ import { primaryAxial } from './hps/primaryAxial';
8
+ import { frameView } from './hps/frameView';
9
+
10
+ function getHangingProtocolModule() {
11
+ return [
12
+ {
13
+ name: mpr.id,
14
+ protocol: mpr,
15
+ },
16
+ {
17
+ name: mprAnd3DVolumeViewport.id,
18
+ protocol: mprAnd3DVolumeViewport,
19
+ },
20
+ {
21
+ name: fourUp.id,
22
+ protocol: fourUp,
23
+ },
24
+ {
25
+ name: main3D.id,
26
+ protocol: main3D,
27
+ },
28
+ {
29
+ name: primaryAxial.id,
30
+ protocol: primaryAxial,
31
+ },
32
+ {
33
+ name: only3D.id,
34
+ protocol: only3D,
35
+ },
36
+ {
37
+ name: primary3D.id,
38
+ protocol: primary3D,
39
+ },
40
+ {
41
+ name: frameView.id,
42
+ protocol: frameView,
43
+ },
44
+ ];
45
+ }
46
+
47
+ export default getHangingProtocolModule;
@@ -0,0 +1,128 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Toolbox } from '@ohif/extension-default';
4
+ import PanelSegmentation from './panels/PanelSegmentation';
5
+ import ActiveViewportWindowLevel from './components/ActiveViewportWindowLevel';
6
+ import PanelMeasurement from './panels/PanelMeasurement';
7
+ import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
8
+ import i18n from '@ohif/i18n';
9
+
10
+ const getPanelModule = ({ commandsManager, servicesManager, extensionManager }: withAppTypes) => {
11
+ const { toolbarService } = servicesManager.services;
12
+
13
+ const toolSectionMap = {
14
+ [SegmentationRepresentations.Labelmap]: toolbarService.sections.labelMapSegmentationToolbox,
15
+ [SegmentationRepresentations.Contour]: toolbarService.sections.contourSegmentationToolbox,
16
+ };
17
+
18
+ const wrappedPanelSegmentation = props => {
19
+ return (
20
+ <PanelSegmentation
21
+ commandsManager={commandsManager}
22
+ servicesManager={servicesManager}
23
+ extensionManager={extensionManager}
24
+ configuration={{
25
+ ...props?.configuration,
26
+ }}
27
+ segmentationRepresentationTypes={props?.segmentationRepresentationTypes}
28
+ />
29
+ );
30
+ };
31
+
32
+ const wrappedPanelSegmentationNoHeader = props => {
33
+ return (
34
+ <PanelSegmentation
35
+ commandsManager={commandsManager}
36
+ servicesManager={servicesManager}
37
+ extensionManager={extensionManager}
38
+ configuration={{
39
+ ...props?.configuration,
40
+ }}
41
+ segmentationRepresentationTypes={props?.segmentationRepresentationTypes}
42
+ />
43
+ );
44
+ };
45
+
46
+ const PanelSegmentationWithTools = props => {
47
+ const { t } = useTranslation('SegmentationPanel');
48
+ const tKey = `${props.segmentationRepresentationTypes?.[0] ?? 'Segmentation'} tools`;
49
+ const tValue = t(tKey);
50
+
51
+ return (
52
+ <>
53
+ <Toolbox
54
+ buttonSectionId={toolSectionMap[props.segmentationRepresentationTypes?.[0]]}
55
+ title={tValue}
56
+ />
57
+ <PanelSegmentation
58
+ commandsManager={commandsManager}
59
+ servicesManager={servicesManager}
60
+ extensionManager={extensionManager}
61
+ configuration={{
62
+ ...props?.configuration,
63
+ }}
64
+ segmentationRepresentationTypes={props?.segmentationRepresentationTypes}
65
+ />
66
+ </>
67
+ );
68
+ };
69
+
70
+ return [
71
+ {
72
+ name: 'activeViewportWindowLevel',
73
+ component: () => {
74
+ return <ActiveViewportWindowLevel servicesManager={servicesManager} />;
75
+ },
76
+ },
77
+ {
78
+ name: 'panelMeasurement',
79
+ iconName: 'tab-linear',
80
+ iconLabel: 'Measure',
81
+ label: 'Measurement',
82
+ component: PanelMeasurement,
83
+ },
84
+ {
85
+ name: 'panelSegmentation',
86
+ iconName: 'tab-segmentation',
87
+ iconLabel: 'Segmentation',
88
+ label: 'Segmentation',
89
+ component: wrappedPanelSegmentation,
90
+ },
91
+ {
92
+ name: 'panelSegmentationNoHeader',
93
+ iconName: 'tab-segmentation',
94
+ iconLabel: 'Segmentation',
95
+ label: 'Segmentation',
96
+ component: wrappedPanelSegmentationNoHeader,
97
+ },
98
+ {
99
+ name: 'panelSegmentationWithToolsLabelMap',
100
+ iconName: 'tab-segmentation',
101
+ iconLabel: 'Segmentation',
102
+ label: i18n.t('SegmentationPanel:Labelmap'),
103
+ component: props => (
104
+ <PanelSegmentationWithTools
105
+ {...props}
106
+ segmentationRepresentationTypes={[
107
+ SegmentationRepresentations.Labelmap,
108
+ SegmentationRepresentations.Surface,
109
+ ]}
110
+ />
111
+ ),
112
+ },
113
+ {
114
+ name: 'panelSegmentationWithToolsContour',
115
+ iconName: 'tab-contours',
116
+ iconLabel: 'Segmentation',
117
+ label: i18n.t('SegmentationPanel:Contour'),
118
+ component: props => (
119
+ <PanelSegmentationWithTools
120
+ {...props}
121
+ segmentationRepresentationTypes={[SegmentationRepresentations.Contour]}
122
+ />
123
+ ),
124
+ },
125
+ ];
126
+ };
127
+
128
+ export default getPanelModule;
@@ -0,0 +1,284 @@
1
+ import OHIF from '@ohif/core';
2
+ import i18n from '@ohif/i18n';
3
+ import { utilities as csUtils, Enums as csEnums } from '@cornerstonejs/core';
4
+ import { utilities as csMetadataUtilities } from '@cornerstonejs/metadata';
5
+ import dcmjs from 'dcmjs';
6
+ import { dicomWebUtils } from '@ohif/extension-default';
7
+ import { buildEcgModule } from './utils/ecgMetadata';
8
+
9
+ const { MetadataModules } = csEnums;
10
+ const { utils } = OHIF;
11
+ const { denaturalizeDataset } = dcmjs.data.DicomMetaDictionary;
12
+ // NOTE: access transferDenaturalizedDataset / fixMultiValueKeys lazily (at call
13
+ // time) rather than destructuring here. This module and @ohif/extension-default
14
+ // form a circular import, so dicomWebUtils can be undefined at module-eval time
15
+ // depending on bundler eval order; a top-level destructure then throws and
16
+ // crashes app boot.
17
+
18
+ const SOP_CLASS_UIDS = {
19
+ VL_WHOLE_SLIDE_MICROSCOPY_IMAGE_STORAGE: '1.2.840.10008.5.1.4.1.1.77.1.6',
20
+ };
21
+
22
+ const SOPClassHandlerId =
23
+ '@ohif/extension-cornerstone.sopClassHandlerModule.DicomMicroscopySopClassHandler';
24
+
25
+ /**
26
+ * Adds the whole slide fields to `displaySet`, from all of its instances (the
27
+ * levels of the image pyramid), and registers the DICOMweb client of the
28
+ * slide. Shared by the legacy builder and the split-rule path (the
29
+ * `wholeSlide` handler).
30
+ */
31
+ function extendWholeSlideDisplaySet(displaySet, { extensionManager }) {
32
+ const dataSource = extensionManager.getActiveDataSource()[0];
33
+ let { instances } = displaySet;
34
+ const instance = instances[0];
35
+
36
+ let singleFrameInstance = instance;
37
+ let currentFrames = +singleFrameInstance.NumberOfFrames || 1;
38
+ for (const instanceI of instances) {
39
+ const framesI = +instanceI.NumberOfFrames || 1;
40
+ if (framesI < currentFrames) {
41
+ singleFrameInstance = instanceI;
42
+ currentFrames = framesI;
43
+ }
44
+ }
45
+
46
+ const {
47
+ FrameOfReferenceUID,
48
+ SeriesDescription,
49
+ ContentDate,
50
+ ContentTime,
51
+ SeriesNumber,
52
+ StudyInstanceUID,
53
+ SeriesInstanceUID,
54
+ SOPInstanceUID,
55
+ SOPClassUID,
56
+ } = instance;
57
+
58
+ instances = instances.map(inst => {
59
+ // NOTE: According to DICOM standard a series should have a FrameOfReferenceUID
60
+ // When the Microscopy file was built by certain tool from multiple image files,
61
+ // each instance's FrameOfReferenceUID is sometimes different.
62
+ // Even though this means the file was not well formatted DICOM VL Whole Slide Microscopy Image,
63
+ // the case is so often, so let's override this value manually here.
64
+ //
65
+ // https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.4.html#sect_C.7.4.1.1.1
66
+
67
+ inst.FrameOfReferenceUID = instance.FrameOfReferenceUID;
68
+
69
+ return inst;
70
+ });
71
+
72
+ const othersFrameOfReferenceUID = instances
73
+ .filter(v => v)
74
+ .map(inst => inst.FrameOfReferenceUID)
75
+ .filter((value, index, array) => array.indexOf(value) === index);
76
+ if (othersFrameOfReferenceUID.length > 1) {
77
+ console.warn(
78
+ 'Expected FrameOfReferenceUID of difference instances within a series to be the same, found multiple different values',
79
+ othersFrameOfReferenceUID
80
+ );
81
+ }
82
+
83
+ Object.assign(displaySet, {
84
+ plugin: 'microscopy',
85
+ Modality: 'SM',
86
+ viewportType: csEnums.ViewportType.WHOLE_SLIDE,
87
+ altImageText: 'Microscopy',
88
+ SOPInstanceUID,
89
+ SeriesInstanceUID,
90
+ StudyInstanceUID,
91
+ FrameOfReferenceUID,
92
+ SOPClassHandlerId,
93
+ SOPClassUID,
94
+ SeriesDescription: SeriesDescription || 'Microscopy Data',
95
+ // Map ContentDate/Time to SeriesTime for series list sorting.
96
+ SeriesDate: ContentDate,
97
+ SeriesTime: ContentTime,
98
+ SeriesNumber,
99
+ firstInstance: singleFrameInstance, // top level instance in the image Pyramid
100
+ instance,
101
+ numImageFrames: 0,
102
+ numInstances: 1,
103
+ others: instances, // all other level instances in the image Pyramid
104
+ othersFrameOfReferenceUID,
105
+ imageIds: instances.map(instance => instance.imageId),
106
+ getThumbnailSrc: dataSource.retrieve.getGetThumbnailSrc?.(
107
+ singleFrameInstance,
108
+ singleFrameInstance.imageId
109
+ ),
110
+ label: SeriesDescription || `${i18n.t('Series')} ${SeriesNumber} - ${i18n.t('SM')}`,
111
+ });
112
+ // The microscopy viewer directly accesses the metadata already loaded, and
113
+ // uses the DICOMweb client library directly for loading, so it has to be
114
+ // provided here.
115
+ const dicomWebClient = dataSource.retrieve.getWadoDicomWebClient?.();
116
+ const instanceMap = new Map();
117
+ instances.forEach(instance => instanceMap.set(instance.imageId, instance));
118
+ if (dicomWebClient) {
119
+ const webClient = Object.create(dicomWebClient);
120
+ // This replaces just the dicom web metadata call with one which retrieves
121
+ // internally.
122
+ webClient.getDICOMwebMetadata = getDICOMwebMetadata.bind(webClient, instanceMap);
123
+
124
+ csUtils.genericMetadataProvider.addRaw(displaySet.imageIds[0], {
125
+ type: MetadataModules.WADO_WEB_CLIENT,
126
+ metadata: webClient,
127
+ });
128
+ } else {
129
+ // Might have some other way of getting the data in the future or internally?
130
+ // throw new Error('Unable to provide a DICOMWeb client library, microscopy will fail to view');
131
+ }
132
+ }
133
+
134
+ function _getDisplaySetsFromSeries(instances, servicesManager, extensionManager) {
135
+ // If the series has no instances, stop here
136
+ if (!instances || !instances.length) {
137
+ throw new Error('No instances were provided');
138
+ }
139
+
140
+ const displaySet = { displaySetInstanceUID: utils.guid(), instances };
141
+ extendWholeSlideDisplaySet(displaySet, { extensionManager });
142
+ return [displaySet];
143
+ }
144
+
145
+ /**
146
+ * This method provides access to the internal DICOMweb metadata, used to avoid
147
+ * refetching the DICOMweb data. It gets assigned as a member function to the
148
+ * dicom web client.
149
+ */
150
+ function getDICOMwebMetadata(instanceMap, imageId) {
151
+ const instance = instanceMap.get(imageId);
152
+ if (!instance) {
153
+ console.warn('Metadata not already found for', imageId, 'in', instanceMap);
154
+ return this.super.getDICOMwebMetadata(imageId);
155
+ }
156
+ return dicomWebUtils.transferDenaturalizedDataset(
157
+ denaturalizeDataset(dicomWebUtils.fixMultiValueKeys(instanceMap.get(imageId)))
158
+ );
159
+ }
160
+
161
+ export function getDicomMicroscopySopClassHandler({ servicesManager, extensionManager }) {
162
+ const getDisplaySetsFromSeries = instances => {
163
+ return _getDisplaySetsFromSeries(instances, servicesManager, extensionManager);
164
+ };
165
+
166
+ return {
167
+ name: 'DicomMicroscopySopClassHandler',
168
+ sopClassUids: [SOP_CLASS_UIDS.VL_WHOLE_SLIDE_MICROSCOPY_IMAGE_STORAGE],
169
+ getDisplaySetsFromSeries,
170
+ handlerNames: ['wholeSlide'],
171
+ extendDisplaySet: extendWholeSlideDisplaySet,
172
+ };
173
+ }
174
+
175
+ /**
176
+ * DICOM Waveform SOP Class UIDs for ECG / cardiac electrophysiology.
177
+ * Reference: https://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_B.5.html
178
+ */
179
+ const ECG_SOP_CLASS_UIDS = {
180
+ TWELVE_LEAD_ECG_WAVEFORM_STORAGE: '1.2.840.10008.5.1.4.1.1.9.1.1',
181
+ GENERAL_ECG_WAVEFORM_STORAGE: '1.2.840.10008.5.1.4.1.1.9.1.2',
182
+ AMBULATORY_ECG_WAVEFORM_STORAGE: '1.2.840.10008.5.1.4.1.1.9.1.3',
183
+ HEMODYNAMIC_WAVEFORM_STORAGE: '1.2.840.10008.5.1.4.1.1.9.2.1',
184
+ CARDIAC_ELECTROPHYSIOLOGY_WAVEFORM_STORAGE: '1.2.840.10008.5.1.4.1.1.9.3.1',
185
+ };
186
+
187
+ const ecgSopClassUids = Object.values(ECG_SOP_CLASS_UIDS);
188
+
189
+ const DicomEcgSOPClassHandlerId =
190
+ '@ohif/extension-cornerstone.sopClassHandlerModule.DicomEcgSopClassHandler';
191
+
192
+ /**
193
+ * The ECG fields of a display set that shows `instance`, and the registration
194
+ * of its ECG metadata. Shared by the legacy builder and
195
+ * {@link extendEcgDisplaySet}.
196
+ */
197
+ function getEcgFields(instance, servicesManager) {
198
+ const { userAuthenticationService } = servicesManager.services;
199
+ const { Modality, SOPInstanceUID } = instance;
200
+ const { SeriesDescription, SeriesNumber, SeriesDate } = instance;
201
+ const { SOPClassUID } = instance;
202
+ const imageId = instance.imageId;
203
+
204
+ // Register ECG metadata in the OHIF metadata provider so that
205
+ // Cornerstone's ECGViewport can retrieve it via metaData.get('ecgModule', imageId).
206
+ if (imageId) {
207
+ const ecgModule = buildEcgModule(instance, userAuthenticationService);
208
+ if (ecgModule) {
209
+ csUtils.genericMetadataProvider.addRaw(imageId, {
210
+ type: MetadataModules.ECG,
211
+ metadata: ecgModule,
212
+ });
213
+ // The time and mV region, so measurement tools report physical units
214
+ const calibration = csMetadataUtilities.buildEcgCalibrationFromInstance(instance);
215
+ if (calibration) {
216
+ csUtils.genericMetadataProvider.addRaw(imageId, {
217
+ type: MetadataModules.CALIBRATION,
218
+ metadata: calibration,
219
+ });
220
+ }
221
+ }
222
+ }
223
+
224
+ return {
225
+ Modality,
226
+ SeriesDescription,
227
+ SeriesNumber,
228
+ SeriesDate,
229
+ SOPInstanceUID,
230
+ SOPClassHandlerId: DicomEcgSOPClassHandlerId,
231
+ SOPClassUID,
232
+ referencedImages: null,
233
+ measurements: null,
234
+ viewportType: csEnums.ViewportType.ECG,
235
+ instance,
236
+ thumbnailSrc: null,
237
+ isDerivedDisplaySet: false,
238
+ isLoaded: false,
239
+ sopClassUids: ecgSopClassUids,
240
+ numImageFrames: 0,
241
+ numInstances: 1,
242
+ imageIds: imageId ? [imageId] : [],
243
+ supportsWindowLevel: false,
244
+ label: SeriesDescription || 'ECG',
245
+ };
246
+ }
247
+
248
+ function _getEcgDisplaySetsFromSeries(instances, servicesManager) {
249
+ return instances.map(instance => {
250
+ const { SeriesInstanceUID, StudyInstanceUID } = instance;
251
+ return {
252
+ ...getEcgFields(instance, servicesManager),
253
+ displaySetInstanceUID: utils.guid(),
254
+ SeriesInstanceUID,
255
+ StudyInstanceUID,
256
+ instances: [instance],
257
+ };
258
+ });
259
+ }
260
+
261
+ /**
262
+ * Adds the ECG fields to a display set that a split rule with the `ecg`
263
+ * handler made. The display set shows its first instance.
264
+ */
265
+ function extendEcgDisplaySet(displaySet, { servicesManager }) {
266
+ Object.assign(displaySet, getEcgFields(displaySet.instances[0], servicesManager));
267
+ }
268
+
269
+ export function getDicomEcgSopClassHandler({ servicesManager }) {
270
+ const getDisplaySetsFromSeries = instances =>
271
+ _getEcgDisplaySetsFromSeries(instances, servicesManager);
272
+
273
+ return {
274
+ name: 'DicomEcgSopClassHandler',
275
+ sopClassUids: ecgSopClassUids,
276
+ getDisplaySetsFromSeries,
277
+ handlerNames: ['ecg'],
278
+ extendDisplaySet: extendEcgDisplaySet,
279
+ };
280
+ }
281
+
282
+ export function getSopClassHandlerModule(params) {
283
+ return [getDicomMicroscopySopClassHandler(params), getDicomEcgSopClassHandler(params)];
284
+ }