@ohif/extension-default 3.14.0-beta.10 → 3.14.0-beta.101

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 (216) hide show
  1. package/dist/ohif-extension-default.css +1 -1
  2. package/dist/ohif-extension-default.umd.js +1 -1
  3. package/package.json +14 -10
  4. package/src/Actions/createReportAsync.tsx +45 -0
  5. package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
  6. package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
  7. package/src/Components/ItemListComponent.tsx +95 -0
  8. package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
  9. package/src/Components/LineChartViewport/index.ts +1 -0
  10. package/src/Components/MoreDropdownMenu.tsx +112 -0
  11. package/src/Components/ProgressDropdownWithService.tsx +101 -0
  12. package/src/Components/SidePanelWithServices.tsx +122 -0
  13. package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
  14. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
  15. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
  16. package/src/CustomizableContextMenu/index.ts +5 -0
  17. package/src/CustomizableContextMenu/types.ts +126 -0
  18. package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
  19. package/src/DicomJSONDataSource/index.js +326 -0
  20. package/src/DicomLocalDataSource/index.js +273 -0
  21. package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
  22. package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
  23. package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
  24. package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
  25. package/src/DicomWebDataSource/exampleInstances.js +280 -0
  26. package/src/DicomWebDataSource/index.ts +808 -0
  27. package/src/DicomWebDataSource/qido.js +215 -0
  28. package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
  29. package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
  30. package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
  31. package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
  32. package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
  33. package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
  34. package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
  35. package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
  36. package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
  37. package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
  38. package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
  39. package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
  40. package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
  41. package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
  42. package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
  43. package/src/DicomWebDataSource/utils/getImageId.js +54 -0
  44. package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
  45. package/src/DicomWebDataSource/utils/index.ts +9 -0
  46. package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
  47. package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
  48. package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
  49. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
  50. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
  51. package/src/DicomWebProxyDataSource/index.ts +90 -0
  52. package/src/MergeDataSource/index.test.ts +212 -0
  53. package/src/MergeDataSource/index.ts +319 -0
  54. package/src/MergeDataSource/types.ts +46 -0
  55. package/src/Panels/DataSourceSelector.tsx +55 -0
  56. package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
  57. package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
  58. package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
  59. package/src/Panels/StudyBrowser/constants/index.ts +4 -0
  60. package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
  61. package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
  62. package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
  63. package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
  64. package/src/Panels/StudyBrowser/types/index.ts +4 -0
  65. package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
  66. package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
  67. package/src/Panels/createReportDialogPrompt.tsx +128 -0
  68. package/src/Panels/debounce.js +25 -0
  69. package/src/Panels/getImageSrcFromImageId.js +16 -0
  70. package/src/Panels/getStudiesForPatientByMRN.js +19 -0
  71. package/src/Panels/index.js +5 -0
  72. package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
  73. package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
  74. package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
  75. package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
  76. package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
  77. package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
  78. package/src/Toolbar/ToolRowWrapper.tsx +41 -0
  79. package/src/Toolbar/Toolbar.tsx +98 -0
  80. package/src/Toolbar/ToolbarDivider.tsx +5 -0
  81. package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
  82. package/src/Toolbar/index.ts +7 -0
  83. package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
  84. package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
  85. package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
  86. package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
  87. package/src/ViewerLayout/ViewerHeader.tsx +124 -0
  88. package/src/ViewerLayout/constants/panels.ts +42 -0
  89. package/src/ViewerLayout/index.tsx +227 -0
  90. package/src/ViewerLayout/useUndoRedoState.ts +75 -0
  91. package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
  92. package/src/commandsModule.ts +970 -0
  93. package/src/customizations/aboutModalCustomization.tsx +42 -0
  94. package/src/customizations/appearanceModalCustomization.tsx +143 -0
  95. package/src/customizations/contextMenuCustomization.ts +25 -0
  96. package/src/customizations/contextMenuUICustomization.ts +5 -0
  97. package/src/customizations/customRoutesCustomization.ts +6 -0
  98. package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
  99. package/src/customizations/datasourcesCustomization.tsx +14 -0
  100. package/src/customizations/defaultContextMenuCustomization.ts +22 -0
  101. package/src/customizations/hangingProtocolsCustomization.ts +15 -0
  102. package/src/customizations/headerRightSideCustomization.ts +19 -0
  103. package/src/customizations/helloPageCustomization.tsx +14 -0
  104. package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
  105. package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
  106. package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
  107. package/src/customizations/labellingFlowCustomization.tsx +5 -0
  108. package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
  109. package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
  110. package/src/customizations/menuContentCustomization.tsx +67 -0
  111. package/src/customizations/metadataContextCustomization.test.ts +22 -0
  112. package/src/customizations/metadataContextCustomization.ts +28 -0
  113. package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
  114. package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
  115. package/src/customizations/multimonitorCustomization.ts +63 -0
  116. package/src/customizations/notificationCustomization.ts +29 -0
  117. package/src/customizations/onDropHandlerCustomization.ts +5 -0
  118. package/src/customizations/onboardingCustomization.ts +200 -0
  119. package/src/customizations/overlayItemCustomization.tsx +33 -0
  120. package/src/customizations/progressDropdownCustomization.ts +5 -0
  121. package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
  122. package/src/customizations/reportDialogCustomization.test.ts +701 -0
  123. package/src/customizations/reportDialogCustomization.tsx +661 -0
  124. package/src/customizations/sortingCriteriaCustomization.ts +14 -0
  125. package/src/customizations/studyBrowserCustomization.test.ts +69 -0
  126. package/src/customizations/studyBrowserCustomization.ts +95 -0
  127. package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
  128. package/src/customizations/userPreferencesCustomization.tsx +342 -0
  129. package/src/customizations/workListCustomization.ts +107 -0
  130. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
  131. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
  132. package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
  133. package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
  134. package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
  135. package/src/findViewportsByPosition.ts +102 -0
  136. package/src/getCustomizationModule.tsx +109 -0
  137. package/src/getDataSourcesModule.js +44 -0
  138. package/src/getDisplaySetMessages.ts +54 -0
  139. package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
  140. package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
  141. package/src/getHangingProtocolModule.js +155 -0
  142. package/src/getLayoutTemplateModule.js +28 -0
  143. package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
  144. package/src/getPTImageIdInstanceMetadata.ts +124 -0
  145. package/src/getPanelModule.tsx +29 -0
  146. package/src/getSopClassHandlerModule.js +152 -0
  147. package/src/getSopClassHandlerModule.test.js +78 -0
  148. package/src/getToolbarModule.tsx +63 -0
  149. package/src/getViewportModule.tsx +12 -0
  150. package/src/hangingprotocols/hpCompare.ts +189 -0
  151. package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
  152. package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
  153. package/src/hangingprotocols/hpMNGrid.ts +419 -0
  154. package/src/hangingprotocols/hpMammo.ts +202 -0
  155. package/src/hangingprotocols/hpScale.ts +132 -0
  156. package/src/hangingprotocols/index.ts +16 -0
  157. package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
  158. package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
  159. package/src/hangingprotocols/utils/laterality.ts +9 -0
  160. package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
  161. package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
  162. package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
  163. package/src/hangingprotocols/utils/studySelectors.ts +14 -0
  164. package/src/hangingprotocols/utils/viewCode.test.js +25 -0
  165. package/src/hangingprotocols/utils/viewCode.ts +17 -0
  166. package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
  167. package/src/hooks/usePatientInfo.tsx +63 -0
  168. package/src/id.js +5 -0
  169. package/src/index.ts +113 -0
  170. package/src/init.ts +169 -0
  171. package/src/stores/index.ts +7 -0
  172. package/src/stores/useDisplaySetSelectorStore.ts +83 -0
  173. package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
  174. package/src/stores/useToggleHangingProtocolStore.ts +76 -0
  175. package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
  176. package/src/stores/useUIStateStore.ts +87 -0
  177. package/src/stores/useViewportGridStore.ts +89 -0
  178. package/src/stores/useViewportsByPositionStore.ts +100 -0
  179. package/src/types/AppTypes.ts +20 -0
  180. package/src/types/commandModuleTypes.tsx +6 -0
  181. package/src/utils/Toolbox.tsx +123 -0
  182. package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
  183. package/src/utils/addIcon.ts +6 -0
  184. package/src/utils/appendFrameQueryToImageId.js +9 -0
  185. package/src/utils/callInputDialog.tsx +126 -0
  186. package/src/utils/colorPickerDialog.css +4 -0
  187. package/src/utils/colorPickerDialog.tsx +45 -0
  188. package/src/utils/createRenderedRetrieve.js +32 -0
  189. package/src/utils/createRenderedRetrieve.test.js +46 -0
  190. package/src/utils/dicomWriter.test.ts +228 -0
  191. package/src/utils/dicomWriter.ts +110 -0
  192. package/src/utils/getBulkdataValue.js +45 -0
  193. package/src/utils/getBulkdataValue.test.js +105 -0
  194. package/src/utils/getDirectURL.test.ts +207 -0
  195. package/src/utils/getDirectURL.ts +65 -0
  196. package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
  197. package/src/utils/index.ts +2 -0
  198. package/src/utils/layerConfigurationUtils.ts +202 -0
  199. package/src/utils/promptLabelAnnotation.js +47 -0
  200. package/src/utils/promptSaveReport.test.ts +106 -0
  201. package/src/utils/promptSaveReport.tsx +117 -0
  202. package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
  203. package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
  204. package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
  205. package/src/utils/registerStoredInstanceImageId.ts +66 -0
  206. package/src/utils/reuseCachedLayouts.ts +92 -0
  207. package/src/utils/secureConfigFetch.js +115 -0
  208. package/src/utils/secureConfigFetch.test.js +163 -0
  209. package/src/utils/seriesDescriptionHistory.ts +83 -0
  210. package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
  211. package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
  212. package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
  213. package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
  214. package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
  215. package/src/utils/validations/checkMultiframe.ts +25 -0
  216. package/src/utils/validations/checkSingleFrames.ts +36 -0
