@ohif/extension-default 3.14.0-beta.97 → 3.14.0-beta.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ohif-extension-default.umd.js +1 -1
- package/package.json +9 -6
- package/src/Actions/createReportAsync.tsx +45 -0
- package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
- package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
- package/src/Components/ItemListComponent.tsx +95 -0
- package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
- package/src/Components/LineChartViewport/index.ts +1 -0
- package/src/Components/MoreDropdownMenu.tsx +112 -0
- package/src/Components/ProgressDropdownWithService.tsx +101 -0
- package/src/Components/SidePanelWithServices.tsx +122 -0
- package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
- package/src/CustomizableContextMenu/index.ts +5 -0
- package/src/CustomizableContextMenu/types.ts +126 -0
- package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
- package/src/DicomJSONDataSource/index.js +326 -0
- package/src/DicomLocalDataSource/index.js +273 -0
- package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
- package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
- package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
- package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
- package/src/DicomWebDataSource/exampleInstances.js +280 -0
- package/src/DicomWebDataSource/index.ts +808 -0
- package/src/DicomWebDataSource/qido.js +215 -0
- package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
- package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
- package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
- package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
- package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
- package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
- package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
- package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
- package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
- package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
- package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
- package/src/DicomWebDataSource/utils/getImageId.js +54 -0
- package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
- package/src/DicomWebDataSource/utils/index.ts +9 -0
- package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
- package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
- package/src/DicomWebProxyDataSource/index.ts +90 -0
- package/src/MergeDataSource/index.test.ts +212 -0
- package/src/MergeDataSource/index.ts +319 -0
- package/src/MergeDataSource/types.ts +46 -0
- package/src/Panels/DataSourceSelector.tsx +55 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
- package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
- package/src/Panels/StudyBrowser/constants/index.ts +4 -0
- package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
- package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
- package/src/Panels/StudyBrowser/types/index.ts +4 -0
- package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
- package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
- package/src/Panels/createReportDialogPrompt.tsx +128 -0
- package/src/Panels/debounce.js +25 -0
- package/src/Panels/getImageSrcFromImageId.js +16 -0
- package/src/Panels/getStudiesForPatientByMRN.js +19 -0
- package/src/Panels/index.js +5 -0
- package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
- package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
- package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
- package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
- package/src/Toolbar/ToolRowWrapper.tsx +41 -0
- package/src/Toolbar/Toolbar.tsx +98 -0
- package/src/Toolbar/ToolbarDivider.tsx +5 -0
- package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
- package/src/Toolbar/index.ts +7 -0
- package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
- package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
- package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
- package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
- package/src/ViewerLayout/ViewerHeader.tsx +124 -0
- package/src/ViewerLayout/constants/panels.ts +42 -0
- package/src/ViewerLayout/index.tsx +227 -0
- package/src/ViewerLayout/useUndoRedoState.ts +75 -0
- package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
- package/src/commandsModule.ts +970 -0
- package/src/customizations/aboutModalCustomization.tsx +42 -0
- package/src/customizations/appearanceModalCustomization.tsx +143 -0
- package/src/customizations/contextMenuCustomization.ts +25 -0
- package/src/customizations/contextMenuUICustomization.ts +5 -0
- package/src/customizations/customRoutesCustomization.ts +6 -0
- package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
- package/src/customizations/datasourcesCustomization.tsx +14 -0
- package/src/customizations/defaultContextMenuCustomization.ts +22 -0
- package/src/customizations/hangingProtocolsCustomization.ts +15 -0
- package/src/customizations/headerRightSideCustomization.ts +19 -0
- package/src/customizations/helloPageCustomization.tsx +14 -0
- package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
- package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
- package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
- package/src/customizations/labellingFlowCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
- package/src/customizations/menuContentCustomization.tsx +67 -0
- package/src/customizations/metadataContextCustomization.test.ts +22 -0
- package/src/customizations/metadataContextCustomization.ts +28 -0
- package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
- package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
- package/src/customizations/multimonitorCustomization.ts +63 -0
- package/src/customizations/notificationCustomization.ts +29 -0
- package/src/customizations/onDropHandlerCustomization.ts +5 -0
- package/src/customizations/onboardingCustomization.ts +200 -0
- package/src/customizations/overlayItemCustomization.tsx +33 -0
- package/src/customizations/progressDropdownCustomization.ts +5 -0
- package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
- package/src/customizations/reportDialogCustomization.test.ts +701 -0
- package/src/customizations/reportDialogCustomization.tsx +661 -0
- package/src/customizations/sortingCriteriaCustomization.ts +14 -0
- package/src/customizations/studyBrowserCustomization.test.ts +69 -0
- package/src/customizations/studyBrowserCustomization.ts +95 -0
- package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
- package/src/customizations/userPreferencesCustomization.tsx +342 -0
- package/src/customizations/workListCustomization.ts +107 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
- package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
- package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
- package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
- package/src/findViewportsByPosition.ts +102 -0
- package/src/getCustomizationModule.tsx +109 -0
- package/src/getDataSourcesModule.js +44 -0
- package/src/getDisplaySetMessages.ts +54 -0
- package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
- package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
- package/src/getHangingProtocolModule.js +155 -0
- package/src/getLayoutTemplateModule.js +28 -0
- package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
- package/src/getPTImageIdInstanceMetadata.ts +124 -0
- package/src/getPanelModule.tsx +29 -0
- package/src/getSopClassHandlerModule.js +152 -0
- package/src/getSopClassHandlerModule.test.js +78 -0
- package/src/getToolbarModule.tsx +63 -0
- package/src/getViewportModule.tsx +12 -0
- package/src/hangingprotocols/hpCompare.ts +189 -0
- package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
- package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
- package/src/hangingprotocols/hpMNGrid.ts +419 -0
- package/src/hangingprotocols/hpMammo.ts +202 -0
- package/src/hangingprotocols/hpScale.ts +132 -0
- package/src/hangingprotocols/index.ts +16 -0
- package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
- package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
- package/src/hangingprotocols/utils/laterality.ts +9 -0
- package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
- package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
- package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
- package/src/hangingprotocols/utils/studySelectors.ts +14 -0
- package/src/hangingprotocols/utils/viewCode.test.js +25 -0
- package/src/hangingprotocols/utils/viewCode.ts +17 -0
- package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
- package/src/hooks/usePatientInfo.tsx +63 -0
- package/src/id.js +5 -0
- package/src/index.ts +113 -0
- package/src/init.ts +169 -0
- package/src/stores/index.ts +7 -0
- package/src/stores/useDisplaySetSelectorStore.ts +83 -0
- package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
- package/src/stores/useToggleHangingProtocolStore.ts +76 -0
- package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
- package/src/stores/useUIStateStore.ts +87 -0
- package/src/stores/useViewportGridStore.ts +89 -0
- package/src/stores/useViewportsByPositionStore.ts +100 -0
- package/src/types/AppTypes.ts +20 -0
- package/src/types/commandModuleTypes.tsx +6 -0
- package/src/utils/Toolbox.tsx +123 -0
- package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
- package/src/utils/addIcon.ts +6 -0
- package/src/utils/appendFrameQueryToImageId.js +9 -0
- package/src/utils/callInputDialog.tsx +126 -0
- package/src/utils/colorPickerDialog.css +4 -0
- package/src/utils/colorPickerDialog.tsx +45 -0
- package/src/utils/createRenderedRetrieve.js +32 -0
- package/src/utils/createRenderedRetrieve.test.js +46 -0
- package/src/utils/dicomWriter.test.ts +228 -0
- package/src/utils/dicomWriter.ts +110 -0
- package/src/utils/getBulkdataValue.js +45 -0
- package/src/utils/getBulkdataValue.test.js +105 -0
- package/src/utils/getDirectURL.test.ts +207 -0
- package/src/utils/getDirectURL.ts +65 -0
- package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/layerConfigurationUtils.ts +202 -0
- package/src/utils/promptLabelAnnotation.js +47 -0
- package/src/utils/promptSaveReport.test.ts +106 -0
- package/src/utils/promptSaveReport.tsx +117 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
- package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
- package/src/utils/registerStoredInstanceImageId.ts +66 -0
- package/src/utils/reuseCachedLayouts.ts +92 -0
- package/src/utils/secureConfigFetch.js +115 -0
- package/src/utils/secureConfigFetch.test.js +163 -0
- package/src/utils/seriesDescriptionHistory.ts +83 -0
- package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
- package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
- package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
- package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
- package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
- package/src/utils/validations/checkMultiframe.ts +25 -0
- package/src/utils/validations/checkSingleFrames.ts +36 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { utils, classes } from '@ohif/core';
|
|
2
|
+
import i18n from '@ohif/i18n';
|
|
3
|
+
import { metaData } from '@cornerstonejs/core';
|
|
4
|
+
import { id } from '../id';
|
|
5
|
+
import getDisplaySetMessages from '../getDisplaySetMessages';
|
|
6
|
+
|
|
7
|
+
const { sortStudyInstances, isDisplaySetReconstructable } = utils;
|
|
8
|
+
const { ImageSet } = classes;
|
|
9
|
+
|
|
10
|
+
const DEFAULT_VOLUME_LOADER_SCHEME = 'cornerstoneStreamingImageVolume';
|
|
11
|
+
const DYNAMIC_VOLUME_LOADER_SCHEME = 'cornerstoneStreamingDynamicImageVolume';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The registered module name of the stack SOP class handler, and the resulting
|
|
15
|
+
* fully-qualified `SOPClassHandlerId`.
|
|
16
|
+
*
|
|
17
|
+
* Both live here rather than in `getSopClassHandlerModule` because that module
|
|
18
|
+
* imports this one (the reverse would be a cycle). The handler imports the
|
|
19
|
+
* name back for its registration so the id and the registration can never
|
|
20
|
+
* disagree about what the handler is called.
|
|
21
|
+
*/
|
|
22
|
+
export const STACK_SOP_CLASS_HANDLER_NAME = 'stack';
|
|
23
|
+
export const STACK_SOP_CLASS_HANDLER_ID = `${id}.sopClassHandlerModule.${STACK_SOP_CLASS_HANDLER_NAME}`;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The application context required to build an ImageSet display set. This is
|
|
27
|
+
* the same shape as the `appContext` handed to `getSopClassHandlerModule`.
|
|
28
|
+
*/
|
|
29
|
+
export type ImageSetFactoryContext = {
|
|
30
|
+
servicesManager: AppTypes.ServicesManager;
|
|
31
|
+
extensionManager: AppTypes.ExtensionManager;
|
|
32
|
+
appConfig?: AppTypes.Config;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const isMultiFrame = instance => {
|
|
36
|
+
return instance.NumberOfFrames > 1;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function getDynamicVolumeInfo(imageIds, context: ImageSetFactoryContext) {
|
|
40
|
+
const { extensionManager } = context;
|
|
41
|
+
|
|
42
|
+
if (!extensionManager) {
|
|
43
|
+
throw new Error('extensionManager is not available');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const volumeLoaderUtility = extensionManager.getModuleEntry(
|
|
47
|
+
'@ohif/extension-cornerstone.utilityModule.volumeLoader'
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (!volumeLoaderUtility?.exports) {
|
|
51
|
+
throw new Error('The @ohif/extension-cornerstone volumeLoader utility module is not available');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { getDynamicVolumeInfo: csGetDynamicVolumeInfo } = volumeLoaderUtility.exports;
|
|
55
|
+
|
|
56
|
+
return csGetDynamicVolumeInfo(imageIds);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Computes reconstructability / dynamic-volume information for a set of
|
|
61
|
+
* instances. Callers go through {@link applyImageListAttributes} so creation
|
|
62
|
+
* and incremental updates share one computation.
|
|
63
|
+
*/
|
|
64
|
+
function getDisplaySetInfo(instances, imageIds, context: ImageSetFactoryContext) {
|
|
65
|
+
const dynamicVolumeInfo = getDynamicVolumeInfo(imageIds, context);
|
|
66
|
+
const { isDynamicVolume, timePoints } = dynamicVolumeInfo;
|
|
67
|
+
let displaySetInfo;
|
|
68
|
+
|
|
69
|
+
const { appConfig } = context;
|
|
70
|
+
|
|
71
|
+
if (isDynamicVolume) {
|
|
72
|
+
const timePoint = timePoints[0];
|
|
73
|
+
const instancesMap = new Map();
|
|
74
|
+
|
|
75
|
+
let firstTimePointInstances;
|
|
76
|
+
|
|
77
|
+
if (instances[0].NumberOfFrames > 1 && timePoints.length > 1) {
|
|
78
|
+
// Handle multiframe dynamic volumes. Local file frame imageIds do not
|
|
79
|
+
// always resolve to a frame-level instance object, so keep resolved
|
|
80
|
+
// entries and fall back to the source multiframe instance when needed.
|
|
81
|
+
firstTimePointInstances = timePoints[0]
|
|
82
|
+
.map(imageId => metaData.get('instance', imageId))
|
|
83
|
+
.filter(Boolean);
|
|
84
|
+
|
|
85
|
+
if (!firstTimePointInstances.length) {
|
|
86
|
+
firstTimePointInstances = [instances[0]];
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// O(n) to convert it into a map and O(1) to find each instance
|
|
90
|
+
instances.forEach(instance => instancesMap.set(instance.imageId, instance));
|
|
91
|
+
firstTimePointInstances = timePoint.map(imageId => instancesMap.get(imageId)).filter(Boolean);
|
|
92
|
+
}
|
|
93
|
+
displaySetInfo = isDisplaySetReconstructable(firstTimePointInstances, appConfig);
|
|
94
|
+
} else {
|
|
95
|
+
displaySetInfo = isDisplaySetReconstructable(instances, appConfig);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
isDynamicVolume,
|
|
100
|
+
...displaySetInfo,
|
|
101
|
+
dynamicVolumeInfo,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type MakeImageSetDisplaySetOptions = {
|
|
106
|
+
/**
|
|
107
|
+
* Leave the instance order alone. Set by the split-rule path, which applies
|
|
108
|
+
* OHIF's default order and the matched rule's comparator together, once.
|
|
109
|
+
*/
|
|
110
|
+
skipSort?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The `isReconstructable` that a split rule's attributes set. It replaces
|
|
113
|
+
* the OHIF check, and the messages and the icon follow it.
|
|
114
|
+
*/
|
|
115
|
+
isReconstructable?: boolean;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The generic part of an OHIF display set: an ImageSet over the instances,
|
|
120
|
+
* with the series identity (`displaySetInstanceUID`, the series UIDs, date,
|
|
121
|
+
* number, description, `Modality`, `label`). Every display set of a split
|
|
122
|
+
* rule starts here, whatever its handler.
|
|
123
|
+
*/
|
|
124
|
+
export function makeSeriesDisplaySet(instances) {
|
|
125
|
+
// Need to sort the instances in order to get a consistent instance/thumbnail
|
|
126
|
+
sortStudyInstances(instances);
|
|
127
|
+
const instance = instances[0];
|
|
128
|
+
const imageSet = new ImageSet(instances);
|
|
129
|
+
|
|
130
|
+
// Series-level identity: fixed for the lifetime of the display set, because
|
|
131
|
+
// adding more instances of the SAME series cannot change any of it.
|
|
132
|
+
imageSet.setAttributes({
|
|
133
|
+
displaySetInstanceUID: imageSet.uid, // create a local alias for the imageSet UID
|
|
134
|
+
SeriesDate: instance.SeriesDate,
|
|
135
|
+
SeriesTime: instance.SeriesTime,
|
|
136
|
+
SeriesInstanceUID: instance.SeriesInstanceUID,
|
|
137
|
+
StudyInstanceUID: instance.StudyInstanceUID,
|
|
138
|
+
SeriesNumber: instance.SeriesNumber || 0,
|
|
139
|
+
SOPClassUID: instance.SOPClassUID,
|
|
140
|
+
SeriesDescription: instance.SeriesDescription || '',
|
|
141
|
+
Modality: instance.Modality,
|
|
142
|
+
label:
|
|
143
|
+
instance.SeriesDescription ||
|
|
144
|
+
`${i18n.t('Series')} ${instance.SeriesNumber} - ${i18n.t(instance.Modality)}`,
|
|
145
|
+
});
|
|
146
|
+
return imageSet;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The image part of a display set: the stack SOP class handler id, the
|
|
151
|
+
* image-list attributes (`isReconstructable`, `messages`, ...), the thumbnail
|
|
152
|
+
* and, unless `skipSort`, OHIF's default instance order.
|
|
153
|
+
*/
|
|
154
|
+
export function applyImageAttributes(
|
|
155
|
+
imageSet,
|
|
156
|
+
context: ImageSetFactoryContext,
|
|
157
|
+
options: MakeImageSetDisplaySetOptions = {}
|
|
158
|
+
) {
|
|
159
|
+
const instance = imageSet.images[0];
|
|
160
|
+
imageSet.setAttributes({
|
|
161
|
+
FrameRate: instance.FrameTime,
|
|
162
|
+
SOPClassHandlerId: STACK_SOP_CLASS_HANDLER_ID,
|
|
163
|
+
supportsWindowLevel: true,
|
|
164
|
+
FrameOfReferenceUID: instance.FrameOfReferenceUID,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Everything derived from the image list. `imageSet.sort` reads
|
|
168
|
+
// `isReconstructable`, so this must run before it.
|
|
169
|
+
const derived = applyImageListAttributes(imageSet, context, options.isReconstructable);
|
|
170
|
+
applyThumbnailSrc(imageSet, context, derived);
|
|
171
|
+
|
|
172
|
+
// The legacy SOP class handler path has no rule to consult, so OHIF's default
|
|
173
|
+
// order is the whole answer and is applied here. The split-rule path passes
|
|
174
|
+
// `skipSort` and orders once itself, folding the matched rule's comparator in
|
|
175
|
+
// over this same default - see `applyInstanceOrder`.
|
|
176
|
+
if (!options.skipSort) {
|
|
177
|
+
imageSet.sort(context.servicesManager.services.customizationService);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Builds a stack/volume ImageSet display set carrying the full OHIF attribute
|
|
183
|
+
* set (`label`, `supportsWindowLevel`, `FrameOfReferenceUID`,
|
|
184
|
+
* `SOPClassHandlerId`, `isReconstructable`, `messages`, ...): the generic part
|
|
185
|
+
* and the image part.
|
|
186
|
+
*
|
|
187
|
+
* The legacy stack SOP class handler and the split-rule path share these two
|
|
188
|
+
* parts, so both paths produce identical image display sets.
|
|
189
|
+
*/
|
|
190
|
+
export function makeImageSetDisplaySet(
|
|
191
|
+
instances,
|
|
192
|
+
context: ImageSetFactoryContext,
|
|
193
|
+
options: MakeImageSetDisplaySetOptions = {}
|
|
194
|
+
) {
|
|
195
|
+
const imageSet = makeSeriesDisplaySet(instances);
|
|
196
|
+
applyImageAttributes(imageSet, context, options);
|
|
197
|
+
return imageSet;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Applies every attribute derived from an ImageSet's current image list.
|
|
202
|
+
*
|
|
203
|
+
* Shared by the initial build and the split-rule `extendInstances` growth hook
|
|
204
|
+
* so the two cannot drift: whatever is recomputed here is, by construction,
|
|
205
|
+
* recomputed identically when instances arrive later.
|
|
206
|
+
*
|
|
207
|
+
* Series-level identity (`label`, `SeriesDescription`, `Modality`, ...) is
|
|
208
|
+
* deliberately NOT touched — it cannot change by adding instances to the same
|
|
209
|
+
* series, and a split rule's `customAttributes` may have overridden it (e.g.
|
|
210
|
+
* the SCOUT example relabels `SeriesDescription`).
|
|
211
|
+
*
|
|
212
|
+
* @param ruleIsReconstructable - a value that a split rule's attributes set;
|
|
213
|
+
* it replaces the OHIF check.
|
|
214
|
+
* @returns the intermediate values a caller needs for the thumbnail.
|
|
215
|
+
*/
|
|
216
|
+
export function applyImageListAttributes(
|
|
217
|
+
imageSet,
|
|
218
|
+
context: ImageSetFactoryContext,
|
|
219
|
+
ruleIsReconstructable?: boolean
|
|
220
|
+
) {
|
|
221
|
+
const dataSource = context.extensionManager.getActiveDataSource()[0];
|
|
222
|
+
const imageIds = dataSource.getImageIdsForDisplaySet(imageSet);
|
|
223
|
+
const {
|
|
224
|
+
isDynamicVolume,
|
|
225
|
+
value: checkedIsReconstructable,
|
|
226
|
+
averageSpacingBetweenFrames,
|
|
227
|
+
dynamicVolumeInfo,
|
|
228
|
+
} = getDisplaySetInfo(imageSet.images, imageIds, context);
|
|
229
|
+
|
|
230
|
+
// `ImageSet` snapshots `instance = images[0]` in its constructor and `sort()`
|
|
231
|
+
// does not refresh it, so an instance that sorts to the front would otherwise
|
|
232
|
+
// leave `instance` pointing at the wrong image.
|
|
233
|
+
const instance = imageSet.images[0];
|
|
234
|
+
const multiFrame = isMultiFrame(instance);
|
|
235
|
+
const isReconstructable = ruleIsReconstructable ?? checkedIsReconstructable;
|
|
236
|
+
|
|
237
|
+
imageSet.setAttributes({
|
|
238
|
+
instance,
|
|
239
|
+
isMultiFrame: multiFrame,
|
|
240
|
+
volumeLoaderSchema: isDynamicVolume
|
|
241
|
+
? DYNAMIC_VOLUME_LOADER_SCHEME
|
|
242
|
+
: DEFAULT_VOLUME_LOADER_SCHEME,
|
|
243
|
+
// A multiframe display set holds one instance whose frames are the content;
|
|
244
|
+
// a stack counts images.
|
|
245
|
+
numImageFrames: multiFrame ? Number(instance.NumberOfFrames) : imageSet.images.length,
|
|
246
|
+
countIcon: isReconstructable ? 'icon-mpr' : undefined,
|
|
247
|
+
isReconstructable,
|
|
248
|
+
messages: getDisplaySetMessages(imageSet.images, isReconstructable, isDynamicVolume),
|
|
249
|
+
averageSpacingBetweenFrames: averageSpacingBetweenFrames || null,
|
|
250
|
+
isDynamicVolume,
|
|
251
|
+
dynamicVolumeInfo,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return { imageIds, isDynamicVolume, dynamicVolumeInfo };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Picks the middle image (middle time point when dynamic) as the thumbnail. */
|
|
258
|
+
export function applyThumbnailSrc(
|
|
259
|
+
imageSet,
|
|
260
|
+
context: ImageSetFactoryContext,
|
|
261
|
+
{ imageIds, isDynamicVolume, dynamicVolumeInfo }
|
|
262
|
+
) {
|
|
263
|
+
const dataSource = context.extensionManager.getActiveDataSource()[0];
|
|
264
|
+
let imageId = imageIds[Math.floor(imageIds.length / 2)];
|
|
265
|
+
const thumbnailInstance = imageSet.images[Math.floor(imageSet.images.length / 2)];
|
|
266
|
+
if (isDynamicVolume) {
|
|
267
|
+
const timePoints = dynamicVolumeInfo.timePoints;
|
|
268
|
+
const middleIndex = Math.floor(timePoints.length / 2);
|
|
269
|
+
const middleTimePointImageIds = timePoints[middleIndex];
|
|
270
|
+
imageId = middleTimePointImageIds[Math.floor(middleTimePointImageIds.length / 2)];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
imageSet.setAttributes({
|
|
274
|
+
getThumbnailSrc: dataSource.retrieve.getGetThumbnailSrc?.(thumbnailInstance, imageId),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { utils } from '@ohif/core';
|
|
2
|
+
|
|
3
|
+
const { sopClassDictionary } = utils;
|
|
4
|
+
|
|
5
|
+
/** The SOP classes the stack SOP class handler claims. */
|
|
6
|
+
export const STACK_SOP_CLASS_UIDS = [
|
|
7
|
+
sopClassDictionary.ComputedRadiographyImageStorage,
|
|
8
|
+
sopClassDictionary.DigitalXRayImageStorageForPresentation,
|
|
9
|
+
sopClassDictionary.DigitalXRayImageStorageForProcessing,
|
|
10
|
+
sopClassDictionary.DigitalMammographyXRayImageStorageForPresentation,
|
|
11
|
+
sopClassDictionary.DigitalMammographyXRayImageStorageForProcessing,
|
|
12
|
+
sopClassDictionary.DigitalIntraOralXRayImageStorageForPresentation,
|
|
13
|
+
sopClassDictionary.DigitalIntraOralXRayImageStorageForProcessing,
|
|
14
|
+
sopClassDictionary.CTImageStorage,
|
|
15
|
+
sopClassDictionary.EnhancedCTImageStorage,
|
|
16
|
+
sopClassDictionary.LegacyConvertedEnhancedCTImageStorage,
|
|
17
|
+
sopClassDictionary.UltrasoundMultiframeImageStorage,
|
|
18
|
+
sopClassDictionary.MRImageStorage,
|
|
19
|
+
sopClassDictionary.EnhancedMRImageStorage,
|
|
20
|
+
sopClassDictionary.EnhancedMRColorImageStorage,
|
|
21
|
+
sopClassDictionary.LegacyConvertedEnhancedMRImageStorage,
|
|
22
|
+
sopClassDictionary.UltrasoundImageStorage,
|
|
23
|
+
sopClassDictionary.UltrasoundImageStorageRET,
|
|
24
|
+
sopClassDictionary.SecondaryCaptureImageStorage,
|
|
25
|
+
sopClassDictionary.MultiframeSingleBitSecondaryCaptureImageStorage,
|
|
26
|
+
sopClassDictionary.MultiframeGrayscaleByteSecondaryCaptureImageStorage,
|
|
27
|
+
sopClassDictionary.MultiframeGrayscaleWordSecondaryCaptureImageStorage,
|
|
28
|
+
sopClassDictionary.MultiframeTrueColorSecondaryCaptureImageStorage,
|
|
29
|
+
sopClassDictionary.XRayAngiographicImageStorage,
|
|
30
|
+
sopClassDictionary.EnhancedXAImageStorage,
|
|
31
|
+
sopClassDictionary.XRayRadiofluoroscopicImageStorage,
|
|
32
|
+
sopClassDictionary.EnhancedXRFImageStorage,
|
|
33
|
+
sopClassDictionary.XRay3DAngiographicImageStorage,
|
|
34
|
+
sopClassDictionary.XRay3DCraniofacialImageStorage,
|
|
35
|
+
sopClassDictionary.BreastTomosynthesisImageStorage,
|
|
36
|
+
sopClassDictionary.CornealTopographyMapStorage,
|
|
37
|
+
sopClassDictionary.BreastProjectionXRayImageStorageForPresentation,
|
|
38
|
+
sopClassDictionary.BreastProjectionXRayImageStorageForProcessing,
|
|
39
|
+
sopClassDictionary.IntravascularOpticalCoherenceTomographyImageStorageForPresentation,
|
|
40
|
+
sopClassDictionary.IntravascularOpticalCoherenceTomographyImageStorageForProcessing,
|
|
41
|
+
sopClassDictionary.NuclearMedicineImageStorage,
|
|
42
|
+
sopClassDictionary.VLEndoscopicImageStorage,
|
|
43
|
+
sopClassDictionary.VideoEndoscopicImageStorage,
|
|
44
|
+
sopClassDictionary.VLMicroscopicImageStorage,
|
|
45
|
+
sopClassDictionary.VideoMicroscopicImageStorage,
|
|
46
|
+
sopClassDictionary.VLSlideCoordinatesMicroscopicImageStorage,
|
|
47
|
+
sopClassDictionary.VLPhotographicImageStorage,
|
|
48
|
+
sopClassDictionary.VideoPhotographicImageStorage,
|
|
49
|
+
sopClassDictionary.OphthalmicPhotography8BitImageStorage,
|
|
50
|
+
sopClassDictionary.OphthalmicPhotography16BitImageStorage,
|
|
51
|
+
sopClassDictionary.OphthalmicTomographyImageStorage,
|
|
52
|
+
// Handled by another sop class module
|
|
53
|
+
// sopClassDictionary.VLWholeSlideMicroscopyImageStorage,
|
|
54
|
+
sopClassDictionary.PositronEmissionTomographyImageStorage,
|
|
55
|
+
sopClassDictionary.EnhancedPETImageStorage,
|
|
56
|
+
sopClassDictionary.LegacyConvertedEnhancedPETImageStorage,
|
|
57
|
+
sopClassDictionary.RTImageStorage,
|
|
58
|
+
sopClassDictionary.EnhancedUSVolumeStorage,
|
|
59
|
+
sopClassDictionary.RTDoseStorage,
|
|
60
|
+
];
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import JSON5 from 'json5';
|
|
4
|
+
import { newContext } from 'immutability-helper';
|
|
5
|
+
import {
|
|
6
|
+
createDisplaySetSplitRules,
|
|
7
|
+
defaultMetadataContext,
|
|
8
|
+
displaySetRuleOrder,
|
|
9
|
+
displaySetRules,
|
|
10
|
+
groupInstancesBySplitRules,
|
|
11
|
+
materializeSplitRules,
|
|
12
|
+
spliceById,
|
|
13
|
+
} from '@cornerstonejs/metadata';
|
|
14
|
+
import { CustomizationService } from '@ohif/core';
|
|
15
|
+
import getMetadataDisplaySetCustomization from '../customizations/metadataDisplaySetCustomization';
|
|
16
|
+
import getMetadataContextCustomization from '../customizations/metadataContextCustomization';
|
|
17
|
+
import optionalSplitRulesCopyPattern from '../../../../platform/app/.rspack/optionalSplitRulesCopyPattern';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The `split/*.jsonc` URL modules in platform/app/public are data that no
|
|
21
|
+
* build step checks. These tests apply each module as a server does: with
|
|
22
|
+
* `JSON5`, the standard `immutability-helper` commands and the
|
|
23
|
+
* `@cornerstonejs/metadata` defaults, and with no OHIF code.
|
|
24
|
+
*
|
|
25
|
+
* The `split/optional/<id>` modules are the `rules/optional/<id>.jsonc` files
|
|
26
|
+
* of @cornerstonejs/metadata, wrapped by the copy pattern of the build. A
|
|
27
|
+
* metadata version without the files has no optional modules.
|
|
28
|
+
*/
|
|
29
|
+
const SPLIT_DIR = path.resolve(__dirname, '../../../../platform/app/public/customizations/split');
|
|
30
|
+
const OPTIONAL = optionalSplitRulesCopyPattern('');
|
|
31
|
+
const OPTIONAL_NAMES = fs.existsSync(OPTIONAL.from)
|
|
32
|
+
? fs
|
|
33
|
+
.readdirSync(OPTIONAL.from)
|
|
34
|
+
.filter(file => file.endsWith('.jsonc'))
|
|
35
|
+
.map(file => `optional/${file.replace(/\.jsonc$/, '')}`)
|
|
36
|
+
: [];
|
|
37
|
+
|
|
38
|
+
const readModule = (name: string) =>
|
|
39
|
+
JSON5.parse(
|
|
40
|
+
name.startsWith('optional/')
|
|
41
|
+
? OPTIONAL.transform(
|
|
42
|
+
fs.readFileSync(path.join(OPTIONAL.from, `${name.slice('optional/'.length)}.jsonc`))
|
|
43
|
+
)
|
|
44
|
+
: fs.readFileSync(path.join(SPLIT_DIR, `${name}.jsonc`), 'utf8')
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const MODULE_NAMES = [
|
|
48
|
+
...fs
|
|
49
|
+
.readdirSync(SPLIT_DIR)
|
|
50
|
+
.filter(file => file.endsWith('.jsonc'))
|
|
51
|
+
.map(file => file.replace(/\.jsonc$/, '')),
|
|
52
|
+
...OPTIONAL_NAMES,
|
|
53
|
+
];
|
|
54
|
+
const describeOptional = OPTIONAL_NAMES.length ? describe : describe.skip;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* `immutability-helper` as a server has it: the standard commands, and
|
|
58
|
+
* `$spliceById` of `@cornerstonejs/metadata` (SP-SRV-3). No OHIF `$filter`.
|
|
59
|
+
*/
|
|
60
|
+
const standardUpdate = newContext();
|
|
61
|
+
standardUpdate.extend('$spliceById', (spec, list) => spliceById(list as string[], spec));
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The customizations a server gets for one module: the CS3D defaults, then
|
|
65
|
+
* the `global` block of each required module, then of the module itself.
|
|
66
|
+
*/
|
|
67
|
+
const serverCustomizations = (name: string) => {
|
|
68
|
+
let value = {
|
|
69
|
+
useMetadataDisplaySet: { enabled: false, displaySetRules, displaySetRuleOrder },
|
|
70
|
+
metadataContext: defaultMetadataContext,
|
|
71
|
+
};
|
|
72
|
+
const applied = new Set<string>();
|
|
73
|
+
const apply = (moduleName: string) => {
|
|
74
|
+
if (applied.has(moduleName)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
applied.add(moduleName);
|
|
78
|
+
const module = readModule(moduleName);
|
|
79
|
+
(module.requires ?? []).forEach(required => apply(required.replace(/^split\//, '')));
|
|
80
|
+
value = standardUpdate(value, module.global ?? {});
|
|
81
|
+
};
|
|
82
|
+
apply(name);
|
|
83
|
+
return value;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** The split rules of one module, compiled as a server compiles them. */
|
|
87
|
+
const compileModule = (name: string, overlay = {}) => {
|
|
88
|
+
const { useMetadataDisplaySet, metadataContext } = serverCustomizations(name);
|
|
89
|
+
const registry = standardUpdate(useMetadataDisplaySet.displaySetRules, overlay);
|
|
90
|
+
return createDisplaySetSplitRules(
|
|
91
|
+
materializeSplitRules(registry, useMetadataDisplaySet.displaySetRuleOrder),
|
|
92
|
+
{ context: metadataContext }
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** The `useMetadataDisplaySet` value that OHIF gets for one module. */
|
|
97
|
+
const ohifSplitCustomization = async (name: string) => {
|
|
98
|
+
const service = new CustomizationService({ configuration: {}, commandsManager: {} } as never);
|
|
99
|
+
service.setCustomizations(
|
|
100
|
+
{
|
|
101
|
+
...getMetadataDisplaySetCustomization({} as never),
|
|
102
|
+
...getMetadataContextCustomization(),
|
|
103
|
+
},
|
|
104
|
+
service.Scope.Default
|
|
105
|
+
);
|
|
106
|
+
await service.requires([`split/${name}`], {
|
|
107
|
+
policy: { prefixes: { default: './customizations/' } },
|
|
108
|
+
importFn: async (url: string) => readModule(url.match(/split\/([\w/]+)\.jsonc$/)[1]),
|
|
109
|
+
});
|
|
110
|
+
return service.getCustomization('useMetadataDisplaySet') as {
|
|
111
|
+
enabled: boolean;
|
|
112
|
+
displaySetRules: unknown;
|
|
113
|
+
displaySetRuleOrder: unknown;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const MR_IMAGE_STORAGE = '1.2.840.10008.5.1.4.1.1.4';
|
|
118
|
+
|
|
119
|
+
let counter = 0;
|
|
120
|
+
const mr = (overrides: Record<string, unknown> = {}) => ({
|
|
121
|
+
SOPInstanceUID: `sop-${++counter}`,
|
|
122
|
+
SeriesInstanceUID: 'series-1',
|
|
123
|
+
StudyInstanceUID: 'study-1',
|
|
124
|
+
SeriesDescription: 'DWI',
|
|
125
|
+
Modality: 'MR',
|
|
126
|
+
SOPClassUID: MR_IMAGE_STORAGE,
|
|
127
|
+
Rows: 128,
|
|
128
|
+
Columns: 128,
|
|
129
|
+
InstanceNumber: counter,
|
|
130
|
+
...overrides,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const CT_IMAGE_STORAGE = '1.2.840.10008.5.1.4.1.1.2';
|
|
134
|
+
const ct = (z: number, InstanceNumber: number) => ({
|
|
135
|
+
...mr(),
|
|
136
|
+
Modality: 'CT',
|
|
137
|
+
SeriesDescription: 'AX',
|
|
138
|
+
SOPClassUID: CT_IMAGE_STORAGE,
|
|
139
|
+
InstanceNumber,
|
|
140
|
+
ImageOrientationPatient: [1, 0, 0, 0, 1, 0],
|
|
141
|
+
ImagePositionPatient: [0, 0, z],
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const rows = groups =>
|
|
145
|
+
groups.map(group => [group.matchedRule.id, group.instances.map(i => i.InstanceNumber)]);
|
|
146
|
+
|
|
147
|
+
describe('split URL modules', () => {
|
|
148
|
+
beforeEach(() => {
|
|
149
|
+
counter = 0;
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// SP-SRV-3: the same rules without OHIF code.
|
|
153
|
+
it.each(MODULE_NAMES)(
|
|
154
|
+
'%s gives a server and OHIF the same split rules, with no OHIF code on the server',
|
|
155
|
+
async name => {
|
|
156
|
+
const server = serverCustomizations(name).useMetadataDisplaySet;
|
|
157
|
+
const ohif = await ohifSplitCustomization(name);
|
|
158
|
+
|
|
159
|
+
expect(ohif.enabled).toBe(server.enabled);
|
|
160
|
+
expect(ohif.displaySetRules).toEqual(server.displaySetRules);
|
|
161
|
+
expect(ohif.displaySetRuleOrder).toEqual(server.displaySetRuleOrder);
|
|
162
|
+
expect(() => compileModule(name)).not.toThrow();
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
describeOptional('optional/dwiByBValue', () => {
|
|
167
|
+
it('dwiByBValue makes one display set for each b-value', () => {
|
|
168
|
+
const rules = compileModule('optional/dwiByBValue');
|
|
169
|
+
const series = [
|
|
170
|
+
...[1, 2, 3].map(() => mr({ DiffusionBValue: 0 })),
|
|
171
|
+
...[1, 2, 3].map(() => mr({ DiffusionBValue: 1000 })),
|
|
172
|
+
...[1, 2, 3].map(() => mr({ DiffusionBValue: 500 })),
|
|
173
|
+
];
|
|
174
|
+
const groups = groupInstancesBySplitRules(series as any, rules);
|
|
175
|
+
|
|
176
|
+
expect(groups.map(group => group.matchedRule.id)).toEqual([
|
|
177
|
+
'dwiByBValue',
|
|
178
|
+
'dwiByBValue',
|
|
179
|
+
'dwiByBValue',
|
|
180
|
+
]);
|
|
181
|
+
// The natural order of the keys puts the groups in b-value order.
|
|
182
|
+
expect(groups.map(group => group.instances.map(i => i.DiffusionBValue)[0])).toEqual([
|
|
183
|
+
0, 500, 1000,
|
|
184
|
+
]);
|
|
185
|
+
expect(groups.every(group => group.instances.length === 3)).toBe(true);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('dwiByBValue leaves the frames without a b-value to mixedDimensionalityBValue', () => {
|
|
189
|
+
const rules = compileModule('optional/dwiByBValue');
|
|
190
|
+
const series = [...[1, 2].map(() => mr({ DiffusionBValue: 800 })), ...[1, 2].map(() => mr())];
|
|
191
|
+
const groups = groupInstancesBySplitRules(series as any, rules);
|
|
192
|
+
|
|
193
|
+
expect(groups.map(group => [group.matchedRule.id, group.instances.length])).toEqual([
|
|
194
|
+
['dwiByBValue', 2],
|
|
195
|
+
['mixedDimensionalityBValue', 2],
|
|
196
|
+
]);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('dwiByBValue leaves a series of b=0 frames only to the default rules', () => {
|
|
200
|
+
const rules = compileModule('optional/dwiByBValue');
|
|
201
|
+
const series = [1, 2, 3].map(() => mr({ SeriesDescription: 'T2W', DiffusionBValue: 0 }));
|
|
202
|
+
const groups = groupInstancesBySplitRules(series as any, rules);
|
|
203
|
+
|
|
204
|
+
expect(groups.map(group => [group.matchedRule.id, group.instances.length])).toEqual([
|
|
205
|
+
['volume3d', 3],
|
|
206
|
+
]);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('single images', () => {
|
|
211
|
+
const SOP_CLASS = {
|
|
212
|
+
DX: '1.2.840.10008.5.1.4.1.1.1.1',
|
|
213
|
+
CR: '1.2.840.10008.5.1.4.1.1.1',
|
|
214
|
+
MG: '1.2.840.10008.5.1.4.1.1.1.2',
|
|
215
|
+
};
|
|
216
|
+
const image = (Modality: 'DX' | 'CR' | 'MG', size = 128) => ({
|
|
217
|
+
...mr(),
|
|
218
|
+
SeriesDescription: Modality,
|
|
219
|
+
Modality,
|
|
220
|
+
SOPClassUID: SOP_CLASS[Modality],
|
|
221
|
+
Rows: size,
|
|
222
|
+
Columns: size,
|
|
223
|
+
});
|
|
224
|
+
const split = (moduleName: string, images) =>
|
|
225
|
+
groupInstancesBySplitRules(images as any, compileModule(moduleName)).map(group => [
|
|
226
|
+
group.matchedRule.id,
|
|
227
|
+
group.instances.length,
|
|
228
|
+
]);
|
|
229
|
+
|
|
230
|
+
// DS-USER-SPLIT: a four-view MG series gives four display sets, as before #6137.
|
|
231
|
+
it.each(['MG', 'DX', 'CR'] as const)(
|
|
232
|
+
'the default rules make one display set for each image of a %s series',
|
|
233
|
+
modality => {
|
|
234
|
+
expect(
|
|
235
|
+
split(
|
|
236
|
+
'enableNewSplit',
|
|
237
|
+
[1, 2, 3, 4].map(() => image(modality))
|
|
238
|
+
)
|
|
239
|
+
).toEqual(Array.from({ length: 4 }, () => ['singleImageModality', 1]));
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
// DS-USER-SPLIT-1.
|
|
244
|
+
it('singleImagesBySize makes one display set for each image size', () => {
|
|
245
|
+
const images = [image('DX', 128), image('DX', 1024), image('DX', 128)];
|
|
246
|
+
expect(split('singleImagesBySize', images)).toEqual([
|
|
247
|
+
['singleImagesBySize', 2],
|
|
248
|
+
['singleImagesBySize', 1],
|
|
249
|
+
]);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// DS-USER-SPLIT-2.
|
|
254
|
+
describe('decimation', () => {
|
|
255
|
+
const series = () => [0, 2, 4, 6, 8].map((z, index) => ct(z, index + 1));
|
|
256
|
+
|
|
257
|
+
it('splits a series into ceil(count / decimationSize) parts, by sliceIndex modulo the count', () => {
|
|
258
|
+
const rules = compileModule('decimation', {
|
|
259
|
+
decimation: { context: { decimationSize: { $set: 2 } } },
|
|
260
|
+
});
|
|
261
|
+
expect(rows(groupInstancesBySplitRules(series() as any, rules))).toEqual([
|
|
262
|
+
['decimation', [1, 4]],
|
|
263
|
+
['decimation', [2, 5]],
|
|
264
|
+
['decimation', [3]],
|
|
265
|
+
]);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('leaves a series of decimationSize (1000) images or fewer to the default rules', () => {
|
|
269
|
+
expect(
|
|
270
|
+
rows(groupInstancesBySplitRules(series() as any, compileModule('decimation')))
|
|
271
|
+
).toEqual([['volume3d', [1, 2, 3, 4, 5]]]);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
describe('series context modules', () => {
|
|
276
|
+
const US_IMAGE_STORAGE = '1.2.840.10008.5.1.4.1.1.6.1';
|
|
277
|
+
|
|
278
|
+
it('regularVolume makes a volume of the regular slices, and leaves the extra slice', () => {
|
|
279
|
+
// Slices every 2 mm, and one extra slice at 3.1 mm.
|
|
280
|
+
const series = [ct(0, 1), ct(2, 2), ct(4, 3), ct(6, 4), ct(3.1, 5)];
|
|
281
|
+
|
|
282
|
+
expect(
|
|
283
|
+
rows(groupInstancesBySplitRules(series as any, compileModule('regularVolume')))
|
|
284
|
+
).toEqual([
|
|
285
|
+
['regularVolume', [1, 2, 3, 4]],
|
|
286
|
+
['volume3d', [5]],
|
|
287
|
+
]);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('regularVolume keeps a fully regular series as the default volume', () => {
|
|
291
|
+
const series = [ct(0, 1), ct(2, 2), ct(4, 3)];
|
|
292
|
+
|
|
293
|
+
expect(
|
|
294
|
+
rows(groupInstancesBySplitRules(series as any, compileModule('regularVolume')))
|
|
295
|
+
).toEqual([['volume3d', [1, 2, 3]]]);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('usTimeClusters makes one display set for each sweep, in time order', () => {
|
|
299
|
+
const us = (AcquisitionTime: string, InstanceNumber: number) => ({
|
|
300
|
+
...mr(),
|
|
301
|
+
Modality: 'US',
|
|
302
|
+
SeriesDescription: 'Liver',
|
|
303
|
+
SOPClassUID: US_IMAGE_STORAGE,
|
|
304
|
+
AcquisitionDate: '20260101',
|
|
305
|
+
AcquisitionTime,
|
|
306
|
+
InstanceNumber,
|
|
307
|
+
});
|
|
308
|
+
// Two sweeps, 5 minutes apart; the instance numbers do not follow time.
|
|
309
|
+
const series = [
|
|
310
|
+
us('100500', 1),
|
|
311
|
+
us('100505', 2),
|
|
312
|
+
us('100000', 3),
|
|
313
|
+
us('100003', 4),
|
|
314
|
+
us('100006', 5),
|
|
315
|
+
];
|
|
316
|
+
const groups = groupInstancesBySplitRules(series as any, compileModule('usTimeClusters'));
|
|
317
|
+
|
|
318
|
+
expect(rows(groups)).toEqual([
|
|
319
|
+
['usTimeClusters', [3, 4, 5]],
|
|
320
|
+
['usTimeClusters', [1, 2]],
|
|
321
|
+
]);
|
|
322
|
+
expect(
|
|
323
|
+
groups.map(
|
|
324
|
+
group =>
|
|
325
|
+
group.matchedRule.customAttributes(
|
|
326
|
+
{ instance: group.instances[0] },
|
|
327
|
+
{ instances: group.instances, series: group.series }
|
|
328
|
+
).SeriesDescription
|
|
329
|
+
)
|
|
330
|
+
).toEqual(['Liver +0 s', 'Liver +300 s']);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
});
|