@ohif/extension-cornerstone 3.14.0-beta.1 → 3.14.0-beta.100

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 (325) 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 +2951 -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/MeasurementItems.tsx +70 -0
  33. package/src/components/MeasurementTableNested.tsx +30 -0
  34. package/src/components/MeasurementsMenu.tsx +84 -0
  35. package/src/components/MeasurementsOrAdditionalFindings.tsx +82 -0
  36. package/src/components/ModalityLoadBadge/ModalityLoadBadge.tsx +171 -0
  37. package/src/components/ModalityLoadBadge/index.ts +1 -0
  38. package/src/components/NavigationComponent/NavigationComponent.tsx +138 -0
  39. package/src/components/NavigationComponent/index.ts +3 -0
  40. package/src/components/OHIFViewportActionCorners.tsx +94 -0
  41. package/src/components/OpacityMenu/OpacityMenu.tsx +54 -0
  42. package/src/components/OpacityMenu/OpacityMenuWrapper.tsx +85 -0
  43. package/src/components/OpacityMenu/index.ts +2 -0
  44. package/src/components/PanelAccordionTrigger.tsx +48 -0
  45. package/src/components/SegmentationToolConfig.tsx +71 -0
  46. package/src/components/SegmentationUtilityButton.tsx +61 -0
  47. package/src/components/SelectItemWithModality.tsx +29 -0
  48. package/src/components/SeriesMeasurements.tsx +90 -0
  49. package/src/components/SeriesSummaryFromDisplaySet.tsx +21 -0
  50. package/src/components/StudyMeasurements.tsx +88 -0
  51. package/src/components/StudyMeasurementsActions.tsx +75 -0
  52. package/src/components/StudySummaryFromMetadata.test.ts +47 -0
  53. package/src/components/StudySummaryFromMetadata.tsx +31 -0
  54. package/src/components/StudySummaryWithActions.tsx +14 -0
  55. package/src/components/ThresholdMenu/ThresholdMenu.tsx +104 -0
  56. package/src/components/ThresholdMenu/ThresholdMenuWrapper.tsx +85 -0
  57. package/src/components/ThresholdMenu/index.ts +2 -0
  58. package/src/components/TrackingStatus/TrackingStatus.tsx +32 -0
  59. package/src/components/TrackingStatus/index.ts +1 -0
  60. package/src/components/VOIManualControlMenu/VOIManualControlMenu.tsx +190 -0
  61. package/src/components/VOIManualControlMenu/VOIManualControlMenuWrapper.tsx +85 -0
  62. package/src/components/VOIManualControlMenu/index.ts +2 -0
  63. package/src/components/ViewportColorbar/ViewportColorbar.tsx +150 -0
  64. package/src/components/ViewportColorbar/ViewportColorbarsContainer.tsx +125 -0
  65. package/src/components/ViewportColorbar/index.ts +5 -0
  66. package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenu.tsx +538 -0
  67. package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenuWrapper.tsx +91 -0
  68. package/src/components/ViewportDataOverlaySettingMenu/utils.ts +118 -0
  69. package/src/components/ViewportOrientationMenu/ViewportOrientationMenu.tsx +249 -0
  70. package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +29 -0
  71. package/src/components/ViewportWindowLevel/ViewportWindowLevel.tsx +261 -0
  72. package/src/components/ViewportWindowLevel/getViewportVolumeHistogram.ts +72 -0
  73. package/src/components/ViewportWindowLevel/histogramWorker.js +97 -0
  74. package/src/components/ViewportWindowLevel/index.js +1 -0
  75. package/src/components/ViewportWindowLevel/utils.ts +176 -0
  76. package/src/components/WindowLevelActionMenu/Colorbar.tsx +30 -0
  77. package/src/components/WindowLevelActionMenu/Colormap.tsx +121 -0
  78. package/src/components/WindowLevelActionMenu/VolumeLighting.tsx +82 -0
  79. package/src/components/WindowLevelActionMenu/VolumeRenderingOptions.tsx +38 -0
  80. package/src/components/WindowLevelActionMenu/VolumeRenderingPresets.tsx +36 -0
  81. package/src/components/WindowLevelActionMenu/VolumeRenderingPresetsContent.tsx +78 -0
  82. package/src/components/WindowLevelActionMenu/VolumeRenderingQuality.tsx +64 -0
  83. package/src/components/WindowLevelActionMenu/VolumeShade.tsx +47 -0
  84. package/src/components/WindowLevelActionMenu/VolumeShift.tsx +92 -0
  85. package/src/components/WindowLevelActionMenu/WindowLevel.tsx +157 -0
  86. package/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx +102 -0
  87. package/src/components/WindowLevelActionMenu/WindowLevelActionMenuWrapper.tsx +131 -0
  88. package/src/components/WindowLevelActionMenu/defaultWindowLevelPresets.ts +23 -0
  89. package/src/components/WindowLevelActionMenu/index.ts +11 -0
  90. package/src/components/WindowLevelActionMenu/windowLevelPresetHotkeys.test.ts +19 -0
  91. package/src/components/index.ts +12 -0
  92. package/src/constants/index.ts +13 -0
  93. package/src/customizations/CustomDropdownMenuContent.tsx +106 -0
  94. package/src/customizations/CustomSegmentStatisticsHeader.tsx +140 -0
  95. package/src/customizations/captureViewportModalCustomization.tsx +175 -0
  96. package/src/customizations/colorbarCustomization.ts +93 -0
  97. package/src/customizations/gpuSettingsPresetCustomization.ts +8 -0
  98. package/src/customizations/layoutSelectorCustomization.ts +104 -0
  99. package/src/customizations/measurementsCustomization.ts +124 -0
  100. package/src/customizations/miscCustomization.ts +22 -0
  101. package/src/customizations/modalityColorMapCustomization.ts +23 -0
  102. package/src/customizations/segmentationHydrationCustomization.ts +16 -0
  103. package/src/customizations/segmentationPanelCustomization.tsx +119 -0
  104. package/src/customizations/segmentationToolbarCustomization.ts +964 -0
  105. package/src/customizations/toolGroupToolsCustomization.ts +204 -0
  106. package/src/customizations/toolbarButtonsCustomization.ts +805 -0
  107. package/src/customizations/viewportClickCommandsCustomization.ts +15 -0
  108. package/src/customizations/viewportDownloadWarningCustomization.tsx +6 -0
  109. package/src/customizations/viewportOverlayCustomization.tsx +46 -0
  110. package/src/customizations/viewportScrollbarCustomization.tsx +27 -0
  111. package/src/customizations/viewportToolsCustomization.ts +33 -0
  112. package/src/customizations/volumeRenderingCustomization.ts +14 -0
  113. package/src/customizations/windowLevelPresetsCustomization.ts +5 -0
  114. package/src/enums.ts +9 -0
  115. package/src/getCustomizationModule.tsx +54 -0
  116. package/src/getHangingProtocolModule.ts +47 -0
  117. package/src/getPanelModule.tsx +128 -0
  118. package/src/getSopClassHandlerModule.js +284 -0
  119. package/src/getToolbarModule.tsx +622 -0
  120. package/src/hooks/index.ts +8 -0
  121. package/src/hooks/useActiveViewportSegmentationRepresentations.ts +14 -0
  122. package/src/hooks/useMeasurementTracking.ts +132 -0
  123. package/src/hooks/useMeasurements.ts +104 -0
  124. package/src/hooks/useSegmentations.ts +147 -0
  125. package/src/hooks/useViewportDisplaySets.ts +284 -0
  126. package/src/hooks/useViewportHover.ts +77 -0
  127. package/src/hooks/useViewportRendering.tsx +868 -0
  128. package/src/hooks/useViewportSegmentations.ts +245 -0
  129. package/src/hps/fourUp.ts +117 -0
  130. package/src/hps/frameView.ts +1581 -0
  131. package/src/hps/main3D.ts +142 -0
  132. package/src/hps/mpr.ts +197 -0
  133. package/src/hps/mprAnd3DVolumeViewport.ts +124 -0
  134. package/src/hps/only3D.ts +70 -0
  135. package/src/hps/primary3D.ts +142 -0
  136. package/src/hps/primaryAxial.ts +114 -0
  137. package/src/id.js +5 -0
  138. package/src/index.tsx +350 -0
  139. package/src/init.tsx +445 -0
  140. package/src/initCineService.ts +75 -0
  141. package/src/initContextMenu.ts +94 -0
  142. package/src/initCornerstoneTools.js +188 -0
  143. package/src/initDoubleClick.ts +82 -0
  144. package/src/initMeasurementService.ts +576 -0
  145. package/src/initStudyPrefetcherService.ts +33 -0
  146. package/src/initWADOImageLoader.js +56 -0
  147. package/src/panels/PanelMeasurement.tsx +84 -0
  148. package/src/panels/PanelSegmentation.tsx +338 -0
  149. package/src/services/ColorbarService/ColorbarService.ts +242 -0
  150. package/src/services/ColorbarService/index.ts +2 -0
  151. package/src/services/CornerstoneCacheService/CornerstoneCacheService.ts +326 -0
  152. package/src/services/CornerstoneCacheService/index.js +3 -0
  153. package/src/services/SegmentationService/RTSTRUCT/mapROIContoursToRTStructData.ts +36 -0
  154. package/src/services/SegmentationService/SegmentationService.test.ts +3698 -0
  155. package/src/services/SegmentationService/SegmentationService.ts +2376 -0
  156. package/src/services/SegmentationService/backends/ISegmentationBackend.ts +102 -0
  157. package/src/services/SegmentationService/backends/ISegmentationServiceInternals.ts +44 -0
  158. package/src/services/SegmentationService/backends/LegacySegmentationBackend.ts +139 -0
  159. package/src/services/SegmentationService/backends/NextSegmentationBackend.ts +159 -0
  160. package/src/services/SegmentationService/backends/index.ts +4 -0
  161. package/src/services/SegmentationService/index.ts +3 -0
  162. package/src/services/SyncGroupService/SyncGroupService.ts +264 -0
  163. package/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts +118 -0
  164. package/src/services/SyncGroupService/index.js +3 -0
  165. package/src/services/ToolGroupService/ToolGroupService.test.ts +83 -0
  166. package/src/services/ToolGroupService/ToolGroupService.ts +541 -0
  167. package/src/services/ToolGroupService/index.js +3 -0
  168. package/src/services/ViewedDataService/ViewedDataService.ts +58 -0
  169. package/src/services/ViewedDataService/index.ts +3 -0
  170. package/src/services/ViewportService/CornerstoneViewportService.ts +1814 -0
  171. package/src/services/ViewportService/IViewportService.ts +64 -0
  172. package/src/services/ViewportService/Viewport.ts +372 -0
  173. package/src/services/ViewportService/adapter/IViewportAdapter.contract.test.ts +467 -0
  174. package/src/services/ViewportService/adapter/IViewportAdapter.ts +179 -0
  175. package/src/services/ViewportService/adapter/LegacyViewportAdapter.ts +240 -0
  176. package/src/services/ViewportService/adapter/NextViewportAdapter.ts +241 -0
  177. package/src/services/ViewportService/adapter/getViewportAdapter.ts +62 -0
  178. package/src/services/ViewportService/adapter/index.ts +16 -0
  179. package/src/services/ViewportService/backends/IViewportBackend.ts +195 -0
  180. package/src/services/ViewportService/backends/IViewportOperations.ts +98 -0
  181. package/src/services/ViewportService/backends/IViewportServiceInternals.ts +47 -0
  182. package/src/services/ViewportService/backends/LegacyViewportBackend.ts +264 -0
  183. package/src/services/ViewportService/backends/LegacyViewportOperations.ts +272 -0
  184. package/src/services/ViewportService/backends/NextViewportBackend.ts +671 -0
  185. package/src/services/ViewportService/backends/NextViewportOperations.ts +169 -0
  186. package/src/services/ViewportService/backends/README.md +62 -0
  187. package/src/services/ViewportService/backends/dataIdRegistry.ts +121 -0
  188. package/src/services/ViewportService/backends/viewportOperations.ts +71 -0
  189. package/src/services/ViewportService/constants.ts +3 -0
  190. package/src/state.ts +34 -0
  191. package/src/stores/index.ts +5 -0
  192. package/src/stores/presentationUtils.ts +42 -0
  193. package/src/stores/useLutPresentationStore.ts +166 -0
  194. package/src/stores/usePositionPresentationStore.ts +172 -0
  195. package/src/stores/useSegmentationPresentationStore.test.ts +146 -0
  196. package/src/stores/useSegmentationPresentationStore.ts +417 -0
  197. package/src/stores/useSelectedSegmentationsForViewportStore.ts +85 -0
  198. package/src/stores/useSynchronizersStore.ts +84 -0
  199. package/src/synchronizers/frameViewSynchronizer.ts +52 -0
  200. package/src/tools/CalibrationLineTool.ts +97 -0
  201. package/src/tools/ImageOverlayViewerTool.tsx +279 -0
  202. package/src/tools/OverlayPlaneModuleProvider.ts +40 -0
  203. package/src/tools/WindowLevelTool.test.ts +55 -0
  204. package/src/tools/WindowLevelTool.ts +22 -0
  205. package/src/types/AppTypes.ts +70 -0
  206. package/src/types/Colorbar.ts +114 -0
  207. package/src/types/Colormap.ts +16 -0
  208. package/src/types/CornerstoneCacheService.ts +40 -0
  209. package/src/types/CornerstoneServices.ts +18 -0
  210. package/src/types/Presentation.ts +83 -0
  211. package/src/types/SelectedSegmentationByTypeMap.ts +3 -0
  212. package/src/types/ViewportPresets.ts +53 -0
  213. package/src/types/VolumeLighting.ts +7 -0
  214. package/src/types/VolumeRenderingConfig.ts +8 -0
  215. package/src/types/WindowLevel.ts +5 -0
  216. package/src/types/index.ts +10 -0
  217. package/src/utils/ActiveViewportBehavior.tsx +80 -0
  218. package/src/utils/CornerstoneViewportDownloadForm.tsx +319 -0
  219. package/src/utils/DicomFileUploader.ts +204 -0
  220. package/src/utils/JumpPresets.ts +14 -0
  221. package/src/utils/autoHydrateViewportTypes.ts +69 -0
  222. package/src/utils/colormaps.js +1597 -0
  223. package/src/utils/createSegmentationForViewport.ts +83 -0
  224. package/src/utils/dicomLoaderService.js +225 -0
  225. package/src/utils/ecgMetadata.test.ts +137 -0
  226. package/src/utils/ecgMetadata.ts +109 -0
  227. package/src/utils/findNearbyToolData.test.ts +125 -0
  228. package/src/utils/findNearbyToolData.ts +21 -0
  229. package/src/utils/generateSegmentationCSVReport.test.ts +324 -0
  230. package/src/utils/generateSegmentationCSVReport.ts +131 -0
  231. package/src/utils/getActiveViewportEnabledElement.test.ts +70 -0
  232. package/src/utils/getActiveViewportEnabledElement.ts +8 -0
  233. package/src/utils/getCenterExtent.test.ts +313 -0
  234. package/src/utils/getCenterExtent.ts +46 -0
  235. package/src/utils/getCornerstoneBlendMode.test.ts +59 -0
  236. package/src/utils/getCornerstoneBlendMode.ts +25 -0
  237. package/src/utils/getCornerstoneOrientation.test.ts +78 -0
  238. package/src/utils/getCornerstoneOrientation.ts +31 -0
  239. package/src/utils/getCornerstoneViewportType.test.ts +169 -0
  240. package/src/utils/getCornerstoneViewportType.ts +88 -0
  241. package/src/utils/getInterleavedFrames.test.ts +85 -0
  242. package/src/utils/getInterleavedFrames.ts +73 -0
  243. package/src/utils/getLegacyViewportType.ts +64 -0
  244. package/src/utils/getNthFrames.test.ts +145 -0
  245. package/src/utils/getNthFrames.ts +31 -0
  246. package/src/utils/getViewportEnabledElement.test.ts +83 -0
  247. package/src/utils/getViewportEnabledElement.ts +8 -0
  248. package/src/utils/getViewportOrientationFromImageOrientationPatient.test.ts +50 -0
  249. package/src/utils/getViewportOrientationFromImageOrientationPatient.ts +56 -0
  250. package/src/utils/hydrationUtils.test.ts +572 -0
  251. package/src/utils/hydrationUtils.ts +197 -0
  252. package/src/utils/imageSliceSync/calculateViewportRegistrations.ts +28 -0
  253. package/src/utils/imageSliceSync/toggleImageSliceSync.ts +101 -0
  254. package/src/utils/index.ts +29 -0
  255. package/src/utils/initGpuSettingsPreset.ts +51 -0
  256. package/src/utils/initViewTiming.test.ts +342 -0
  257. package/src/utils/initViewTiming.ts +52 -0
  258. package/src/utils/initWebWorkerProgressHandler.test.ts +381 -0
  259. package/src/utils/initWebWorkerProgressHandler.ts +110 -0
  260. package/src/utils/interleave.test.ts +304 -0
  261. package/src/utils/interleave.ts +32 -0
  262. package/src/utils/interleaveCenterLoader.test.ts +547 -0
  263. package/src/utils/interleaveCenterLoader.ts +143 -0
  264. package/src/utils/interleaveTopToBottom.test.ts +487 -0
  265. package/src/utils/interleaveTopToBottom.ts +132 -0
  266. package/src/utils/isAnyDisplaySetCommon.ts +18 -0
  267. package/src/utils/isDisplaySetOverlayable.ts +96 -0
  268. package/src/utils/isMeasurementWithinViewport.test.ts +340 -0
  269. package/src/utils/isMeasurementWithinViewport.ts +33 -0
  270. package/src/utils/isReferenceViewable.test.ts +581 -0
  271. package/src/utils/isReferenceViewable.ts +95 -0
  272. package/src/utils/loadDisplaySetData.ts +49 -0
  273. package/src/utils/measurementServiceMappings/Angle.ts +200 -0
  274. package/src/utils/measurementServiceMappings/ArrowAnnotate.ts +176 -0
  275. package/src/utils/measurementServiceMappings/Bidirectional.ts +193 -0
  276. package/src/utils/measurementServiceMappings/CircleROI.ts +227 -0
  277. package/src/utils/measurementServiceMappings/CobbAngle.ts +206 -0
  278. package/src/utils/measurementServiceMappings/EllipticalROI.ts +221 -0
  279. package/src/utils/measurementServiceMappings/Length.ts +206 -0
  280. package/src/utils/measurementServiceMappings/LivewireContour.ts +175 -0
  281. package/src/utils/measurementServiceMappings/PlanarFreehandROI.ts +228 -0
  282. package/src/utils/measurementServiceMappings/Probe.ts +192 -0
  283. package/src/utils/measurementServiceMappings/RectangleROI.ts +225 -0
  284. package/src/utils/measurementServiceMappings/SegmentBidirectional.ts +184 -0
  285. package/src/utils/measurementServiceMappings/SplineROI.ts +227 -0
  286. package/src/utils/measurementServiceMappings/UltrasoundDirectional.ts +214 -0
  287. package/src/utils/measurementServiceMappings/UltrasoundPleuraBLine.ts +179 -0
  288. package/src/utils/measurementServiceMappings/constants/supportedTools.js +21 -0
  289. package/src/utils/measurementServiceMappings/index.ts +3 -0
  290. package/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts +324 -0
  291. package/src/utils/measurementServiceMappings/utils/getDisplayUnit.js +3 -0
  292. package/src/utils/measurementServiceMappings/utils/getHandlesFromPoints.js +14 -0
  293. package/src/utils/measurementServiceMappings/utils/getIsLocked.ts +5 -0
  294. package/src/utils/measurementServiceMappings/utils/getIsVisible.ts +6 -0
  295. package/src/utils/measurementServiceMappings/utils/getSOPInstanceAttributes.js +66 -0
  296. package/src/utils/measurementServiceMappings/utils/getValueDisplayString.js +12 -0
  297. package/src/utils/measurementServiceMappings/utils/index.ts +17 -0
  298. package/src/utils/measurementServiceMappings/utils/selection.ts +33 -0
  299. package/src/utils/mpr/getProtocolViewportStructureFromGridViewports.ts +74 -0
  300. package/src/utils/nextViewportPolicies.ts +41 -0
  301. package/src/utils/nextViewports.ts +157 -0
  302. package/src/utils/nthLoader.test.ts +317 -0
  303. package/src/utils/nthLoader.ts +78 -0
  304. package/src/utils/presentations/getViewportPresentations.test.ts +280 -0
  305. package/src/utils/presentations/getViewportPresentations.ts +151 -0
  306. package/src/utils/promptHydrationDialog.test.ts +490 -0
  307. package/src/utils/promptHydrationDialog.ts +197 -0
  308. package/src/utils/removeViewportSegmentationRepresentations.test.ts +129 -0
  309. package/src/utils/removeViewportSegmentationRepresentations.ts +17 -0
  310. package/src/utils/segmentUtils.test.ts +515 -0
  311. package/src/utils/segmentUtils.ts +46 -0
  312. package/src/utils/segmentationExportUtils.test.ts +100 -0
  313. package/src/utils/segmentationExportUtils.ts +171 -0
  314. package/src/utils/segmentationHandlers.test.ts +614 -0
  315. package/src/utils/segmentationHandlers.ts +164 -0
  316. package/src/utils/setUpAnnotationEventHandlers.ts +26 -0
  317. package/src/utils/setUpSegmentationEventHandlers.test.ts +372 -0
  318. package/src/utils/setUpSegmentationEventHandlers.ts +122 -0
  319. package/src/utils/toggleVOISliceSync.test.ts +606 -0
  320. package/src/utils/toggleVOISliceSync.ts +103 -0
  321. package/src/utils/transitions.test.ts +351 -0
  322. package/src/utils/transitions.ts +300 -0
  323. package/src/utils/updateSegmentationStats.test.ts +942 -0
  324. package/src/utils/updateSegmentationStats.ts +192 -0
  325. package/src/utils/viewportDataShape.ts +85 -0
