@ohif/extension-cornerstone 3.14.0-beta.119 → 3.14.0-beta.120
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohif/extension-cornerstone",
|
|
3
|
-
"version": "3.14.0-beta.
|
|
3
|
+
"version": "3.14.0-beta.120",
|
|
4
4
|
"description": "OHIF extension for Cornerstone",
|
|
5
5
|
"author": "OHIF",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"@cornerstonejs/codec-libjpeg-turbo-8bit": "1.2.4",
|
|
36
36
|
"@cornerstonejs/codec-openjpeg": "1.3.2",
|
|
37
37
|
"@cornerstonejs/codec-openjph": "2.4.9",
|
|
38
|
-
"@cornerstonejs/dicom-image-loader": "5.
|
|
39
|
-
"@ohif/core": "3.14.0-beta.
|
|
40
|
-
"@ohif/extension-default": "3.14.0-beta.
|
|
41
|
-
"@ohif/ui-next": "3.14.0-beta.
|
|
38
|
+
"@cornerstonejs/dicom-image-loader": "5.24.0",
|
|
39
|
+
"@ohif/core": "3.14.0-beta.120",
|
|
40
|
+
"@ohif/extension-default": "3.14.0-beta.120",
|
|
41
|
+
"@ohif/ui-next": "3.14.0-beta.120",
|
|
42
42
|
"dcmjs": "0.52.0",
|
|
43
43
|
"dicom-parser": "1.8.21",
|
|
44
44
|
"hammerjs": "2.0.8",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/runtime": "7.29.7",
|
|
50
|
-
"@cornerstonejs/adapters": "5.
|
|
51
|
-
"@cornerstonejs/ai": "5.
|
|
52
|
-
"@cornerstonejs/core": "5.
|
|
53
|
-
"@cornerstonejs/labelmap-interpolation": "5.
|
|
54
|
-
"@cornerstonejs/metadata": "5.
|
|
55
|
-
"@cornerstonejs/polymorphic-segmentation": "5.
|
|
56
|
-
"@cornerstonejs/tools": "5.
|
|
57
|
-
"@cornerstonejs/utils": "5.
|
|
50
|
+
"@cornerstonejs/adapters": "5.24.0",
|
|
51
|
+
"@cornerstonejs/ai": "5.24.0",
|
|
52
|
+
"@cornerstonejs/core": "5.24.0",
|
|
53
|
+
"@cornerstonejs/labelmap-interpolation": "5.24.0",
|
|
54
|
+
"@cornerstonejs/metadata": "5.24.0",
|
|
55
|
+
"@cornerstonejs/polymorphic-segmentation": "5.24.0",
|
|
56
|
+
"@cornerstonejs/tools": "5.24.0",
|
|
57
|
+
"@cornerstonejs/utils": "5.24.0",
|
|
58
58
|
"@icr/polyseg-wasm": "0.4.0",
|
|
59
59
|
"@itk-wasm/morphological-contour-interpolation": "1.1.0",
|
|
60
60
|
"@kitware/vtk.js": "36.4.1",
|
package/src/commandsModule.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { getFirstAnnotationSelected } from './utils/measurementServiceMappings/u
|
|
|
37
37
|
import { getViewportEnabledElement } from './utils/getViewportEnabledElement';
|
|
38
38
|
import getActiveViewportEnabledElement from './utils/getActiveViewportEnabledElement';
|
|
39
39
|
import toggleVOISliceSync from './utils/toggleVOISliceSync';
|
|
40
|
+
import { findWindowLevelPreset } from './utils/findWindowLevelPreset';
|
|
40
41
|
import {
|
|
41
42
|
isStackViewportType,
|
|
42
43
|
isOrthographicViewportType,
|
|
@@ -1167,9 +1168,16 @@ function commandsModule({
|
|
|
1167
1168
|
return;
|
|
1168
1169
|
}
|
|
1169
1170
|
|
|
1170
|
-
const windowLevelPreset =
|
|
1171
|
-
windowLevelPresetForModality
|
|
1172
|
-
|
|
1171
|
+
const windowLevelPreset = findWindowLevelPreset(
|
|
1172
|
+
windowLevelPresetForModality,
|
|
1173
|
+
presetName,
|
|
1174
|
+
presetIndex
|
|
1175
|
+
);
|
|
1176
|
+
|
|
1177
|
+
// A customization can have fewer presets than there are W/L hotkeys.
|
|
1178
|
+
if (!windowLevelPreset) {
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1173
1181
|
|
|
1174
1182
|
actions.setViewportWindowLevel({
|
|
1175
1183
|
viewportId: activeViewport,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { findWindowLevelPreset } from './findWindowLevelPreset';
|
|
2
|
+
import defaultWindowLevelPresets from '../components/WindowLevelActionMenu/defaultWindowLevelPresets';
|
|
3
|
+
|
|
4
|
+
// The CT presets of platform/app/public/customizations/tools/ctPresets.jsonc
|
|
5
|
+
const fourCtPresets = [
|
|
6
|
+
{ id: 'ct-soft-tissue', description: 'Soft tissue', window: '400', level: '40' },
|
|
7
|
+
{ id: 'ct-lung', description: 'Lung', window: '1500', level: '-600' },
|
|
8
|
+
{ id: 'ct-angio', description: 'Angio', window: '600', level: '300' },
|
|
9
|
+
{ id: 'ct-bone', description: 'Bone', window: '2500', level: '480' },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
describe('findWindowLevelPreset', () => {
|
|
13
|
+
it('finds a default CT preset by its id', () => {
|
|
14
|
+
const preset = findWindowLevelPreset(defaultWindowLevelPresets.CT, 'ct-brain', 4);
|
|
15
|
+
|
|
16
|
+
expect(preset).toMatchObject({ id: 'ct-brain', window: '80', level: '40' });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('finds the preset by id when a customization orders the presets differently', () => {
|
|
20
|
+
const preset = findWindowLevelPreset(fourCtPresets, 'ct-bone', 2);
|
|
21
|
+
|
|
22
|
+
expect(preset).toMatchObject({ id: 'ct-bone', window: '2500', level: '480' });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('uses the position when no preset has the id', () => {
|
|
26
|
+
const preset = findWindowLevelPreset(fourCtPresets, 'ct-liver', 2);
|
|
27
|
+
|
|
28
|
+
expect(preset).toMatchObject({ id: 'ct-angio' });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('returns undefined when neither the id nor the position matches', () => {
|
|
32
|
+
expect(findWindowLevelPreset(fourCtPresets, 'ct-brain', 4)).toBeUndefined();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('supports presets given as an object keyed by id', () => {
|
|
36
|
+
const presets = {
|
|
37
|
+
'ct-lung': { description: 'Lung', window: '1500', level: '-600' },
|
|
38
|
+
'ct-bone': { description: 'Bone', window: '2500', level: '480' },
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
expect(findWindowLevelPreset(presets, 'ct-bone', 0)).toMatchObject({ window: '2500' });
|
|
42
|
+
expect(findWindowLevelPreset(presets, 'ct-brain', 0)).toMatchObject({ window: '1500' });
|
|
43
|
+
expect(findWindowLevelPreset(presets, 'ct-brain', 2)).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('does not match inherited object properties', () => {
|
|
47
|
+
const presets = { 'ct-lung': { description: 'Lung', window: '1500', level: '-600' } };
|
|
48
|
+
|
|
49
|
+
expect(findWindowLevelPreset(presets, 'toString', 5)).toBeUndefined();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('returns undefined when the modality has no presets', () => {
|
|
53
|
+
expect(findWindowLevelPreset(undefined, 'ct-brain', 4)).toBeUndefined();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { WindowLevelPreset } from '../types/WindowLevel';
|
|
2
|
+
|
|
3
|
+
type PresetEntry = WindowLevelPreset & { id?: string };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Finds the window level preset that a hotkey asks for.
|
|
7
|
+
*
|
|
8
|
+
* The presets of a modality are usually an array of entries with an `id`
|
|
9
|
+
* (see `defaultWindowLevelPresets`), but a customization can also give them
|
|
10
|
+
* as an object keyed by id. The preset is looked up by `presetName` first,
|
|
11
|
+
* then by its position `presetIndex`.
|
|
12
|
+
*
|
|
13
|
+
* @param presets - The presets of one modality, as an array or an object keyed by id
|
|
14
|
+
* @param presetName - The id of the preset, for example `ct-brain`
|
|
15
|
+
* @param presetIndex - The position of the preset, used when no preset has that id
|
|
16
|
+
* @returns The preset, or undefined when neither the id nor the position matches,
|
|
17
|
+
* for example when a customization has fewer presets than there are hotkeys
|
|
18
|
+
*/
|
|
19
|
+
export function findWindowLevelPreset(
|
|
20
|
+
presets: PresetEntry[] | Record<string, PresetEntry> | undefined,
|
|
21
|
+
presetName?: string,
|
|
22
|
+
presetIndex?: number
|
|
23
|
+
): PresetEntry | undefined {
|
|
24
|
+
if (!presets) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const entries = Array.isArray(presets) ? presets : Object.values(presets);
|
|
29
|
+
|
|
30
|
+
if (presetName) {
|
|
31
|
+
const byName = Array.isArray(presets)
|
|
32
|
+
? presets.find(preset => preset?.id === presetName)
|
|
33
|
+
: Object.prototype.hasOwnProperty.call(presets, presetName)
|
|
34
|
+
? presets[presetName]
|
|
35
|
+
: undefined;
|
|
36
|
+
if (byName) {
|
|
37
|
+
return byName;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (Number.isInteger(presetIndex) && presetIndex >= 0) {
|
|
42
|
+
return entries[presetIndex];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|