@cornerstonejs/tools 1.35.3 → 1.36.0
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/cjs/eventListeners/segmentation/imageChangeEventListener.js +3 -0
- package/dist/cjs/eventListeners/segmentation/imageChangeEventListener.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.d.ts +5 -4
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +6 -10
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/addSegmentationRepresentation.d.ts +3 -0
- package/dist/cjs/stateManagement/segmentation/addSegmentationRepresentation.js +87 -0
- package/dist/cjs/stateManagement/segmentation/addSegmentationRepresentation.js.map +1 -0
- package/dist/cjs/stateManagement/segmentation/addSegmentationRepresentations.js +2 -29
- package/dist/cjs/stateManagement/segmentation/addSegmentationRepresentations.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/config/segmentationColor.d.ts +4 -5
- package/dist/cjs/stateManagement/segmentation/config/segmentationColor.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.d.ts +2 -0
- package/dist/cjs/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.js +19 -0
- package/dist/cjs/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.js.map +1 -0
- package/dist/cjs/stateManagement/segmentation/segmentationState.d.ts +6 -4
- package/dist/cjs/stateManagement/segmentation/segmentationState.js +6 -1
- package/dist/cjs/stateManagement/segmentation/segmentationState.js.map +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.d.ts +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js +2 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/cjs/tools/annotation/SplineROITool.js +9 -34
- package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.d.ts +1 -3
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +0 -33
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.d.ts +9 -3
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +13 -37
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.d.ts +1 -3
- package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js +0 -32
- package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
- package/dist/cjs/types/SegmentationStateTypes.d.ts +5 -3
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +3 -0
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +6 -10
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.js +49 -0
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.js.map +1 -0
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.js +2 -24
- package/dist/esm/stateManagement/segmentation/addSegmentationRepresentations.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.js +12 -0
- package/dist/esm/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.js.map +1 -0
- package/dist/esm/stateManagement/segmentation/segmentationState.js +5 -1
- package/dist/esm/stateManagement/segmentation/segmentationState.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +2 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/esm/tools/annotation/SplineROITool.js +2 -4
- package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +1 -34
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +6 -33
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +1 -33
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
- package/dist/types/eventListeners/segmentation/imageChangeEventListener.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts +5 -4
- package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/addSegmentationRepresentation.d.ts +4 -0
- package/dist/types/stateManagement/segmentation/addSegmentationRepresentation.d.ts.map +1 -0
- package/dist/types/stateManagement/segmentation/addSegmentationRepresentations.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/config/segmentationColor.d.ts +4 -5
- package/dist/types/stateManagement/segmentation/config/segmentationColor.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.d.ts +3 -0
- package/dist/types/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.d.ts.map +1 -0
- package/dist/types/stateManagement/segmentation/segmentationState.d.ts +6 -4
- package/dist/types/stateManagement/segmentation/segmentationState.d.ts.map +1 -1
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts +1 -1
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts.map +1 -1
- package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts +1 -3
- package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Labelmap/labelmapDisplay.d.ts +9 -3
- package/dist/types/tools/displayTools/Labelmap/labelmapDisplay.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts +1 -3
- package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts.map +1 -1
- package/dist/types/types/SegmentationStateTypes.d.ts +5 -3
- package/dist/types/types/SegmentationStateTypes.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/eventListeners/segmentation/imageChangeEventListener.ts +5 -0
- package/src/stateManagement/segmentation/SegmentationStateManager.ts +10 -17
- package/src/stateManagement/segmentation/addSegmentationRepresentation.ts +86 -0
- package/src/stateManagement/segmentation/addSegmentationRepresentations.ts +2 -43
- package/src/stateManagement/segmentation/config/segmentationColor.ts +4 -6
- package/src/stateManagement/segmentation/helpers/getRepresentationSpecificConfig.ts +15 -0
- package/src/stateManagement/segmentation/segmentationState.ts +9 -3
- package/src/store/ToolGroupManager/ToolGroup.ts +4 -6
- package/src/tools/annotation/SplineROITool.ts +3 -3
- package/src/tools/displayTools/Contour/contourDisplay.ts +0 -61
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +11 -66
- package/src/tools/displayTools/Surface/surfaceDisplay.ts +0 -60
- package/src/types/SegmentationStateTypes.ts +7 -12
- package/src/types/index.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cornerstonejs/core": "^1.
|
|
32
|
+
"@cornerstonejs/core": "^1.36.0",
|
|
33
33
|
"comlink": "^4.4.1",
|
|
34
34
|
"lodash.clonedeep": "4.5.0",
|
|
35
35
|
"lodash.get": "^4.4.2"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"type": "individual",
|
|
54
54
|
"url": "https://ohif.org/donate"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "616ef6915f122cab6d1e27e2d02ebc95484a4e37"
|
|
57
57
|
}
|
|
@@ -71,6 +71,11 @@ function _imageChangeEventListener(evt) {
|
|
|
71
71
|
) as { viewport: Types.IStackViewport };
|
|
72
72
|
|
|
73
73
|
const toolGroup = getToolGroupForViewport(viewportId, renderingEngineId);
|
|
74
|
+
|
|
75
|
+
if (!toolGroup) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
let toolGroupSegmentationRepresentations =
|
|
75
80
|
SegmentationState.getSegmentationRepresentations(toolGroup.id) || [];
|
|
76
81
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { utilities as csUtils } from '@cornerstonejs/core';
|
|
2
1
|
import cloneDeep from 'lodash.clonedeep';
|
|
3
|
-
|
|
4
|
-
import
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
import { utilities as csUtils } from '@cornerstonejs/core';
|
|
5
4
|
|
|
6
5
|
import { SegmentationRepresentations } from '../../enums';
|
|
7
6
|
import getDefaultContourConfig from '../../tools/displayTools/Contour/contourConfig';
|
|
8
7
|
import getDefaultLabelmapConfig from '../../tools/displayTools/Labelmap/labelmapConfig';
|
|
9
8
|
import type {
|
|
10
|
-
ColorLUT,
|
|
11
9
|
RepresentationConfig,
|
|
12
10
|
Segmentation,
|
|
13
11
|
SegmentationRepresentationConfig,
|
|
@@ -77,10 +75,14 @@ export default class SegmentationStateManager {
|
|
|
77
75
|
* @param lutIndex - The index of the color LUT to retrieve.
|
|
78
76
|
* @returns A ColorLUT object.
|
|
79
77
|
*/
|
|
80
|
-
getColorLUT(lutIndex: number): ColorLUT | undefined {
|
|
78
|
+
getColorLUT(lutIndex: number): Types.ColorLUT | undefined {
|
|
81
79
|
return this.state.colorLUT[lutIndex];
|
|
82
80
|
}
|
|
83
81
|
|
|
82
|
+
getNextColorLUTIndex(): number {
|
|
83
|
+
return this.state.colorLUT.length;
|
|
84
|
+
}
|
|
85
|
+
|
|
84
86
|
/**
|
|
85
87
|
* Reset the state to the default state
|
|
86
88
|
*/
|
|
@@ -104,8 +106,6 @@ export default class SegmentationStateManager {
|
|
|
104
106
|
* @param segmentation - Segmentation
|
|
105
107
|
*/
|
|
106
108
|
addSegmentation(segmentation: Segmentation): void {
|
|
107
|
-
this._initDefaultColorLUTIfNecessary();
|
|
108
|
-
|
|
109
109
|
// Check if the segmentation already exists with the segmentationId
|
|
110
110
|
if (this.getSegmentation(segmentation.segmentationId)) {
|
|
111
111
|
throw new Error(
|
|
@@ -433,12 +433,12 @@ export default class SegmentationStateManager {
|
|
|
433
433
|
* @param colorLUT - ColorLUT
|
|
434
434
|
* @param lutIndex - The index of the color LUT table to add.
|
|
435
435
|
*/
|
|
436
|
-
addColorLUT(colorLUT: ColorLUT, lutIndex: number): void {
|
|
436
|
+
addColorLUT(colorLUT: Types.ColorLUT, lutIndex: number): void {
|
|
437
437
|
if (this.state.colorLUT[lutIndex]) {
|
|
438
|
-
console.
|
|
438
|
+
console.warn('Color LUT table already exists, overwriting');
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
this.state.colorLUT[lutIndex] = colorLUT;
|
|
441
|
+
this.state.colorLUT[lutIndex] = structuredClone(colorLUT);
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
/**
|
|
@@ -500,13 +500,6 @@ export default class SegmentationStateManager {
|
|
|
500
500
|
|
|
501
501
|
// 5. if added/removed segmentation is is inactive, do nothing
|
|
502
502
|
}
|
|
503
|
-
|
|
504
|
-
_initDefaultColorLUTIfNecessary() {
|
|
505
|
-
// if colorLUTTable is not specified or the default one is not found
|
|
506
|
-
if (this.state.colorLUT.length === 0 || !this.state.colorLUT[0]) {
|
|
507
|
-
this.addColorLUT(CORNERSTONE_COLOR_LUT as ColorLUT, 0);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
503
|
}
|
|
511
504
|
|
|
512
505
|
const defaultSegmentationStateManager = new SegmentationStateManager('DEFAULT');
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { utilities } from '@cornerstonejs/core';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
import {
|
|
4
|
+
SegmentationRepresentationConfig,
|
|
5
|
+
RepresentationPublicInput,
|
|
6
|
+
ToolGroupSpecificRepresentation,
|
|
7
|
+
} from '../../types/SegmentationStateTypes';
|
|
8
|
+
import Representations from '../../enums/SegmentationRepresentations';
|
|
9
|
+
import * as SegmentationConfig from './config/segmentationConfig';
|
|
10
|
+
import {
|
|
11
|
+
addSegmentationRepresentation as addSegmentationRepresentationToState,
|
|
12
|
+
getNextColorLUTIndex,
|
|
13
|
+
addColorLUT,
|
|
14
|
+
} from './segmentationState';
|
|
15
|
+
import { getRepresentationSpecificConfig } from './helpers/getRepresentationSpecificConfig';
|
|
16
|
+
import CORNERSTONE_COLOR_LUT from '../../constants/COLOR_LUT';
|
|
17
|
+
|
|
18
|
+
async function addSegmentationRepresentation(
|
|
19
|
+
toolGroupId: string,
|
|
20
|
+
representationInput: RepresentationPublicInput,
|
|
21
|
+
toolGroupSpecificConfig?: SegmentationRepresentationConfig
|
|
22
|
+
): Promise<string> {
|
|
23
|
+
const { segmentationId, options = {} } = representationInput;
|
|
24
|
+
const segmentationRepresentationUID = utilities.uuidv4();
|
|
25
|
+
|
|
26
|
+
// Todo: make segmentsHidden also an option that can get passed by
|
|
27
|
+
// the user
|
|
28
|
+
const segmentsHidden = new Set() as Set<number>;
|
|
29
|
+
|
|
30
|
+
const colorLUTOrIndexInput = options.colorLUTOrIndex;
|
|
31
|
+
let colorLUTIndexToUse;
|
|
32
|
+
|
|
33
|
+
if (typeof colorLUTOrIndexInput === 'number') {
|
|
34
|
+
colorLUTIndexToUse = colorLUTOrIndexInput;
|
|
35
|
+
} else {
|
|
36
|
+
const nextIndex = getNextColorLUTIndex();
|
|
37
|
+
const colorLUTToAdd = Array.isArray(colorLUTOrIndexInput)
|
|
38
|
+
? colorLUTOrIndexInput
|
|
39
|
+
: CORNERSTONE_COLOR_LUT;
|
|
40
|
+
addColorLUT(colorLUTToAdd as Types.ColorLUT, nextIndex);
|
|
41
|
+
colorLUTIndexToUse = nextIndex;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const toolGroupSpecificRepresentation: ToolGroupSpecificRepresentation = {
|
|
45
|
+
segmentationId,
|
|
46
|
+
segmentationRepresentationUID,
|
|
47
|
+
type: Representations.Labelmap,
|
|
48
|
+
segmentsHidden,
|
|
49
|
+
colorLUTIndex: colorLUTIndexToUse,
|
|
50
|
+
active: true,
|
|
51
|
+
segmentationRepresentationSpecificConfig: {},
|
|
52
|
+
segmentSpecificConfig: {},
|
|
53
|
+
config: getRepresentationSpecificConfig(representationInput),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Update the toolGroup specific configuration
|
|
57
|
+
if (toolGroupSpecificConfig) {
|
|
58
|
+
// Since setting configuration on toolGroup will trigger a segmentationRepresentation
|
|
59
|
+
// update event, we don't want to trigger the event twice, so we suppress
|
|
60
|
+
// the first one
|
|
61
|
+
const currentToolGroupConfig =
|
|
62
|
+
SegmentationConfig.getToolGroupSpecificConfig(toolGroupId);
|
|
63
|
+
|
|
64
|
+
const mergedConfig = utilities.deepMerge(
|
|
65
|
+
currentToolGroupConfig,
|
|
66
|
+
toolGroupSpecificConfig
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
SegmentationConfig.setToolGroupSpecificConfig(toolGroupId, {
|
|
70
|
+
renderInactiveSegmentations:
|
|
71
|
+
mergedConfig.renderInactiveSegmentations || true,
|
|
72
|
+
representations: {
|
|
73
|
+
...mergedConfig.representations,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
addSegmentationRepresentationToState(
|
|
79
|
+
toolGroupId,
|
|
80
|
+
toolGroupSpecificRepresentation
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return segmentationRepresentationUID;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { addSegmentationRepresentation };
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import _cloneDeep from 'lodash.clonedeep';
|
|
2
1
|
import {
|
|
3
2
|
SegmentationRepresentationConfig,
|
|
4
3
|
RepresentationPublicInput,
|
|
5
4
|
} from '../../types/SegmentationStateTypes';
|
|
6
|
-
import Representations from '../../enums/SegmentationRepresentations';
|
|
7
5
|
import { getToolGroup } from '../../store/ToolGroupManager';
|
|
8
6
|
|
|
9
|
-
import {
|
|
10
|
-
import { contourDisplay } from '../../tools/displayTools/Contour';
|
|
11
|
-
import { surfaceDisplay } from '../../tools/displayTools/Surface';
|
|
7
|
+
import { addSegmentationRepresentation } from './addSegmentationRepresentation';
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
10
|
* Set the specified segmentation representations on the viewports of the specified
|
|
@@ -33,7 +29,7 @@ async function addSegmentationRepresentations(
|
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
const promises = representationInputArray.map((representationInput) => {
|
|
36
|
-
return
|
|
32
|
+
return addSegmentationRepresentation(
|
|
37
33
|
toolGroupId,
|
|
38
34
|
representationInput,
|
|
39
35
|
toolGroupSpecificRepresentationConfig
|
|
@@ -45,41 +41,4 @@ async function addSegmentationRepresentations(
|
|
|
45
41
|
return segmentationRepresentationUIDs;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
|
-
async function _addSegmentationRepresentation(
|
|
49
|
-
toolGroupId: string,
|
|
50
|
-
representationInput: RepresentationPublicInput,
|
|
51
|
-
toolGroupSpecificRepresentationConfig?: SegmentationRepresentationConfig
|
|
52
|
-
): Promise<string> {
|
|
53
|
-
let segmentationRepresentationUID;
|
|
54
|
-
|
|
55
|
-
if (representationInput.type === Representations.Labelmap) {
|
|
56
|
-
segmentationRepresentationUID =
|
|
57
|
-
await labelmapDisplay.addSegmentationRepresentation(
|
|
58
|
-
toolGroupId,
|
|
59
|
-
representationInput,
|
|
60
|
-
toolGroupSpecificRepresentationConfig
|
|
61
|
-
);
|
|
62
|
-
} else if (representationInput.type === Representations.Contour) {
|
|
63
|
-
segmentationRepresentationUID =
|
|
64
|
-
await contourDisplay.addSegmentationRepresentation(
|
|
65
|
-
toolGroupId,
|
|
66
|
-
representationInput,
|
|
67
|
-
toolGroupSpecificRepresentationConfig
|
|
68
|
-
);
|
|
69
|
-
} else if (representationInput.type === Representations.Surface) {
|
|
70
|
-
segmentationRepresentationUID =
|
|
71
|
-
await surfaceDisplay.addSegmentationRepresentation(
|
|
72
|
-
toolGroupId,
|
|
73
|
-
representationInput,
|
|
74
|
-
toolGroupSpecificRepresentationConfig
|
|
75
|
-
);
|
|
76
|
-
} else {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`The representation type ${representationInput.type} is not supported`
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return segmentationRepresentationUID;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
44
|
export default addSegmentationRepresentations;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { utilities } from '@cornerstonejs/core';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
3
|
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
3
|
-
import { Color } from '../../../types/SegmentationStateTypes';
|
|
4
|
-
import { ColorLUT } from '../../../types/SegmentationStateTypes';
|
|
5
4
|
import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents';
|
|
6
|
-
import { SegmentationRepresentations } from '../../../enums';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* addColorLUT - Adds a new color LUT to the state at the given colorLUTIndex.
|
|
@@ -13,7 +11,7 @@ import { SegmentationRepresentations } from '../../../enums';
|
|
|
13
11
|
* @param colorLUT - An array of The colorLUT to set.
|
|
14
12
|
* @returns
|
|
15
13
|
*/
|
|
16
|
-
function addColorLUT(colorLUT: ColorLUT, colorLUTIndex: number): void {
|
|
14
|
+
function addColorLUT(colorLUT: Types.ColorLUT, colorLUTIndex: number): void {
|
|
17
15
|
if (!colorLUT) {
|
|
18
16
|
throw new Error('addColorLUT: colorLUT is required');
|
|
19
17
|
}
|
|
@@ -81,7 +79,7 @@ function getColorForSegmentIndex(
|
|
|
81
79
|
toolGroupId: string,
|
|
82
80
|
segmentationRepresentationUID: string,
|
|
83
81
|
segmentIndex: number
|
|
84
|
-
): Color {
|
|
82
|
+
): Types.Color {
|
|
85
83
|
const segmentationRepresentation =
|
|
86
84
|
SegmentationState.getSegmentationRepresentationByUID(
|
|
87
85
|
toolGroupId,
|
|
@@ -105,7 +103,7 @@ function setColorForSegmentIndex(
|
|
|
105
103
|
toolGroupId: string,
|
|
106
104
|
segmentationRepresentationUID: string,
|
|
107
105
|
segmentIndex: number,
|
|
108
|
-
color: Color
|
|
106
|
+
color: Types.Color
|
|
109
107
|
): void {
|
|
110
108
|
// Get the reference to the color in the colorLUT.
|
|
111
109
|
const colorReference = getColorForSegmentIndex(
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
|
|
2
|
+
import { RepresentationPublicInput } from '../../../types';
|
|
3
|
+
import { getRepresentationRenderingConfig as getLabelmapRenderingConfig } from '../../../tools/displayTools/Labelmap/labelmapDisplay';
|
|
4
|
+
|
|
5
|
+
export function getRepresentationSpecificConfig(
|
|
6
|
+
representationInput: RepresentationPublicInput
|
|
7
|
+
) {
|
|
8
|
+
const { type } = representationInput;
|
|
9
|
+
|
|
10
|
+
if (type === SegmentationRepresentations.Labelmap) {
|
|
11
|
+
return getLabelmapRenderingConfig();
|
|
12
|
+
} else {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
1
2
|
import type {
|
|
2
|
-
ColorLUT,
|
|
3
3
|
RepresentationConfig,
|
|
4
4
|
Segmentation,
|
|
5
5
|
SegmentationPublicInput,
|
|
@@ -383,17 +383,22 @@ function removeColorLUT(colorLUTIndex: number): void {
|
|
|
383
383
|
* @param index - The index of the color lut to retrieve.
|
|
384
384
|
* @returns A ColorLUT array.
|
|
385
385
|
*/
|
|
386
|
-
function getColorLUT(index: number): ColorLUT | undefined {
|
|
386
|
+
function getColorLUT(index: number): Types.ColorLUT | undefined {
|
|
387
387
|
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
388
388
|
return segmentationStateManager.getColorLUT(index);
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
+
function getNextColorLUTIndex(): number {
|
|
392
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
393
|
+
return segmentationStateManager.getNextColorLUTIndex();
|
|
394
|
+
}
|
|
395
|
+
|
|
391
396
|
/**
|
|
392
397
|
* Add a color LUT to the segmentation state manager
|
|
393
398
|
* @param colorLUT - The color LUT array to add.
|
|
394
399
|
* @param index - The index of the color LUT to add.
|
|
395
400
|
*/
|
|
396
|
-
function addColorLUT(colorLUT: ColorLUT, index: number): void {
|
|
401
|
+
function addColorLUT(colorLUT: Types.ColorLUT, index: number): void {
|
|
397
402
|
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
398
403
|
segmentationStateManager.addColorLUT(colorLUT, index);
|
|
399
404
|
// Todo: trigger event color LUT added
|
|
@@ -426,5 +431,6 @@ export {
|
|
|
426
431
|
// color
|
|
427
432
|
addColorLUT,
|
|
428
433
|
getColorLUT,
|
|
434
|
+
getNextColorLUTIndex,
|
|
429
435
|
removeColorLUT,
|
|
430
436
|
};
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
getRenderingEngines,
|
|
9
9
|
getEnabledElementByIds,
|
|
10
10
|
Settings,
|
|
11
|
-
utilities as csUtils,
|
|
12
11
|
} from '@cornerstonejs/core';
|
|
13
12
|
import type { Types } from '@cornerstonejs/core';
|
|
14
13
|
import { Events } from '../../enums';
|
|
@@ -675,7 +674,7 @@ export default class ToolGroup implements IToolGroup {
|
|
|
675
674
|
* getToolConfiguration('LengthTool', 'firstLevel.secondLevel')
|
|
676
675
|
* // get from LengthTool instance the configuration value as being LengthToolInstance[configuration][firstLevel][secondLevel]
|
|
677
676
|
*/
|
|
678
|
-
getToolConfiguration(toolName: string, configurationPath
|
|
677
|
+
getToolConfiguration(toolName: string, configurationPath?: string): any {
|
|
679
678
|
if (this._toolInstances[toolName] === undefined) {
|
|
680
679
|
console.warn(
|
|
681
680
|
`Tool ${toolName} not present, can't set tool configuration.`
|
|
@@ -683,10 +682,9 @@ export default class ToolGroup implements IToolGroup {
|
|
|
683
682
|
return;
|
|
684
683
|
}
|
|
685
684
|
|
|
686
|
-
const _configuration =
|
|
687
|
-
this._toolInstances[toolName].configuration,
|
|
688
|
-
|
|
689
|
-
);
|
|
685
|
+
const _configuration =
|
|
686
|
+
get(this._toolInstances[toolName].configuration, configurationPath) ||
|
|
687
|
+
this._toolInstances[toolName].configuration;
|
|
690
688
|
|
|
691
689
|
return cloneDeep(_configuration);
|
|
692
690
|
}
|
|
@@ -38,6 +38,9 @@ import {
|
|
|
38
38
|
getCalibratedScale,
|
|
39
39
|
getCalibratedAreaUnits,
|
|
40
40
|
} from '../../utilities';
|
|
41
|
+
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
42
|
+
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
43
|
+
|
|
41
44
|
import { SplineROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
|
|
42
45
|
import {
|
|
43
46
|
AnnotationCompletedEventDetail,
|
|
@@ -52,9 +55,6 @@ import { BSpline } from './splines/BSpline';
|
|
|
52
55
|
import * as viewportFilters from '../../utilities/viewportFilters';
|
|
53
56
|
import * as drawing from '../../utilities/drawing';
|
|
54
57
|
|
|
55
|
-
const { getViewportIdsWithToolToRender } = viewportFilters;
|
|
56
|
-
const { getTextBoxCoordsCanvas } = drawing;
|
|
57
|
-
|
|
58
58
|
const SPLINE_MIN_POINTS = 3;
|
|
59
59
|
const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
|
|
60
60
|
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getEnabledElementByIds,
|
|
3
3
|
Types,
|
|
4
|
-
utilities as csUtils,
|
|
5
4
|
StackViewport,
|
|
6
5
|
} from '@cornerstonejs/core';
|
|
7
6
|
|
|
8
7
|
import Representations from '../../../enums/SegmentationRepresentations';
|
|
9
|
-
import * as SegmentationConfig from '../../../stateManagement/segmentation/config/segmentationConfig';
|
|
10
8
|
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
11
9
|
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
12
10
|
import {
|
|
13
|
-
RepresentationPublicInput,
|
|
14
11
|
SegmentationRepresentationConfig,
|
|
15
12
|
ToolGroupSpecificRepresentation,
|
|
16
13
|
} from '../../../types/SegmentationStateTypes';
|
|
@@ -18,63 +15,6 @@ import { addOrUpdateContourSets } from './addOrUpdateContourSets';
|
|
|
18
15
|
import removeContourFromElement from './removeContourFromElement';
|
|
19
16
|
import { deleteConfigCache } from './contourConfigCache';
|
|
20
17
|
|
|
21
|
-
/**
|
|
22
|
-
* It adds a new segmentation representation to the segmentation state
|
|
23
|
-
* @param toolGroupId - The id of the toolGroup that the segmentation
|
|
24
|
-
* belongs to
|
|
25
|
-
* @param representationInput - RepresentationPublicInput
|
|
26
|
-
* @param toolGroupSpecificConfig - The configuration that is specific to the toolGroup.
|
|
27
|
-
* @returns The segmentationRepresentationUID
|
|
28
|
-
*/
|
|
29
|
-
async function addSegmentationRepresentation(
|
|
30
|
-
toolGroupId: string,
|
|
31
|
-
representationInput: RepresentationPublicInput,
|
|
32
|
-
toolGroupSpecificConfig?: SegmentationRepresentationConfig
|
|
33
|
-
): Promise<string> {
|
|
34
|
-
const { segmentationId } = representationInput;
|
|
35
|
-
const segmentationRepresentationUID = csUtils.uuidv4();
|
|
36
|
-
// Todo: make these configurable during representation input by user
|
|
37
|
-
const segmentsHidden = new Set() as Set<number>;
|
|
38
|
-
const visibility = true;
|
|
39
|
-
const colorLUTIndex = 0;
|
|
40
|
-
const active = true;
|
|
41
|
-
const toolGroupSpecificRepresentation: ToolGroupSpecificRepresentation = {
|
|
42
|
-
segmentationId,
|
|
43
|
-
segmentationRepresentationUID,
|
|
44
|
-
type: Representations.Contour,
|
|
45
|
-
segmentsHidden,
|
|
46
|
-
colorLUTIndex,
|
|
47
|
-
active,
|
|
48
|
-
segmentationRepresentationSpecificConfig: {},
|
|
49
|
-
segmentSpecificConfig: {},
|
|
50
|
-
config: {},
|
|
51
|
-
};
|
|
52
|
-
// Update the toolGroup specific configuration
|
|
53
|
-
if (toolGroupSpecificConfig) {
|
|
54
|
-
// Since setting configuration on toolGroup will trigger a segmentationRepresentation
|
|
55
|
-
// update event, we don't want to trigger the event twice, so we suppress
|
|
56
|
-
// the first one
|
|
57
|
-
const currentToolGroupConfig =
|
|
58
|
-
SegmentationConfig.getToolGroupSpecificConfig(toolGroupId);
|
|
59
|
-
const mergedConfig = csUtils.deepMerge(
|
|
60
|
-
currentToolGroupConfig,
|
|
61
|
-
toolGroupSpecificConfig
|
|
62
|
-
);
|
|
63
|
-
SegmentationConfig.setToolGroupSpecificConfig(toolGroupId, {
|
|
64
|
-
renderInactiveSegmentations:
|
|
65
|
-
mergedConfig.renderInactiveSegmentations || true,
|
|
66
|
-
representations: {
|
|
67
|
-
...mergedConfig.representations,
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
SegmentationState.addSegmentationRepresentation(
|
|
72
|
-
toolGroupId,
|
|
73
|
-
toolGroupSpecificRepresentation
|
|
74
|
-
);
|
|
75
|
-
return segmentationRepresentationUID;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
18
|
/**
|
|
79
19
|
* It removes a segmentation representation from the tool group's viewports and
|
|
80
20
|
* from the segmentation state
|
|
@@ -177,6 +117,5 @@ function _removeContourFromToolGroupViewports(
|
|
|
177
117
|
|
|
178
118
|
export default {
|
|
179
119
|
render,
|
|
180
|
-
addSegmentationRepresentation,
|
|
181
120
|
removeSegmentationRepresentation,
|
|
182
121
|
};
|
|
@@ -31,75 +31,14 @@ import { isVolumeSegmentation } from '../../segmentation/strategies/utils/stackV
|
|
|
31
31
|
const MAX_NUMBER_COLORS = 255;
|
|
32
32
|
const labelMapConfigCache = new Map();
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
* For each viewport, in the toolGroup it adds the segmentation labelmap
|
|
36
|
-
* representation to its viewports.
|
|
37
|
-
* @param toolGroup - the tool group that contains the viewports
|
|
38
|
-
* @param representationInput - The segmentation representation input
|
|
39
|
-
* @param toolGroupSpecificConfig - The configuration object for toolGroup
|
|
40
|
-
*
|
|
41
|
-
* @returns The UID of the new segmentation representation
|
|
42
|
-
*/
|
|
43
|
-
async function addSegmentationRepresentation(
|
|
44
|
-
toolGroupId: string,
|
|
45
|
-
representationInput: RepresentationPublicInput,
|
|
46
|
-
toolGroupSpecificConfig?: SegmentationRepresentationConfig
|
|
47
|
-
): Promise<string> {
|
|
48
|
-
const { segmentationId } = representationInput;
|
|
49
|
-
const segmentationRepresentationUID = utilities.uuidv4();
|
|
50
|
-
|
|
51
|
-
// Todo: make these configurable during representation input by user
|
|
52
|
-
const segmentsHidden = new Set() as Set<number>;
|
|
53
|
-
const colorLUTIndex = 0;
|
|
54
|
-
const active = true;
|
|
34
|
+
function getRepresentationRenderingConfig() {
|
|
55
35
|
const cfun = vtkColorTransferFunction.newInstance();
|
|
56
36
|
const ofun = vtkPiecewiseFunction.newInstance();
|
|
57
|
-
|
|
58
37
|
ofun.addPoint(0, 0);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
segmentationRepresentationUID,
|
|
63
|
-
type: Representations.Labelmap,
|
|
64
|
-
segmentsHidden,
|
|
65
|
-
colorLUTIndex,
|
|
66
|
-
active,
|
|
67
|
-
segmentationRepresentationSpecificConfig: {},
|
|
68
|
-
segmentSpecificConfig: {},
|
|
69
|
-
config: {
|
|
70
|
-
cfun,
|
|
71
|
-
ofun,
|
|
72
|
-
},
|
|
38
|
+
return {
|
|
39
|
+
ofun,
|
|
40
|
+
cfun,
|
|
73
41
|
};
|
|
74
|
-
|
|
75
|
-
// Update the toolGroup specific configuration
|
|
76
|
-
if (toolGroupSpecificConfig) {
|
|
77
|
-
// Since setting configuration on toolGroup will trigger a segmentationRepresentation
|
|
78
|
-
// update event, we don't want to trigger the event twice, so we suppress
|
|
79
|
-
// the first one
|
|
80
|
-
const currentToolGroupConfig =
|
|
81
|
-
SegmentationConfig.getToolGroupSpecificConfig(toolGroupId);
|
|
82
|
-
|
|
83
|
-
const mergedConfig = utilities.deepMerge(
|
|
84
|
-
currentToolGroupConfig,
|
|
85
|
-
toolGroupSpecificConfig
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
SegmentationConfig.setToolGroupSpecificConfig(toolGroupId, {
|
|
89
|
-
renderInactiveSegmentations:
|
|
90
|
-
mergedConfig.renderInactiveSegmentations || true,
|
|
91
|
-
representations: {
|
|
92
|
-
...mergedConfig.representations,
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
SegmentationState.addSegmentationRepresentation(
|
|
98
|
-
toolGroupId,
|
|
99
|
-
toolGroupSpecificRepresentation
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
return segmentationRepresentationUID;
|
|
103
42
|
}
|
|
104
43
|
|
|
105
44
|
/**
|
|
@@ -532,7 +471,13 @@ async function _addLabelmapToViewport(
|
|
|
532
471
|
}
|
|
533
472
|
|
|
534
473
|
export default {
|
|
474
|
+
getRepresentationRenderingConfig,
|
|
475
|
+
render,
|
|
476
|
+
removeSegmentationRepresentation,
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
export {
|
|
480
|
+
getRepresentationRenderingConfig,
|
|
535
481
|
render,
|
|
536
|
-
addSegmentationRepresentation,
|
|
537
482
|
removeSegmentationRepresentation,
|
|
538
483
|
};
|
|
@@ -2,16 +2,13 @@ import {
|
|
|
2
2
|
cache,
|
|
3
3
|
getEnabledElementByIds,
|
|
4
4
|
Types,
|
|
5
|
-
utilities,
|
|
6
5
|
Enums,
|
|
7
6
|
} from '@cornerstonejs/core';
|
|
8
7
|
|
|
9
8
|
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
10
|
-
import * as SegmentationConfig from '../../../stateManagement/segmentation/config/segmentationConfig';
|
|
11
9
|
import Representations from '../../../enums/SegmentationRepresentations';
|
|
12
10
|
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
13
11
|
import {
|
|
14
|
-
RepresentationPublicInput,
|
|
15
12
|
SegmentationRepresentationConfig,
|
|
16
13
|
ToolGroupSpecificRepresentation,
|
|
17
14
|
} from '../../../types/SegmentationStateTypes';
|
|
@@ -19,62 +16,6 @@ import {
|
|
|
19
16
|
import removeSurfaceFromElement from './removeSurfaceFromElement';
|
|
20
17
|
import addSurfaceToElement from './addSurfaceToElement';
|
|
21
18
|
|
|
22
|
-
/**
|
|
23
|
-
* It adds a new segmentation representation to the segmentation state
|
|
24
|
-
* @param toolGroupId - The id of the toolGroup that the segmentation
|
|
25
|
-
* belongs to
|
|
26
|
-
* @param representationInput - RepresentationPublicInput
|
|
27
|
-
* @param toolGroupSpecificConfig - The configuration that is specific to the toolGroup.
|
|
28
|
-
* @returns The segmentationRepresentationUID
|
|
29
|
-
*/
|
|
30
|
-
async function addSegmentationRepresentation(
|
|
31
|
-
toolGroupId: string,
|
|
32
|
-
representationInput: RepresentationPublicInput,
|
|
33
|
-
toolGroupSpecificConfig?: SegmentationRepresentationConfig
|
|
34
|
-
): Promise<string> {
|
|
35
|
-
const { segmentationId } = representationInput;
|
|
36
|
-
const segmentationRepresentationUID = utilities.uuidv4();
|
|
37
|
-
// Todo: make these configurable during representation input by user
|
|
38
|
-
const segmentsHidden = new Set() as Set<number>;
|
|
39
|
-
const colorLUTIndex = 0;
|
|
40
|
-
const active = true;
|
|
41
|
-
const toolGroupSpecificRepresentation: ToolGroupSpecificRepresentation = {
|
|
42
|
-
segmentationId,
|
|
43
|
-
segmentationRepresentationUID,
|
|
44
|
-
type: Representations.Surface,
|
|
45
|
-
segmentsHidden,
|
|
46
|
-
colorLUTIndex,
|
|
47
|
-
active,
|
|
48
|
-
segmentationRepresentationSpecificConfig: {},
|
|
49
|
-
segmentSpecificConfig: {},
|
|
50
|
-
config: {},
|
|
51
|
-
};
|
|
52
|
-
// Update the toolGroup specific configuration
|
|
53
|
-
if (toolGroupSpecificConfig) {
|
|
54
|
-
// Since setting configuration on toolGroup will trigger a segmentationRepresentation
|
|
55
|
-
// update event, we don't want to trigger the event twice, so we suppress
|
|
56
|
-
// the first one
|
|
57
|
-
const currentToolGroupConfig =
|
|
58
|
-
SegmentationConfig.getToolGroupSpecificConfig(toolGroupId);
|
|
59
|
-
const mergedConfig = utilities.deepMerge(
|
|
60
|
-
currentToolGroupConfig,
|
|
61
|
-
toolGroupSpecificConfig
|
|
62
|
-
);
|
|
63
|
-
SegmentationConfig.setToolGroupSpecificConfig(toolGroupId, {
|
|
64
|
-
renderInactiveSegmentations:
|
|
65
|
-
mergedConfig.renderInactiveSegmentations || true,
|
|
66
|
-
representations: {
|
|
67
|
-
...mergedConfig.representations,
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
SegmentationState.addSegmentationRepresentation(
|
|
72
|
-
toolGroupId,
|
|
73
|
-
toolGroupSpecificRepresentation
|
|
74
|
-
);
|
|
75
|
-
return segmentationRepresentationUID;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
19
|
/**
|
|
79
20
|
* It removes a segmentation representation from the tool group's viewports and
|
|
80
21
|
* from the segmentation state
|
|
@@ -210,6 +151,5 @@ function _removeSurfaceFromToolGroupViewports(
|
|
|
210
151
|
|
|
211
152
|
export default {
|
|
212
153
|
render,
|
|
213
|
-
addSegmentationRepresentation,
|
|
214
154
|
removeSegmentationRepresentation,
|
|
215
155
|
};
|