@@ -0,0 +1,227 @@
1
+ import SUPPORTED_TOOLS from './constants/supportedTools';
2
+ import { getDisplayUnit } from './utils';
3
+ import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
4
+ import { utils } from '@ohif/core';
5
+ import { getStatisticDisplayString } from './utils/getValueDisplayString';
6
+ import { getIsLocked } from './utils/getIsLocked';
7
+ import { getIsVisible } from './utils/getIsVisible';
8
+
9
+ const CircleROI = {
10
+ toAnnotation: measurement => {},
11
+ toMeasurement: (
12
+ csToolsEventDetail,
13
+ displaySetService,
14
+ CornerstoneViewportService,
15
+ getValueTypeFromToolType,
16
+ customizationService
17
+ ) => {
18
+ const { annotation } = csToolsEventDetail;
19
+ const { metadata, data, annotationUID } = annotation;
20
+
21
+ const isLocked = getIsLocked(annotationUID);
22
+ const isVisible = getIsVisible(annotationUID);
23
+
24
+ if (!metadata || !data) {
25
+ console.warn('Length tool: Missing metadata or data');
26
+ return null;
27
+ }
28
+
29
+ const { toolName, referencedImageId, FrameOfReferenceUID } = metadata;
30
+ const validToolType = SUPPORTED_TOOLS.includes(toolName);
31
+
32
+ if (!validToolType) {
33
+ throw new Error('Tool not supported');
34
+ }
35
+
36
+ const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } = getSOPInstanceAttributes(
37
+ referencedImageId,
38
+ displaySetService,
39
+ annotation
40
+ );
41
+
42
+ let displaySet;
43
+
44
+ if (SOPInstanceUID) {
45
+ displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
46
+ SOPInstanceUID,
47
+ SeriesInstanceUID
48
+ );
49
+ } else {
50
+ displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
51
+ }
52
+
53
+ const { points, textBox } = data.handles;
54
+
55
+ const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
56
+
57
+ const displayText = getDisplayText(mappedAnnotations, displaySet);
58
+ const getReport = () =>
59
+ _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
60
+
61
+ return {
62
+ uid: annotationUID,
63
+ SOPInstanceUID,
64
+ FrameOfReferenceUID,
65
+ points,
66
+ textBox,
67
+ isLocked,
68
+ isVisible,
69
+ metadata,
70
+ referenceSeriesUID: SeriesInstanceUID,
71
+ referenceStudyUID: StudyInstanceUID,
72
+ referencedImageId,
73
+ frameNumber: mappedAnnotations[0]?.frameNumber || 1,
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,
81
+ };
82
+ },
83
+ };
84
+
85
+ function getMappedAnnotations(annotation, displaySetService) {
86
+ const { metadata, data } = annotation;
87
+ const { cachedStats={} } = data;
88
+ const { referencedImageId } = metadata;
89
+ const targets = Object.keys(cachedStats);
90
+
91
+ if (!targets.length) {
92
+ return [];
93
+ }
94
+
95
+ const annotations = [];
96
+ const addedModalities = new Set();
97
+ Object.keys(cachedStats).forEach(targetId => {
98
+ const targetStats = cachedStats[targetId];
99
+
100
+ const { SOPInstanceUID, SeriesInstanceUID, frameNumber } = getSOPInstanceAttributes(
101
+ referencedImageId,
102
+ displaySetService,
103
+ annotation
104
+ );
105
+
106
+ const displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
107
+
108
+ const { SeriesNumber } = displaySet;
109
+ const { mean, stdDev, max, area, Modality, areaUnit, modalityUnit, perimeter, radiusUnit } =
110
+ targetStats;
111
+
112
+ if (Modality && addedModalities.has(Modality)) {
113
+ return;
114
+ }
115
+
116
+ addedModalities.add(Modality);
117
+
118
+ annotations.push({
119
+ SeriesInstanceUID,
120
+ SOPInstanceUID,
121
+ SeriesNumber,
122
+ frameNumber,
123
+ Modality,
124
+ unit: modalityUnit,
125
+ mean,
126
+ stdDev,
127
+ max,
128
+ area,
129
+ areaUnit,
130
+ perimeter,
131
+ radiusUnit,
132
+ });
133
+ });
134
+
135
+ return annotations;
136
+ }
137
+
138
+ /*
139
+ This function is used to convert the measurement data to a format that is
140
+ suitable for the report generation (e.g. for the csv report). The report
141
+ returns a list of columns and corresponding values.
142
+ */
143
+ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService) {
144
+ const columns = [];
145
+ const values = [];
146
+
147
+ // Add Type
148
+ columns.push('AnnotationType');
149
+ values.push('Cornerstone:CircleROI');
150
+
151
+ mappedAnnotations.forEach(annotation => {
152
+ const { mean, stdDev, max, area, unit, areaUnit } = annotation;
153
+
154
+ if (!mean || !unit || !max || !area) {
155
+ return;
156
+ }
157
+
158
+ columns.push(`max (${unit})`, `mean (${unit})`, `std (${unit})`, 'Area', 'Unit');
159
+ values.push(max, mean, stdDev, area, areaUnit);
160
+ });
161
+
162
+ if (FrameOfReferenceUID) {
163
+ columns.push('FrameOfReferenceUID');
164
+ values.push(FrameOfReferenceUID);
165
+ }
166
+
167
+ if (points) {
168
+ columns.push('points');
169
+ // points has the form of [[x1, y1, z1], [x2, y2, z2], ...]
170
+ // convert it to string of [[x1 y1 z1];[x2 y2 z2];...]
171
+ // so that it can be used in the csv report
172
+ values.push(points.map(p => p.join(' ')).join(';'));
173
+ }
174
+
175
+ return {
176
+ columns,
177
+ values,
178
+ };
179
+ }
180
+
181
+ function getDisplayText(mappedAnnotations, displaySet) {
182
+ const displayText = {
183
+ primary: [],
184
+ secondary: [],
185
+ };
186
+
187
+ if (!mappedAnnotations || !mappedAnnotations.length) {
188
+ return displayText;
189
+ }
190
+
191
+ // Area is the same for all series
192
+ const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
193
+
194
+ const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
195
+
196
+ let InstanceNumber;
197
+ if (instance) {
198
+ InstanceNumber = instance.InstanceNumber;
199
+ }
200
+
201
+ const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
202
+ const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
203
+
204
+ // Area sometimes becomes undefined if `preventHandleOutsideImage` is off.
205
+ if (!isNaN(area)) {
206
+ const roundedArea = utils.roundNumber(area || 0, 2);
207
+ displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
208
+ }
209
+
210
+ // Todo: we need a better UI for displaying all these information
211
+ mappedAnnotations.forEach(mappedAnnotation => {
212
+ const { unit, perimeter, radiusUnit, max, SeriesNumber } = mappedAnnotation;
213
+
214
+ if (!isNaN(max)) {
215
+ const maxStr = getStatisticDisplayString(max, unit, 'max');
216
+ displayText.primary.push(maxStr);
217
+ } else if (perimeter && !isNaN(perimeter)) {
218
+ const perimeterStr = getStatisticDisplayString(perimeter, radiusUnit, 'perimeter');
219
+ displayText.primary.push(perimeterStr);
220
+ }
221
+ displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
222
+ });
223
+
224
+ return displayText;
225
+ }
226
+
227
+ export default CircleROI;
@@ -0,0 +1,206 @@
1
+ import SUPPORTED_TOOLS from './constants/supportedTools';
2
+ import { getDisplayUnit } from './utils';
3
+ import { getIsLocked } from './utils/getIsLocked';
4
+ import { getIsVisible } from './utils/getIsVisible';
5
+ import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
6
+ import { utils } from '@ohif/core';
7
+
8
+ const CobbAngle = {
9
+ toAnnotation: measurement => {},
10
+
11
+ /**
12
+ * Maps cornerstone annotation event data to measurement service format.
13
+ *
14
+ * @param {Object} cornerstone Cornerstone event data
15
+ * @return {Measurement} Measurement instance
16
+ */
17
+ toMeasurement: (
18
+ csToolsEventDetail,
19
+ displaySetService,
20
+ CornerstoneViewportService,
21
+ getValueTypeFromToolType,
22
+ customizationService
23
+ ) => {
24
+ const { annotation } = csToolsEventDetail;
25
+ const { metadata, data, annotationUID } = annotation;
26
+
27
+ const isLocked = getIsLocked(annotationUID);
28
+ const isVisible = getIsVisible(annotationUID);
29
+
30
+ if (!metadata || !data) {
31
+ console.warn('Cobb Angle tool: Missing metadata or data');
32
+ return null;
33
+ }
34
+
35
+ const { toolName, referencedImageId, FrameOfReferenceUID } = metadata;
36
+ const validToolType = SUPPORTED_TOOLS.includes(toolName);
37
+
38
+ if (!validToolType) {
39
+ throw new Error('Tool not supported');
40
+ }
41
+
42
+ const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } = getSOPInstanceAttributes(
43
+ referencedImageId,
44
+ displaySetService,
45
+ annotation
46
+ );
47
+
48
+ let displaySet;
49
+
50
+ if (SOPInstanceUID) {
51
+ displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
52
+ SOPInstanceUID,
53
+ SeriesInstanceUID
54
+ );
55
+ } else {
56
+ displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
57
+ }
58
+
59
+ const { points, textBox } = data.handles;
60
+
61
+ const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
62
+
63
+ const displayText = getDisplayText(mappedAnnotations, displaySet);
64
+ const getReport = () =>
65
+ _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
66
+
67
+ return {
68
+ uid: annotationUID,
69
+ SOPInstanceUID,
70
+ FrameOfReferenceUID,
71
+ points,
72
+ textBox,
73
+ isLocked,
74
+ isVisible,
75
+ metadata,
76
+ referenceSeriesUID: SeriesInstanceUID,
77
+ referenceStudyUID: StudyInstanceUID,
78
+ referencedImageId,
79
+ frameNumber: mappedAnnotations?.[0]?.frameNumber || 1,
80
+ toolName: metadata.toolName,
81
+ displaySetInstanceUID: displaySet.displaySetInstanceUID,
82
+ label: data.label,
83
+ displayText: displayText,
84
+ data: data.cachedStats,
85
+ type: getValueTypeFromToolType(toolName),
86
+ getReport,
87
+ };
88
+ },
89
+ };
90
+
91
+ function getMappedAnnotations(annotation, displaySetService) {
92
+ const { metadata, data } = annotation;
93
+ const { cachedStats } = data;
94
+ const { referencedImageId } = metadata;
95
+
96
+ if( !cachedStats ) {
97
+ return;
98
+ }
99
+
100
+ const targets = Object.keys(cachedStats);
101
+
102
+ if (!targets.length) {
103
+ return;
104
+ }
105
+
106
+ const annotations = [];
107
+ Object.keys(cachedStats).forEach(targetId => {
108
+ const targetStats = cachedStats[targetId];
109
+
110
+ const { SOPInstanceUID, SeriesInstanceUID, frameNumber } = getSOPInstanceAttributes(
111
+ referencedImageId,
112
+ displaySetService,
113
+ annotation
114
+ );
115
+
116
+ const displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
117
+
118
+ const { SeriesNumber } = displaySet;
119
+ const { angle } = targetStats;
120
+ const unit = '\u00B0';
121
+
122
+ annotations.push({
123
+ SeriesInstanceUID,
124
+ SOPInstanceUID,
125
+ SeriesNumber,
126
+ frameNumber,
127
+ unit,
128
+ angle,
129
+ });
130
+ });
131
+
132
+ return annotations;
133
+ }
134
+
135
+ /*
136
+ This function is used to convert the measurement data to a format that is
137
+ suitable for the report generation (e.g. for the csv report). The report
138
+ returns a list of columns and corresponding values.
139
+ */
140
+ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService) {
141
+ const columns = [];
142
+ const values = [];
143
+
144
+ // Add Type
145
+ columns.push('AnnotationType');
146
+ values.push('Cornerstone:CobbAngle');
147
+
148
+ mappedAnnotations.forEach(annotation => {
149
+ const { angle, unit } = annotation;
150
+ columns.push(`Angle (${unit})`);
151
+ values.push(angle);
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
+ // Angle is the same for all series
184
+ const { angle, unit, SeriesNumber, SOPInstanceUID, frameNumber } = 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
+ if (angle === undefined) {
196
+ return displayText;
197
+ }
198
+ const roundedAngle = utils.roundNumber(angle, 2);
199
+
200
+ displayText.primary.push(`${roundedAngle} ${getDisplayUnit(unit)}`);
201
+ displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
202
+
203
+ return displayText;
204
+ }
205
+
206
+ export default CobbAngle;
@@ -0,0 +1,221 @@
1
+ import SUPPORTED_TOOLS from './constants/supportedTools';
2
+ import { getDisplayUnit } from './utils';
3
+ import { getIsLocked } from './utils/getIsLocked';
4
+ import { getIsVisible } from './utils/getIsVisible';
5
+ import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
6
+ import { utils } from '@ohif/core';
7
+ import { getStatisticDisplayString } from './utils/getValueDisplayString';
8
+
9
+ const EllipticalROI = {
10
+ toAnnotation: measurement => {},
11
+ toMeasurement: (
12
+ csToolsEventDetail,
13
+ displaySetService,
14
+ cornerstoneViewportService,
15
+ getValueTypeFromToolType,
16
+ customizationService
17
+ ) => {
18
+ const { annotation } = csToolsEventDetail;
19
+ const { metadata, data, annotationUID } = annotation;
20
+
21
+ const isLocked = getIsLocked(annotationUID);
22
+ const isVisible = getIsVisible(annotationUID);
23
+
24
+ if (!metadata || !data) {
25
+ console.warn('Length tool: Missing metadata or data');
26
+ return null;
27
+ }
28
+
29
+ const { toolName, referencedImageId, FrameOfReferenceUID } = metadata;
30
+ const validToolType = SUPPORTED_TOOLS.includes(toolName);
31
+
32
+ if (!validToolType) {
33
+ throw new Error('Tool not supported');
34
+ }
35
+
36
+ const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } = getSOPInstanceAttributes(
37
+ referencedImageId,
38
+ displaySetService,
39
+ annotation
40
+ );
41
+
42
+ let displaySet;
43
+
44
+ if (SOPInstanceUID) {
45
+ displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
46
+ SOPInstanceUID,
47
+ SeriesInstanceUID
48
+ );
49
+ } else {
50
+ displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
51
+ }
52
+
53
+ const { points, textBox } = data.handles;
54
+
55
+ const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);
56
+
57
+ const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
58
+ const getReport = () =>
59
+ _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);
60
+
61
+ return {
62
+ uid: annotationUID,
63
+ SOPInstanceUID,
64
+ FrameOfReferenceUID,
65
+ points,
66
+ textBox,
67
+ metadata,
68
+ isLocked,
69
+ isVisible,
70
+ referenceSeriesUID: SeriesInstanceUID,
71
+ referenceStudyUID: StudyInstanceUID,
72
+ referencedImageId,
73
+ frameNumber: mappedAnnotations[0]?.frameNumber || 1,
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,
81
+ };
82
+ },
83
+ };
84
+
85
+ function getMappedAnnotations(annotation, displaySetService) {
86
+ const { metadata, data } = annotation;
87
+ const { cachedStats } = data;
88
+ const { referencedImageId } = metadata;
89
+ const targets = Object.keys(cachedStats);
90
+
91
+ if (!targets.length) {
92
+ return [];
93
+ }
94
+
95
+ const annotations = [];
96
+ const addedModalities = new Set();
97
+
98
+ Object.keys(cachedStats).forEach(targetId => {
99
+ const targetStats = cachedStats[targetId];
100
+
101
+ const { SOPInstanceUID, SeriesInstanceUID, frameNumber } = getSOPInstanceAttributes(
102
+ referencedImageId,
103
+ displaySetService,
104
+ annotation
105
+ );
106
+
107
+ const displaySet = displaySetService.getDisplaySetsForSeries(SeriesInstanceUID)[0];
108
+
109
+ const { SeriesNumber } = displaySet;
110
+ const { mean, stdDev, max, area, Modality, areaUnit, modalityUnit } = targetStats;
111
+
112
+ // Skip if we've already added this modality
113
+ if (Modality && addedModalities.has(Modality)) {
114
+ return;
115
+ }
116
+
117
+ // Add modality to the set if it exists
118
+ if (Modality) {
119
+ addedModalities.add(Modality);
120
+ }
121
+
122
+ annotations.push({
123
+ SeriesInstanceUID,
124
+ SOPInstanceUID,
125
+ SeriesNumber,
126
+ frameNumber,
127
+ Modality,
128
+ unit: modalityUnit,
129
+ areaUnit,
130
+ mean,
131
+ stdDev,
132
+ max,
133
+ area,
134
+ });
135
+ });
136
+
137
+ return annotations;
138
+ }
139
+
140
+ /*
141
+ This function is used to convert the measurement data to a format that is
142
+ suitable for the report generation (e.g. for the csv report). The report
143
+ returns a list of columns and corresponding values.
144
+ */
145
+ function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService) {
146
+ const columns = [];
147
+ const values = [];
148
+
149
+ // Add Type
150
+ columns.push('AnnotationType');
151
+ values.push('Cornerstone:EllipticalROI');
152
+
153
+ mappedAnnotations.forEach(annotation => {
154
+ const { mean, stdDev, max, area, unit, areaUnit } = annotation;
155
+
156
+ if (!mean || !unit || !max || !area) {
157
+ return;
158
+ }
159
+
160
+ columns.push(`max (${unit})`, `mean (${unit})`, `std (${unit})`, 'Area', 'Unit');
161
+ values.push(max, mean, stdDev, area, areaUnit);
162
+ });
163
+
164
+ if (FrameOfReferenceUID) {
165
+ columns.push('FrameOfReferenceUID');
166
+ values.push(FrameOfReferenceUID);
167
+ }
168
+
169
+ if (points) {
170
+ columns.push('points');
171
+ // points has the form of [[x1, y1, z1], [x2, y2, z2], ...]
172
+ // convert it to string of [[x1 y1 z1];[x2 y2 z2];...]
173
+ // so that it can be used in the csv report
174
+ values.push(points.map(p => p.join(' ')).join(';'));
175
+ }
176
+
177
+ return {
178
+ columns,
179
+ values,
180
+ };
181
+ }
182
+
183
+ function getDisplayText(mappedAnnotations, displaySet, customizationService) {
184
+ const displayText = {
185
+ primary: [],
186
+ secondary: [],
187
+ };
188
+
189
+ if (!mappedAnnotations || !mappedAnnotations.length) {
190
+ return displayText;
191
+ }
192
+
193
+ // Area is the same for all series
194
+ const { area, SOPInstanceUID, frameNumber, areaUnit } = mappedAnnotations[0];
195
+
196
+ const instance = displaySet.instances.find(image => image.SOPInstanceUID === SOPInstanceUID);
197
+
198
+ let InstanceNumber;
199
+ if (instance) {
200
+ InstanceNumber = instance.InstanceNumber;
201
+ }
202
+
203
+ const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
204
+ const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
205
+
206
+ const roundedArea = utils.roundNumber(area, 2);
207
+ displayText.primary.push(`${roundedArea} ${getDisplayUnit(areaUnit)}`);
208
+
209
+ // Todo: we need a better UI for displaying all these information
210
+ mappedAnnotations.forEach(mappedAnnotation => {
211
+ const { unit, max, SeriesNumber } = mappedAnnotation;
212
+
213
+ const maxStr = getStatisticDisplayString(max, unit, 'max');
214
+ displayText.primary.push(maxStr);
215
+ displayText.secondary.push(`S: ${SeriesNumber}${instanceText}${frameText}`);
216
+ });
217
+
218
+ return displayText;
219
+ }
220
+
221
+ export default EllipticalROI;