@@ -0,0 +1,124 @@
1
+ import OHIF, { utils } from '@ohif/core';
2
+
3
+ import type { InstanceMetadata, PhilipsPETPrivateGroup } from '@cornerstonejs/calculate-suv';
4
+
5
+ const metadataProvider = OHIF.classes.MetadataProvider;
6
+
7
+ export default function getPTImageIdInstanceMetadata(imageId: string): InstanceMetadata {
8
+ const dicomMetaData = metadataProvider.get('instance', imageId);
9
+
10
+ if (!dicomMetaData) {
11
+ throw new Error('dicom metadata are required');
12
+ }
13
+
14
+ const radiopharmaceuticalInfo = firstSequenceItem<Record<string, unknown>>(
15
+ dicomMetaData.RadiopharmaceuticalInformationSequence
16
+ );
17
+ const radionuclideHalfLife = coerceNumber(radiopharmaceuticalInfo?.RadionuclideHalfLife);
18
+ const radionuclideTotalDose = coerceNumber(radiopharmaceuticalInfo?.RadionuclideTotalDose);
19
+
20
+ if (
21
+ dicomMetaData.SeriesDate === undefined ||
22
+ dicomMetaData.SeriesTime === undefined ||
23
+ dicomMetaData.CorrectedImage === undefined ||
24
+ dicomMetaData.Units === undefined ||
25
+ !radiopharmaceuticalInfo ||
26
+ radionuclideHalfLife === undefined ||
27
+ radionuclideTotalDose === undefined ||
28
+ dicomMetaData.DecayCorrection === undefined ||
29
+ dicomMetaData.AcquisitionDate === undefined ||
30
+ dicomMetaData.AcquisitionTime === undefined ||
31
+ (radiopharmaceuticalInfo.RadiopharmaceuticalStartDateTime === undefined &&
32
+ radiopharmaceuticalInfo.RadiopharmaceuticalStartTime === undefined)
33
+ ) {
34
+ throw new Error('required metadata are missing');
35
+ }
36
+
37
+ if (dicomMetaData.PatientWeight === undefined) {
38
+ console.warn('PatientWeight missing from PT instance metadata');
39
+ }
40
+
41
+ const instanceMetadata: InstanceMetadata = {
42
+ CorrectedImage: dicomMetaData.CorrectedImage,
43
+ Units: dicomMetaData.Units,
44
+ RadionuclideHalfLife: radionuclideHalfLife,
45
+ RadionuclideTotalDose: radionuclideTotalDose,
46
+ RadiopharmaceuticalStartDateTime: radiopharmaceuticalInfo.RadiopharmaceuticalStartDateTime,
47
+ RadiopharmaceuticalStartTime: radiopharmaceuticalInfo.RadiopharmaceuticalStartTime,
48
+ DecayCorrection: dicomMetaData.DecayCorrection,
49
+ PatientWeight: coerceNumber(dicomMetaData.PatientWeight),
50
+ SeriesDate: dicomMetaData.SeriesDate,
51
+ SeriesTime: dicomMetaData.SeriesTime,
52
+ AcquisitionDate: dicomMetaData.AcquisitionDate,
53
+ AcquisitionTime: dicomMetaData.AcquisitionTime,
54
+ };
55
+
56
+ // Philips PET private group. Only populated with values that coerce to real
57
+ // numbers; an unresolved bulkdata object yields undefined and is dropped so it
58
+ // can never corrupt the SUV calculation. SUVScaleFactor is (7053,1000) and
59
+ // ActivityConcentrationScaleFactor is (7053,1009). These are resolved from
60
+ // bulkdata upstream during ingestion (utils.resolveBulkDataTags).
61
+ const suvScaleFactor = coerceNumber(dicomMetaData['70531000']);
62
+ const activityConcentrationScaleFactor = coerceNumber(dicomMetaData['70531009']);
63
+ if (suvScaleFactor !== undefined || activityConcentrationScaleFactor !== undefined) {
64
+ const philipsPETPrivateGroup: PhilipsPETPrivateGroup = {
65
+ SUVScaleFactor: suvScaleFactor,
66
+ ActivityConcentrationScaleFactor: activityConcentrationScaleFactor,
67
+ };
68
+ instanceMetadata.PhilipsPETPrivateGroup = philipsPETPrivateGroup;
69
+ }
70
+
71
+ if (dicomMetaData['0009100d'] !== undefined) {
72
+ instanceMetadata.GEPrivatePostInjectionDateTime = dicomMetaData['0009100d'];
73
+ }
74
+
75
+ const frameReferenceTime = coerceNumber(dicomMetaData.FrameReferenceTime);
76
+ if (frameReferenceTime !== undefined) {
77
+ instanceMetadata.FrameReferenceTime = frameReferenceTime;
78
+ }
79
+
80
+ const actualFrameDuration = coerceNumber(dicomMetaData.ActualFrameDuration);
81
+ if (actualFrameDuration !== undefined) {
82
+ instanceMetadata.ActualFrameDuration = actualFrameDuration;
83
+ }
84
+
85
+ if (dicomMetaData.PatientSex !== undefined) {
86
+ instanceMetadata.PatientSex = dicomMetaData.PatientSex;
87
+ }
88
+
89
+ const patientSize = coerceNumber(dicomMetaData.PatientSize);
90
+ if (patientSize !== undefined) {
91
+ instanceMetadata.PatientSize = patientSize;
92
+ }
93
+
94
+ return instanceMetadata;
95
+ }
96
+
97
+ export { getPTImageIdInstanceMetadata };
98
+
99
+ /**
100
+ * Coerces a naturalized DICOM value into a finite number, or returns undefined.
101
+ *
102
+ * Delegates to OHIF's `utils.toNumber` and then requires a finite scalar, so an
103
+ * object value - such as an unresolved bulkdata reference `{ BulkDataURI }` or
104
+ * an array - becomes undefined. This is the final backstop ensuring such a value
105
+ * can never reach calculate-suv (which treats it as truthy and silently corrupts
106
+ * the SUV factors). Bulkdata is meant to be resolved upstream during ingestion
107
+ * (see utils.resolveBulkDataTags); this guard catches anything that slips
108
+ * through.
109
+ */
110
+ function coerceNumber(value: unknown): number | undefined {
111
+ const n = utils.toNumber(value);
112
+ return typeof n === 'number' && Number.isFinite(n) ? n : undefined;
113
+ }
114
+
115
+ /**
116
+ * Returns the first item of a DICOM sequence, tolerating either the dcmjs
117
+ * naturalized array shape or an already-flattened single-object shape.
118
+ */
119
+ function firstSequenceItem<T = Record<string, unknown>>(seq: unknown): T | undefined {
120
+ if (seq == null || typeof seq !== 'object') {
121
+ return undefined;
122
+ }
123
+ return (Array.isArray(seq) ? seq[0] : seq) as T;
124
+ }
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { WrappedPanelStudyBrowser } from './Panels';
3
+ import i18n from 'i18next';
4
+
5
+ // TODO:
6
+ // - No loading UI exists yet
7
+ // - cancel promises when component is destroyed
8
+ // - show errors in UI for thumbnails if promise fails
9
+
10
+ function getPanelModule({ commandsManager, extensionManager, servicesManager }) {
11
+ return [
12
+ {
13
+ name: 'seriesList',
14
+ iconName: 'tab-studies',
15
+ iconLabel: 'Studies',
16
+ label: i18n.t('SidePanel:Studies'),
17
+ component: props => (
18
+ <WrappedPanelStudyBrowser
19
+ {...props}
20
+ commandsManager={commandsManager}
21
+ extensionManager={extensionManager}
22
+ servicesManager={servicesManager}
23
+ />
24
+ ),
25
+ },
26
+ ];
27
+ }
28
+
29
+ export default getPanelModule;
@@ -0,0 +1,152 @@
1
+ import { utils } from '@ohif/core';
2
+ import getDisplaySetsFromUnsupportedSeries, {
3
+ extendUnsupportedDisplaySet,
4
+ } from './getDisplaySetsFromUnsupportedSeries';
5
+ import { chartHandler } from './SOPClassHandlers/chartSOPClassHandler';
6
+ import {
7
+ makeImageSetDisplaySet,
8
+ STACK_SOP_CLASS_HANDLER_NAME,
9
+ } from './displaySetSplitting/makeImageSetDisplaySet';
10
+ import { STACK_SOP_CLASS_UIDS } from './displaySetSplitting/stackSopClassUids';
11
+
12
+ const { isImage } = utils;
13
+
14
+ // Shared with the STACK_SOP_CLASS_HANDLER_ID the display set factory stamps
15
+ // onto every display set it builds, so the two cannot drift.
16
+ const sopClassHandlerName = STACK_SOP_CLASS_HANDLER_NAME;
17
+ let appContext = {};
18
+
19
+ const isMultiFrame = instance => {
20
+ return instance.NumberOfFrames > 1;
21
+ };
22
+
23
+ const makeDisplaySet = instances => makeImageSetDisplaySet(instances, appContext);
24
+
25
+ const isSingleImageModality = modality => {
26
+ return modality === 'CR' || modality === 'MG' || modality === 'DX';
27
+ };
28
+
29
+ /**
30
+ * The stack fields of a display set: the instance number and acquisition time
31
+ * of a display set of one multi-frame or single-image instance, else the study.
32
+ * Shared by the legacy builder and the split-rule path.
33
+ */
34
+ function extendStackDisplaySet(displaySet) {
35
+ const { images } = displaySet;
36
+ if (!images?.length) {
37
+ return;
38
+ }
39
+ const [instance] = images;
40
+ if (images.length === 1 && (isMultiFrame(instance) || isSingleImageModality(instance.Modality))) {
41
+ displaySet.setAttributes({
42
+ instanceNumber: instance.InstanceNumber,
43
+ acquisitionDatetime: instance.AcquisitionDateTime,
44
+ });
45
+ } else {
46
+ displaySet.setAttribute('studyInstanceUid', instance.StudyInstanceUID);
47
+ }
48
+ }
49
+
50
+ function getSopClassUids(instances) {
51
+ const uniqueSopClassUidsInSeries = new Set();
52
+ instances.forEach(instance => {
53
+ uniqueSopClassUidsInSeries.add(instance.SOPClassUID);
54
+ });
55
+ const sopClassUids = Array.from(uniqueSopClassUidsInSeries);
56
+
57
+ return sopClassUids;
58
+ }
59
+
60
+ /**
61
+ * Basic SOPClassHandler:
62
+ * - For all Image types that are stackable, create
63
+ * a displaySet with a stack of images
64
+ *
65
+ * @param {SeriesMetadata} series The series metadata object from which the display sets will be created
66
+ * @returns {Array} The list of display sets created for the given series object
67
+ */
68
+ function getDisplaySetsFromSeries(instances) {
69
+ // If the series has no instances, stop here
70
+ if (!instances || !instances.length) {
71
+ throw new Error('No instances were provided');
72
+ }
73
+
74
+ const displaySets = [];
75
+ const sopClassUids = getSopClassUids(instances);
76
+
77
+ // Search through the instances (InstanceMetadata object) of this series
78
+ // Split Multi-frame instances and Single-image modalities
79
+ // into their own specific display sets. Place the rest of each
80
+ // series into another display set.
81
+ const stackableInstances = [];
82
+ instances.forEach((instance, instanceIndex) => {
83
+ // All imaging modalities must have a valid value for sopClassUid (x00080016) or rows (x00280010)
84
+ if (!isImage(instance.SOPClassUID) && !instance.Rows) {
85
+ return;
86
+ }
87
+
88
+ let displaySet;
89
+ if (isMultiFrame(instance)) {
90
+ displaySet = makeDisplaySet([instance]);
91
+ displaySet.setAttributes({
92
+ sopClassUids,
93
+ numImageFrames: instance.NumberOfFrames,
94
+ });
95
+ extendStackDisplaySet(displaySet);
96
+ displaySets.push(displaySet);
97
+ } else if (isSingleImageModality(instance.Modality)) {
98
+ displaySet = makeDisplaySet([instance]);
99
+ displaySet.setAttributes({ sopClassUids });
100
+ extendStackDisplaySet(displaySet);
101
+ displaySets.push(displaySet);
102
+ } else {
103
+ stackableInstances.push(instance);
104
+ }
105
+ });
106
+
107
+ if (stackableInstances.length) {
108
+ const displaySet = makeDisplaySet(stackableInstances);
109
+ // A single stackable instance is neither multi-frame nor single-image, so
110
+ // this sets `studyInstanceUid`.
111
+ extendStackDisplaySet(displaySet);
112
+ displaySet.setAttributes({
113
+ sopClassUids,
114
+ });
115
+ displaySets.push(displaySet);
116
+ }
117
+
118
+ return displaySets;
119
+ }
120
+
121
+ const sopClassUids = STACK_SOP_CLASS_UIDS;
122
+
123
+ function getSopClassHandlerModule(appContextParam) {
124
+ appContext = appContextParam;
125
+
126
+ return [
127
+ {
128
+ name: sopClassHandlerName,
129
+ sopClassUids,
130
+ getDisplaySetsFromSeries,
131
+ // Also serves a split rule with no `handler`; adds the stack fields only.
132
+ handlerNames: ['image'],
133
+ extendDisplaySet: extendStackDisplaySet,
134
+ },
135
+ {
136
+ name: 'not-supported-display-sets-handler',
137
+ sopClassUids: [],
138
+ getDisplaySetsFromSeries: getDisplaySetsFromUnsupportedSeries,
139
+ handlerNames: ['unsupported'],
140
+ extendDisplaySet: extendUnsupportedDisplaySet,
141
+ },
142
+ {
143
+ name: chartHandler.name,
144
+ sopClassUids: chartHandler.sopClassUids,
145
+ getDisplaySetsFromSeries: chartHandler.getDisplaySetsFromSeries,
146
+ handlerNames: chartHandler.handlerNames,
147
+ extendDisplaySet: chartHandler.extendDisplaySet,
148
+ },
149
+ ];
150
+ }
151
+
152
+ export default getSopClassHandlerModule;
@@ -0,0 +1,78 @@
1
+ jest.mock('./getDisplaySetMessages', () => jest.fn(() => ({ addMessage: jest.fn() })));
2
+ jest.mock('./getDisplaySetsFromUnsupportedSeries', () => jest.fn());
3
+
4
+ import getSopClassHandlerModule from './getSopClassHandlerModule';
5
+
6
+ const makeInstance = () => ({
7
+ imageId: 'dicomfile:blob://local-multiframe',
8
+ url: 'dicomfile:blob://local-multiframe',
9
+ NumberOfFrames: 4,
10
+ Rows: 2,
11
+ Columns: 2,
12
+ PixelSpacing: [1, 1],
13
+ SliceThickness: 1,
14
+ ImageOrientationPatient: [1, 0, 0, 0, 1, 0],
15
+ ImagePositionPatient: [0, 0, 0],
16
+ FrameOfReferenceUID: 'frame-of-reference',
17
+ StudyInstanceUID: 'study',
18
+ SeriesInstanceUID: 'series',
19
+ SOPInstanceUID: 'sop',
20
+ SOPClassUID: '1.2.840.10008.5.1.4.1.1.2.1',
21
+ Modality: 'CT',
22
+ SeriesDescription: 'Local multiframe CT',
23
+ SeriesNumber: 1,
24
+ });
25
+
26
+ describe('getSopClassHandlerModule', () => {
27
+ it('checks dynamic volume grouping with generated multiframe imageIds', () => {
28
+ const frameImageIds = [
29
+ 'dicomfile:blob://local-multiframe&frame=1',
30
+ 'dicomfile:blob://local-multiframe&frame=2',
31
+ 'dicomfile:blob://local-multiframe&frame=3',
32
+ 'dicomfile:blob://local-multiframe&frame=4',
33
+ ];
34
+ const getDynamicVolumeInfo = jest.fn(() => ({
35
+ isDynamicVolume: false,
36
+ timePoints: [frameImageIds],
37
+ splittingTag: null,
38
+ }));
39
+ const dataSource = {
40
+ getImageIdsForDisplaySet: jest.fn(imageSet => {
41
+ expect(imageSet.StudyInstanceUID).toBe('study');
42
+ expect(imageSet.SeriesInstanceUID).toBe('series');
43
+ return frameImageIds;
44
+ }),
45
+ retrieve: {
46
+ getGetThumbnailSrc: jest.fn(),
47
+ },
48
+ };
49
+ const customizationService = {
50
+ getCustomization: jest.fn(() => ({
51
+ sortFunctions: {},
52
+ defaultSortFunctionName: 'default',
53
+ })),
54
+ };
55
+ const appContext = {
56
+ appConfig: {},
57
+ extensionManager: {
58
+ getActiveDataSource: jest.fn(() => [dataSource]),
59
+ getModuleEntry: jest.fn(() => ({
60
+ exports: {
61
+ getDynamicVolumeInfo,
62
+ },
63
+ })),
64
+ },
65
+ servicesManager: {
66
+ services: {
67
+ customizationService,
68
+ },
69
+ },
70
+ };
71
+
72
+ const stackHandler = getSopClassHandlerModule(appContext)[0];
73
+
74
+ stackHandler.getDisplaySetsFromSeries([makeInstance()]);
75
+
76
+ expect(getDynamicVolumeInfo).toHaveBeenCalledWith(frameImageIds);
77
+ });
78
+ });
@@ -0,0 +1,63 @@
1
+ import { utils } from '@ohif/ui-next';
2
+
3
+ import ToolbarLayoutSelectorWithServices from './Toolbar/ToolbarLayoutSelector';
4
+
5
+ // legacy
6
+ import { ProgressDropdownWithService } from './Components/ProgressDropdownWithService';
7
+
8
+ // new
9
+ import ToolButtonListWrapper from './Toolbar/ToolButtonListWrapper';
10
+ import ToolRowWrapper from './Toolbar/ToolRowWrapper';
11
+ import { ToolBoxButtonGroupWrapper, ToolBoxButtonWrapper } from './Toolbar/ToolBoxWrapper';
12
+ import { ToolButtonWrapper } from './Toolbar/ToolButtonWrapper';
13
+ import { Toolbar } from './Toolbar';
14
+
15
+ export default function getToolbarModule({ commandsManager, servicesManager }: withAppTypes) {
16
+ const { cineService } = servicesManager.services;
17
+ return [
18
+ // new
19
+ {
20
+ name: 'ohif.toolButton',
21
+ defaultComponent: ToolButtonWrapper,
22
+ },
23
+ {
24
+ name: 'ohif.toolButtonList',
25
+ defaultComponent: ToolButtonListWrapper,
26
+ },
27
+ {
28
+ name: 'ohif.row',
29
+ defaultComponent: ToolRowWrapper,
30
+ },
31
+ {
32
+ name: 'ohif.toolBoxButtonGroup',
33
+ defaultComponent: ToolBoxButtonGroupWrapper,
34
+ },
35
+ {
36
+ name: 'ohif.toolBoxButton',
37
+ defaultComponent: ToolBoxButtonWrapper,
38
+ },
39
+ // others
40
+ {
41
+ name: 'ohif.layoutSelector',
42
+ defaultComponent: props =>
43
+ ToolbarLayoutSelectorWithServices({ ...props, commandsManager, servicesManager }),
44
+ },
45
+ {
46
+ name: 'ohif.progressDropdown',
47
+ defaultComponent: ProgressDropdownWithService,
48
+ },
49
+ {
50
+ name: 'ohif.Toolbar',
51
+ defaultComponent: Toolbar,
52
+ },
53
+ {
54
+ name: 'evaluate.cine',
55
+ evaluate: () => {
56
+ const isToggled = cineService.getState().isCineEnabled;
57
+ return {
58
+ className: utils.getToggledClassName(isToggled),
59
+ };
60
+ },
61
+ },
62
+ ];
63
+ }
@@ -0,0 +1,12 @@
1
+ import LineChartViewport from './Components/LineChartViewport/index';
2
+
3
+ const getViewportModule = () => {
4
+ return [
5
+ {
6
+ name: 'chartViewport',
7
+ component: LineChartViewport,
8
+ },
9
+ ];
10
+ };
11
+
12
+ export { getViewportModule as default };
@@ -0,0 +1,189 @@
1
+ import { Types } from '@ohif/core';
2
+ import i18n from 'i18next';
3
+
4
+ const defaultDisplaySetSelector = {
5
+ studyMatchingRules: [
6
+ {
7
+ // The priorInstance is a study counter that indicates what position this study is in
8
+ // and the value comes from the options parameter.
9
+ attribute: 'studyInstanceUIDsIndex',
10
+ from: 'options',
11
+ required: true,
12
+ constraint: {
13
+ equals: { value: 0 },
14
+ },
15
+ },
16
+ ],
17
+ seriesMatchingRules: [
18
+ {
19
+ attribute: 'numImageFrames',
20
+ constraint: {
21
+ greaterThanOrEqual: { value: 0 },
22
+ },
23
+ },
24
+ // This display set will select the specified items by preference
25
+ // It has no affect if nothing is specified in the URL.
26
+ {
27
+ attribute: 'isDisplaySetFromUrl',
28
+ weight: 20,
29
+ constraint: {
30
+ equals: true,
31
+ },
32
+ },
33
+ ],
34
+ };
35
+
36
+ const priorDisplaySetSelector = {
37
+ studyMatchingRules: [
38
+ {
39
+ // The priorInstance is a study counter that indicates what position this study is in
40
+ // and the value comes from the options parameter.
41
+ attribute: 'studyInstanceUIDsIndex',
42
+ from: 'options',
43
+ required: true,
44
+ constraint: {
45
+ equals: { value: 1 },
46
+ },
47
+ },
48
+ ],
49
+ seriesMatchingRules: [
50
+ {
51
+ attribute: 'numImageFrames',
52
+ constraint: {
53
+ greaterThanOrEqual: { value: 0 },
54
+ },
55
+ },
56
+ // This display set will select the specified items by preference
57
+ // It has no affect if nothing is specified in the URL.
58
+ {
59
+ attribute: 'isDisplaySetFromUrl',
60
+ weight: 20,
61
+ constraint: {
62
+ equals: true,
63
+ },
64
+ },
65
+ ],
66
+ };
67
+
68
+ const currentDisplaySet = {
69
+ id: 'defaultDisplaySetId',
70
+ };
71
+
72
+ const priorDisplaySet = {
73
+ id: 'priorDisplaySetId',
74
+ };
75
+
76
+ const currentViewport0 = {
77
+ viewportOptions: {
78
+ toolGroupId: 'default',
79
+ allowUnmatchedView: true,
80
+ },
81
+ displaySets: [currentDisplaySet],
82
+ };
83
+
84
+ const currentViewport1 = {
85
+ ...currentViewport0,
86
+ displaySets: [
87
+ {
88
+ ...currentDisplaySet,
89
+ matchedDisplaySetsIndex: 1,
90
+ },
91
+ ],
92
+ };
93
+
94
+ const priorViewport0 = {
95
+ ...currentViewport0,
96
+ displaySets: [priorDisplaySet],
97
+ };
98
+
99
+ const priorViewport1 = {
100
+ ...priorViewport0,
101
+ displaySets: [
102
+ {
103
+ ...priorDisplaySet,
104
+ matchedDisplaySetsIndex: 1,
105
+ },
106
+ ],
107
+ };
108
+
109
+ /**
110
+ * This hanging protocol can be activated on the primary mode by directly
111
+ * referencing it in a URL or by directly including it within a mode, e.g.:
112
+ * `&hangingProtocolId=@ohif/mnGrid` added to the viewer URL
113
+ * It is not included in the viewer mode by default.
114
+ */
115
+ const hpMNCompare: Types.HangingProtocol.Protocol = {
116
+ id: '@ohif/hpCompare',
117
+ description: i18n.t('Hps:Compare two studies in various layouts'),
118
+ name: i18n.t('Hps:Compare Two Studies'),
119
+ numberOfPriorsReferenced: 1,
120
+ protocolMatchingRules: [
121
+ {
122
+ id: 'Two Studies',
123
+ weight: 1000,
124
+ // is there a second study or in another work the attribute
125
+ // studyInstanceUIDsIndex that we get from prior should not be null
126
+ attribute: 'StudyInstanceUID',
127
+ from: 'prior',
128
+ required: true,
129
+ constraint: {
130
+ notNull: true,
131
+ },
132
+ },
133
+ ],
134
+ toolGroupIds: ['default'],
135
+ displaySetSelectors: {
136
+ defaultDisplaySetId: defaultDisplaySetSelector,
137
+ priorDisplaySetId: priorDisplaySetSelector,
138
+ },
139
+ defaultViewport: {
140
+ viewportOptions: {
141
+ viewportType: 'stack',
142
+ toolGroupId: 'default',
143
+ allowUnmatchedView: true,
144
+ },
145
+ displaySets: [
146
+ {
147
+ id: 'defaultDisplaySetId',
148
+ matchedDisplaySetsIndex: -1,
149
+ },
150
+ ],
151
+ },
152
+ stages: [
153
+ {
154
+ name: '2x2',
155
+ stageActivation: {
156
+ enabled: {
157
+ minViewportsMatched: 4,
158
+ },
159
+ },
160
+ viewportStructure: {
161
+ layoutType: 'grid',
162
+ properties: {
163
+ rows: 2,
164
+ columns: 2,
165
+ },
166
+ },
167
+ viewports: [currentViewport0, priorViewport0, currentViewport1, priorViewport1],
168
+ },
169
+
170
+ {
171
+ name: '2x1',
172
+ stageActivation: {
173
+ enabled: {
174
+ minViewportsMatched: 2,
175
+ },
176
+ },
177
+ viewportStructure: {
178
+ layoutType: 'grid',
179
+ properties: {
180
+ rows: 1,
181
+ columns: 2,
182
+ },
183
+ },
184
+ viewports: [currentViewport0, priorViewport0],
185
+ },
186
+ ],
187
+ };
188
+
189
+ export default hpMNCompare;