@cornerstonejs/tools 2.1.6 → 2.1.8
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/esm/enums/Events.d.ts +1 -0
- package/dist/esm/enums/Events.js +1 -0
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +2 -1
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +2 -2
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationAdded.d.ts +1 -0
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationAdded.js +8 -0
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +1 -0
- package/dist/esm/types/EventTypes.d.ts +5 -1
- package/dist/esm/utilities/cine/playClip.js +5 -10
- package/dist/esm/utilities/dynamicVolume/getDataInTime.js +19 -25
- package/dist/esm/utilities/segmentation/utilities.js +26 -14
- package/dist/esm/utilities/voi/colorbar/ViewportColorbar.js +19 -14
- package/package.json +3 -3
|
@@ -16,6 +16,7 @@ declare enum Events {
|
|
|
16
16
|
SEGMENTATION_MODIFIED = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",
|
|
17
17
|
SEGMENTATION_RENDERED = "CORNERSTONE_TOOLS_SEGMENTATION_RENDERED",
|
|
18
18
|
SEGMENTATION_REPRESENTATION_ADDED = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED",
|
|
19
|
+
SEGMENTATION_ADDED = "CORNERSTONE_TOOLS_SEGMENTATION_ADDED",
|
|
19
20
|
SEGMENTATION_REPRESENTATION_MODIFIED = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED",
|
|
20
21
|
SEGMENTATION_REMOVED = "CORNERSTONE_TOOLS_SEGMENTATION_REMOVED",
|
|
21
22
|
SEGMENTATION_REPRESENTATION_REMOVED = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED",
|
package/dist/esm/enums/Events.js
CHANGED
|
@@ -17,6 +17,7 @@ var Events;
|
|
|
17
17
|
Events["SEGMENTATION_MODIFIED"] = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED";
|
|
18
18
|
Events["SEGMENTATION_RENDERED"] = "CORNERSTONE_TOOLS_SEGMENTATION_RENDERED";
|
|
19
19
|
Events["SEGMENTATION_REPRESENTATION_ADDED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED";
|
|
20
|
+
Events["SEGMENTATION_ADDED"] = "CORNERSTONE_TOOLS_SEGMENTATION_ADDED";
|
|
20
21
|
Events["SEGMENTATION_REPRESENTATION_MODIFIED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED";
|
|
21
22
|
Events["SEGMENTATION_REMOVED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REMOVED";
|
|
22
23
|
Events["SEGMENTATION_REPRESENTATION_REMOVED"] = "CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED";
|
|
@@ -4,6 +4,7 @@ import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransf
|
|
|
4
4
|
import vtkPiecewiseFunction from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction';
|
|
5
5
|
import { triggerSegmentationModified, triggerSegmentationRemoved, triggerSegmentationRepresentationModified, triggerSegmentationRepresentationRemoved, } from './triggerSegmentationEvents';
|
|
6
6
|
import { segmentationStyle } from './SegmentationStyle';
|
|
7
|
+
import { triggerSegmentationAdded } from './events/triggerSegmentationAdded';
|
|
7
8
|
const initialDefaultState = {
|
|
8
9
|
colorLUT: [],
|
|
9
10
|
segmentations: [],
|
|
@@ -62,7 +63,7 @@ export default class SegmentationStateManager {
|
|
|
62
63
|
}
|
|
63
64
|
state.segmentations.push(newSegmentation);
|
|
64
65
|
});
|
|
65
|
-
|
|
66
|
+
triggerSegmentationAdded(segmentation.segmentationId);
|
|
66
67
|
}
|
|
67
68
|
removeSegmentation(segmentationId) {
|
|
68
69
|
this.updateState((state) => {
|
|
@@ -25,8 +25,8 @@ function getSegmentIndexColor(viewportId, segmentationId, segmentIndex) {
|
|
|
25
25
|
const representations = getSegmentationRepresentations(viewportId, {
|
|
26
26
|
segmentationId,
|
|
27
27
|
});
|
|
28
|
-
if (!representations) {
|
|
29
|
-
|
|
28
|
+
if (!representations || representations.length === 0) {
|
|
29
|
+
return null;
|
|
30
30
|
}
|
|
31
31
|
const representation = representations[0];
|
|
32
32
|
const { colorLUTIndex } = representation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function triggerSegmentationAdded(segmentationId: string): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { triggerEvent, eventTarget } from '@cornerstonejs/core';
|
|
2
|
+
import { Events } from '../../../enums';
|
|
3
|
+
export function triggerSegmentationAdded(segmentationId) {
|
|
4
|
+
const eventDetail = {
|
|
5
|
+
segmentationId,
|
|
6
|
+
};
|
|
7
|
+
triggerEvent(eventTarget, Events.SEGMENTATION_ADDED, eventDetail);
|
|
8
|
+
}
|
|
@@ -11,6 +11,7 @@ function normalizeSegmentationInput(segmentationInput) {
|
|
|
11
11
|
normalizeContourData(data);
|
|
12
12
|
}
|
|
13
13
|
const normalizedSegments = normalizeSegments(config?.segments, type, data);
|
|
14
|
+
delete config?.segments;
|
|
14
15
|
return {
|
|
15
16
|
segmentationId,
|
|
16
17
|
label: config?.label ?? null,
|
|
@@ -130,6 +130,9 @@ type SegmentationRepresentationRemovedEventDetail = {
|
|
|
130
130
|
type SegmentationModifiedEventDetail = {
|
|
131
131
|
segmentationId: string;
|
|
132
132
|
};
|
|
133
|
+
type SegmentationAddedEventDetail = {
|
|
134
|
+
segmentationId: string;
|
|
135
|
+
};
|
|
133
136
|
type KeyDownEventDetail = {
|
|
134
137
|
element: HTMLDivElement;
|
|
135
138
|
viewportId: string;
|
|
@@ -206,6 +209,7 @@ type SegmentationRemovedEventType = Types.CustomEventType<SegmentationRemovedEve
|
|
|
206
209
|
type SegmentationRepresentationRemovedEventType = Types.CustomEventType<SegmentationRepresentationRemovedEventDetail>;
|
|
207
210
|
type SegmentationRenderedEventType = Types.CustomEventType<SegmentationRenderedEventDetail>;
|
|
208
211
|
type SegmentationModifiedEventType = Types.CustomEventType<SegmentationModifiedEventDetail>;
|
|
212
|
+
type SegmentationAddedEventType = Types.CustomEventType<SegmentationAddedEventDetail>;
|
|
209
213
|
type KeyDownEventType = Types.CustomEventType<KeyDownEventDetail>;
|
|
210
214
|
type KeyUpEventType = Types.CustomEventType<KeyUpEventDetail>;
|
|
211
215
|
type MouseDownEventType = Types.CustomEventType<MouseDownEventDetail>;
|
|
@@ -226,4 +230,4 @@ type MouseClickEventType = Types.CustomEventType<MouseClickEventDetail>;
|
|
|
226
230
|
type MouseMoveEventType = Types.CustomEventType<MouseMoveEventDetail>;
|
|
227
231
|
type MouseDoubleClickEventType = Types.CustomEventType<MouseDoubleClickEventDetail>;
|
|
228
232
|
type MouseWheelEventType = Types.CustomEventType<MouseWheelEventDetail>;
|
|
229
|
-
export type { InteractionStartType, InteractionEndType, InteractionEventType, NormalizedInteractionEventDetail, NormalizedMouseEventType, NormalizedTouchEventType, ToolModeChangedEventDetail, ToolModeChangedEventType, ToolActivatedEventDetail, ToolActivatedEventType, AnnotationAddedEventDetail, AnnotationAddedEventType, AnnotationCompletedEventDetail, AnnotationCompletedEventType, AnnotationModifiedEventDetail, AnnotationModifiedEventType, AnnotationRemovedEventDetail, AnnotationRemovedEventType, AnnotationSelectionChangeEventDetail, AnnotationSelectionChangeEventType, AnnotationRenderedEventDetail, AnnotationRenderedEventType, AnnotationLockChangeEventDetail, AnnotationVisibilityChangeEventDetail, AnnotationLockChangeEventType, AnnotationVisibilityChangeEventType, AnnotationInterpolationCompletedEventDetail, AnnotationInterpolationCompletedEventType, AnnotationInterpolationRemovedEventDetail, AnnotationInterpolationRemovedEventType, ContourAnnotationCompletedEventDetail, SegmentationDataModifiedEventType, SegmentationRepresentationModifiedEventDetail, SegmentationRepresentationModifiedEventType, SegmentationRepresentationRemovedEventDetail, SegmentationRepresentationRemovedEventType, SegmentationRemovedEventType, SegmentationRemovedEventDetail, SegmentationDataModifiedEventDetail, SegmentationRenderedEventType, SegmentationRenderedEventDetail, SegmentationModifiedEventType, SegmentationModifiedEventDetail, KeyDownEventDetail, KeyDownEventType, KeyUpEventDetail, KeyUpEventType, MouseDownEventDetail, TouchStartEventDetail, MouseDownEventType, TouchStartEventType, MouseDownActivateEventDetail, TouchStartActivateEventDetail, MouseDownActivateEventType, TouchStartActivateEventType, MouseDragEventDetail, TouchDragEventDetail, MouseDragEventType, TouchDragEventType, MouseUpEventDetail, TouchEndEventDetail, MouseUpEventType, TouchEndEventType, MouseClickEventDetail, MouseClickEventType, TouchTapEventDetail, TouchTapEventType, TouchSwipeEventDetail, TouchSwipeEventType, TouchPressEventDetail, TouchPressEventType, MouseMoveEventDetail, MouseMoveEventType, MouseDoubleClickEventDetail, MouseDoubleClickEventType, MouseWheelEventDetail, MouseWheelEventType, };
|
|
233
|
+
export type { InteractionStartType, InteractionEndType, InteractionEventType, NormalizedInteractionEventDetail, NormalizedMouseEventType, NormalizedTouchEventType, ToolModeChangedEventDetail, ToolModeChangedEventType, ToolActivatedEventDetail, ToolActivatedEventType, AnnotationAddedEventDetail, AnnotationAddedEventType, AnnotationCompletedEventDetail, AnnotationCompletedEventType, AnnotationModifiedEventDetail, AnnotationModifiedEventType, AnnotationRemovedEventDetail, AnnotationRemovedEventType, AnnotationSelectionChangeEventDetail, AnnotationSelectionChangeEventType, AnnotationRenderedEventDetail, AnnotationRenderedEventType, AnnotationLockChangeEventDetail, AnnotationVisibilityChangeEventDetail, AnnotationLockChangeEventType, AnnotationVisibilityChangeEventType, AnnotationInterpolationCompletedEventDetail, AnnotationInterpolationCompletedEventType, AnnotationInterpolationRemovedEventDetail, AnnotationInterpolationRemovedEventType, ContourAnnotationCompletedEventDetail, SegmentationDataModifiedEventType, SegmentationRepresentationModifiedEventDetail, SegmentationRepresentationModifiedEventType, SegmentationRepresentationRemovedEventDetail, SegmentationRepresentationRemovedEventType, SegmentationRemovedEventType, SegmentationRemovedEventDetail, SegmentationDataModifiedEventDetail, SegmentationRenderedEventType, SegmentationRenderedEventDetail, SegmentationModifiedEventType, SegmentationModifiedEventDetail, KeyDownEventDetail, KeyDownEventType, KeyUpEventDetail, KeyUpEventType, MouseDownEventDetail, TouchStartEventDetail, MouseDownEventType, TouchStartEventType, MouseDownActivateEventDetail, TouchStartActivateEventDetail, MouseDownActivateEventType, TouchStartActivateEventType, MouseDragEventDetail, TouchDragEventDetail, MouseDragEventType, TouchDragEventType, MouseUpEventDetail, TouchEndEventDetail, MouseUpEventType, TouchEndEventType, MouseClickEventDetail, MouseClickEventType, TouchTapEventDetail, TouchTapEventType, TouchSwipeEventDetail, TouchSwipeEventType, TouchPressEventDetail, TouchPressEventType, MouseMoveEventDetail, MouseMoveEventType, MouseDoubleClickEventDetail, MouseDoubleClickEventType, MouseWheelEventDetail, MouseWheelEventType, SegmentationAddedEventDetail, SegmentationAddedEventType, };
|
|
@@ -22,6 +22,7 @@ function playClip(element, playClipOptions) {
|
|
|
22
22
|
playClipOptions.dynamicCineEnabled =
|
|
23
23
|
playClipOptions.dynamicCineEnabled ?? true;
|
|
24
24
|
const { viewport } = enabledElement;
|
|
25
|
+
const volume = _getVolumeFromViewport(viewport);
|
|
25
26
|
const playClipContext = _createCinePlayContext(viewport, playClipOptions);
|
|
26
27
|
let playClipData = getToolState(element);
|
|
27
28
|
const isDynamicCinePlaying = playClipOptions.dynamicCineEnabled;
|
|
@@ -211,17 +212,11 @@ function _stopClipWithData(playClipData) {
|
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
function _getVolumesFromViewport(viewport) {
|
|
215
|
-
if (!viewport || !viewport.getVolumeId) {
|
|
216
|
-
return [];
|
|
217
|
-
}
|
|
218
|
-
const volumeId = viewport.getVolumeId();
|
|
219
|
-
return [cache.getVolume(volumeId)];
|
|
220
|
-
}
|
|
221
215
|
function _getVolumeFromViewport(viewport) {
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
|
|
216
|
+
const volumeIds = viewport.getAllVolumeIds();
|
|
217
|
+
const dynamicVolumeId = volumeIds.find((volumeId) => cache.getVolume(volumeId)?.isDynamicVolume());
|
|
218
|
+
const volumeId = dynamicVolumeId ?? volumeIds[0];
|
|
219
|
+
return cache.getVolume(volumeId);
|
|
225
220
|
}
|
|
226
221
|
function _createStackViewportCinePlayContext(viewport, waitForRendered) {
|
|
227
222
|
const imageIds = viewport.getImageIds();
|
|
@@ -13,6 +13,9 @@ function getDataInTime(dynamicVolume, options) {
|
|
|
13
13
|
}
|
|
14
14
|
if (options.maskVolumeId) {
|
|
15
15
|
const segmentationVolume = cache.getVolume(options.maskVolumeId);
|
|
16
|
+
if (!segmentationVolume) {
|
|
17
|
+
throw new Error('Segmentation volume not found');
|
|
18
|
+
}
|
|
16
19
|
const [dataInTime, ijkCoords] = _getTimePointDataMask(frames, dynamicVolume, segmentationVolume);
|
|
17
20
|
return [dataInTime, ijkCoords];
|
|
18
21
|
}
|
|
@@ -33,12 +36,10 @@ function _getTimePointDataCoordinate(frames, coordinate, volume) {
|
|
|
33
36
|
}
|
|
34
37
|
const yMultiple = dimensions[0];
|
|
35
38
|
const zMultiple = dimensions[0] * dimensions[1];
|
|
36
|
-
const allScalarData = volume.getScalarDataArrays();
|
|
37
39
|
const value = [];
|
|
38
40
|
frames.forEach((frame) => {
|
|
39
|
-
const activeScalarData = allScalarData[frame];
|
|
40
41
|
const scalarIndex = index[2] * zMultiple + index[1] * yMultiple + index[0];
|
|
41
|
-
value.push(
|
|
42
|
+
value.push(volume.voxelManager.getAtIndexAndTimePoint(scalarIndex, frame));
|
|
42
43
|
});
|
|
43
44
|
return value;
|
|
44
45
|
}
|
|
@@ -48,35 +49,29 @@ function _getTimePointDataMask(frames, dynamicVolume, segmentationVolume) {
|
|
|
48
49
|
const scalarDataLength = segVoxelManager.getScalarDataLength();
|
|
49
50
|
const nonZeroVoxelIndices = [];
|
|
50
51
|
nonZeroVoxelIndices.length = scalarDataLength;
|
|
51
|
-
const ijkCoords = [];
|
|
52
|
-
const dimensions = segmentationVolume.dimensions;
|
|
53
52
|
let actualLen = 0;
|
|
54
53
|
for (let i = 0, len = scalarDataLength; i < len; i++) {
|
|
55
54
|
if (segVoxelManager.getAtIndex(i) !== 0) {
|
|
56
|
-
ijkCoords.push([
|
|
57
|
-
i % dimensions[0],
|
|
58
|
-
Math.floor((i / dimensions[0]) % dimensions[1]),
|
|
59
|
-
Math.floor(i / (dimensions[0] * dimensions[1])),
|
|
60
|
-
]);
|
|
61
55
|
nonZeroVoxelIndices[actualLen++] = i;
|
|
62
56
|
}
|
|
63
57
|
}
|
|
64
58
|
nonZeroVoxelIndices.length = actualLen;
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const isSameVolume = dynamicVolumeScalarDataArray[0].length === scalarDataLength &&
|
|
59
|
+
const nonZeroVoxelValuesInTime = [];
|
|
60
|
+
const isSameVolume = dynamicVolume.voxelManager.getScalarDataLength() === scalarDataLength &&
|
|
68
61
|
JSON.stringify(dynamicVolume.spacing) ===
|
|
69
62
|
JSON.stringify(segmentationVolume.spacing);
|
|
63
|
+
const ijkCoords = [];
|
|
70
64
|
if (isSameVolume) {
|
|
71
65
|
for (let i = 0; i < nonZeroVoxelIndices.length; i++) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
66
|
+
const valuesInTime = [];
|
|
67
|
+
const index = nonZeroVoxelIndices[i];
|
|
68
|
+
for (let j = 0; j < frames.length; j++) {
|
|
69
|
+
valuesInTime.push(dynamicVolume.voxelManager.getAtIndexAndTimePoint(index, frames[j]));
|
|
70
|
+
}
|
|
71
|
+
nonZeroVoxelValuesInTime.push(valuesInTime);
|
|
72
|
+
ijkCoords.push(segVoxelManager.toIJK(index));
|
|
78
73
|
}
|
|
79
|
-
return [
|
|
74
|
+
return [nonZeroVoxelValuesInTime, ijkCoords];
|
|
80
75
|
}
|
|
81
76
|
const callback = ({ pointLPS: segPointLPS, value: segValue, pointIJK: segPointIJK, }) => {
|
|
82
77
|
if (segValue === 0) {
|
|
@@ -88,7 +83,7 @@ function _getTimePointDataMask(frames, dynamicVolume, segmentationVolume) {
|
|
|
88
83
|
frames.forEach((frame) => perFrameSum.set(frame, 0));
|
|
89
84
|
const averageCallback = ({ index }) => {
|
|
90
85
|
for (let i = 0; i < frames.length; i++) {
|
|
91
|
-
const value =
|
|
86
|
+
const value = dynamicVolume.voxelManager.getAtIndexAndTimePoint(index, frames[i]);
|
|
92
87
|
const frame = frames[i];
|
|
93
88
|
perFrameSum.set(frame, perFrameSum.get(frame) + value);
|
|
94
89
|
}
|
|
@@ -103,12 +98,11 @@ function _getTimePointDataMask(frames, dynamicVolume, segmentationVolume) {
|
|
|
103
98
|
averageValues.push(sum / count);
|
|
104
99
|
});
|
|
105
100
|
ijkCoords.push(segPointIJK);
|
|
106
|
-
|
|
101
|
+
nonZeroVoxelValuesInTime.push(averageValues);
|
|
107
102
|
};
|
|
108
|
-
|
|
109
|
-
voxelManager.forEach(callback, {
|
|
103
|
+
segmentationVolume.voxelManager.forEach(callback, {
|
|
110
104
|
imageData: maskImageData,
|
|
111
105
|
});
|
|
112
|
-
return [
|
|
106
|
+
return [nonZeroVoxelValuesInTime, ijkCoords];
|
|
113
107
|
}
|
|
114
108
|
export default getDataInTime;
|
|
@@ -4,21 +4,33 @@ const equalsCheck = (a, b) => {
|
|
|
4
4
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
5
5
|
};
|
|
6
6
|
export function getVoxelOverlap(imageData, dimensions, voxelSpacing, voxelCenter) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
const halfSpacingX = voxelSpacing[0] / 2;
|
|
8
|
+
const halfSpacingY = voxelSpacing[1] / 2;
|
|
9
|
+
const halfSpacingZ = voxelSpacing[2] / 2;
|
|
10
|
+
const voxelCornersIJK = new Array(8);
|
|
11
|
+
voxelCornersIJK[0] = csUtils.transformWorldToIndex(imageData, [
|
|
12
|
+
voxelCenter[0] - halfSpacingX,
|
|
13
|
+
voxelCenter[1] - halfSpacingY,
|
|
14
|
+
voxelCenter[2] - halfSpacingZ,
|
|
15
|
+
]);
|
|
16
|
+
const offsets = [
|
|
17
|
+
[1, -1, -1],
|
|
18
|
+
[-1, 1, -1],
|
|
19
|
+
[1, 1, -1],
|
|
20
|
+
[-1, -1, 1],
|
|
21
|
+
[1, -1, 1],
|
|
22
|
+
[-1, 1, 1],
|
|
23
|
+
[1, 1, 1],
|
|
24
|
+
];
|
|
25
|
+
for (let i = 0; i < 7; i++) {
|
|
26
|
+
const [xOff, yOff, zOff] = offsets[i];
|
|
27
|
+
voxelCornersIJK[i + 1] = csUtils.transformWorldToIndex(imageData, [
|
|
28
|
+
voxelCenter[0] + xOff * halfSpacingX,
|
|
29
|
+
voxelCenter[1] + yOff * halfSpacingY,
|
|
30
|
+
voxelCenter[2] + zOff * halfSpacingZ,
|
|
31
|
+
]);
|
|
18
32
|
}
|
|
19
|
-
|
|
20
|
-
const overlapBounds = getBoundingBoxAroundShapeIJK(voxelCornersIJK, dimensions);
|
|
21
|
-
return overlapBounds;
|
|
33
|
+
return getBoundingBoxAroundShapeIJK(voxelCornersIJK, dimensions);
|
|
22
34
|
}
|
|
23
35
|
export function processVolumes(segmentationVolume, thresholdVolumeInformation) {
|
|
24
36
|
const { spacing: segmentationSpacing } = segmentationVolume;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { eventTarget, VolumeViewport, StackViewport, Enums, utilities, getEnabledElement, } from '@cornerstonejs/core';
|
|
1
|
+
import { eventTarget, VolumeViewport, StackViewport, Enums, utilities, getEnabledElement, cache, } from '@cornerstonejs/core';
|
|
2
2
|
import { Colorbar } from './Colorbar';
|
|
3
3
|
import { getVOIMultipliers } from '../../getVOIMultipliers';
|
|
4
4
|
const { Events } = Enums;
|
|
@@ -88,14 +88,24 @@ class ViewportColorbar extends Colorbar {
|
|
|
88
88
|
static _getImageRange(element, volumeId) {
|
|
89
89
|
const enabledElement = getEnabledElement(element);
|
|
90
90
|
const { viewport } = enabledElement;
|
|
91
|
-
const actor = volumeId
|
|
92
|
-
? viewport.getActor(volumeId)
|
|
93
|
-
: viewport.getDefaultActor();
|
|
91
|
+
const actor = viewport.getImageActor(volumeId);
|
|
94
92
|
if (!actor) {
|
|
95
93
|
return defaultImageRange;
|
|
96
94
|
}
|
|
97
|
-
const imageData = actor.
|
|
98
|
-
const
|
|
95
|
+
const imageData = actor.getMapper().getInputData();
|
|
96
|
+
const scalarData = imageData.getPointData().getScalars();
|
|
97
|
+
let imageRange;
|
|
98
|
+
if (!scalarData) {
|
|
99
|
+
if (!volumeId) {
|
|
100
|
+
throw new Error('volumeId is required when scalarData is not available');
|
|
101
|
+
}
|
|
102
|
+
const volume = cache.getVolume(volumeId);
|
|
103
|
+
const [minValue, maxValue] = volume.voxelManager.getRange();
|
|
104
|
+
imageRange = [minValue, maxValue];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
imageRange = scalarData.getRange();
|
|
108
|
+
}
|
|
99
109
|
return imageRange[0] === 0 && imageRange[1] === 0
|
|
100
110
|
? defaultImageRange
|
|
101
111
|
: { lower: imageRange[0], upper: imageRange[1] };
|
|
@@ -103,16 +113,11 @@ class ViewportColorbar extends Colorbar {
|
|
|
103
113
|
static _getVOIRange(element, volumeId) {
|
|
104
114
|
const enabledElement = getEnabledElement(element);
|
|
105
115
|
const { viewport } = enabledElement;
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
: viewport.getDefaultActor();
|
|
109
|
-
if (!volumeActor || !utilities.isImageActor(volumeActor)) {
|
|
116
|
+
const actor = viewport.getImageActor(volumeId);
|
|
117
|
+
if (!actor) {
|
|
110
118
|
return defaultImageRange;
|
|
111
119
|
}
|
|
112
|
-
const voiRange =
|
|
113
|
-
.getProperty()
|
|
114
|
-
.getRGBTransferFunction(0)
|
|
115
|
-
.getRange();
|
|
120
|
+
const voiRange = actor.getProperty().getRGBTransferFunction(0).getRange();
|
|
116
121
|
return voiRange[0] === 0 && voiRange[1] === 0
|
|
117
122
|
? defaultImageRange
|
|
118
123
|
: { lower: voiRange[0], upper: voiRange[1] };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"canvas": "^2.11.2"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@cornerstonejs/core": "^2.1.
|
|
108
|
+
"@cornerstonejs/core": "^2.1.8",
|
|
109
109
|
"@kitware/vtk.js": "32.1.0",
|
|
110
110
|
"@types/d3-array": "^3.0.4",
|
|
111
111
|
"@types/d3-interpolate": "^3.0.1",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"type": "individual",
|
|
125
125
|
"url": "https://ohif.org/donate"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "5addc676c0202a1ac03d89be5d727c4d88de3bca"
|
|
128
128
|
}
|