@cornerstonejs/tools 1.44.3 → 1.45.1
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/mouse/mouseDownListener.js.map +1 -1
- package/dist/cjs/store/filterToolsWithAnnotationsForElement.js.map +1 -1
- package/dist/cjs/tools/annotation/CircleROITool.js +1 -2
- package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/LivewireContourTool.js +3 -6
- package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/cjs/utilities/livewire/LivewireScissors.d.ts +2 -3
- package/dist/cjs/utilities/livewire/LivewireScissors.js +0 -12
- package/dist/cjs/utilities/livewire/LivewireScissors.js.map +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/esm/eventListeners/mouse/mouseDownListener.js.map +1 -1
- package/dist/esm/store/filterToolsWithAnnotationsForElement.js.map +1 -1
- package/dist/esm/tools/annotation/CircleROITool.js +1 -2
- package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourTool.js +4 -7
- package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/esm/utilities/livewire/LivewireScissors.js +0 -12
- package/dist/esm/utilities/livewire/LivewireScissors.js.map +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/types/eventListeners/mouse/mouseDownListener.d.ts.map +1 -1
- package/dist/types/store/filterToolsWithAnnotationsForElement.d.ts.map +1 -1
- package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
- package/dist/types/utilities/livewire/LivewireScissors.d.ts +2 -3
- package/dist/types/utilities/livewire/LivewireScissors.d.ts.map +1 -1
- package/dist/types/utilities/planar/filterAnnotationsForDisplay.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/mouse/mouseDownListener.ts +2 -0
- package/src/store/filterToolsWithAnnotationsForElement.ts +0 -1
- package/src/tools/annotation/CircleROITool.ts +0 -3
- package/src/tools/annotation/LivewireContourTool.ts +7 -9
- package/src/utilities/livewire/LivewireScissors.ts +7 -33
- package/src/utilities/planar/filterAnnotationsForDisplay.ts +1 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.1",
|
|
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.45.1",
|
|
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": "acd22f0138a44d468688195e5f074dd6932e57ba"
|
|
57
57
|
}
|
|
@@ -2,6 +2,7 @@ import { getEnabledElement, triggerEvent } from '@cornerstonejs/core';
|
|
|
2
2
|
import type { Types } from '@cornerstonejs/core';
|
|
3
3
|
|
|
4
4
|
import Events from '../../enums/Events';
|
|
5
|
+
import { MouseBindings } from '../../enums/ToolBindings';
|
|
5
6
|
import mouseMoveListener from './mouseMoveListener';
|
|
6
7
|
import { EventTypes, IPoints } from '../../types';
|
|
7
8
|
import getMouseEventPoints from './getMouseEventPoints';
|
|
@@ -314,6 +315,7 @@ function _onMouseUp(evt: MouseEvent): void {
|
|
|
314
315
|
|
|
315
316
|
const currentPoints = getMouseEventPoints(evt, state.element);
|
|
316
317
|
const deltaPoints = _getDeltaPoints(currentPoints, state.lastPoints);
|
|
318
|
+
|
|
317
319
|
const eventDetail:
|
|
318
320
|
| EventTypes.MouseUpEventDetail
|
|
319
321
|
| EventTypes.MouseClickEventType = {
|
|
@@ -2,7 +2,6 @@ import { getAnnotations } from '../stateManagement/annotation/annotationState';
|
|
|
2
2
|
import { ToolAnnotationsPair } from '../types/InternalToolTypes';
|
|
3
3
|
import type AnnotationTool from '../tools/base/AnnotationTool';
|
|
4
4
|
import BaseTool from '../tools/base/BaseTool';
|
|
5
|
-
import { getEnabledElement } from '@cornerstonejs/core';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Filters an array of tools, returning only tools which have annotation.
|
|
@@ -168,7 +168,6 @@ class CircleROITool extends AnnotationTool {
|
|
|
168
168
|
const eventDetail = evt.detail;
|
|
169
169
|
const { currentPoints, element } = eventDetail;
|
|
170
170
|
const worldPos = currentPoints.world;
|
|
171
|
-
const canvasPos = currentPoints.canvas;
|
|
172
171
|
|
|
173
172
|
const enabledElement = getEnabledElement(element);
|
|
174
173
|
const { viewport, renderingEngine } = enabledElement;
|
|
@@ -1052,11 +1051,9 @@ function defaultGetTextLines(data, targetId): string[] {
|
|
|
1052
1051
|
stdDev,
|
|
1053
1052
|
max,
|
|
1054
1053
|
isEmptyArea,
|
|
1055
|
-
Modality,
|
|
1056
1054
|
areaUnit,
|
|
1057
1055
|
modalityUnit,
|
|
1058
1056
|
} = cachedVolumeStats;
|
|
1059
|
-
|
|
1060
1057
|
const textLines: string[] = [];
|
|
1061
1058
|
|
|
1062
1059
|
if (radius) {
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
eventTarget,
|
|
6
6
|
triggerEvent,
|
|
7
7
|
utilities as csUtils,
|
|
8
|
-
StackViewport,
|
|
9
8
|
VolumeViewport,
|
|
10
9
|
} from '@cornerstonejs/core';
|
|
11
10
|
import type { Types } from '@cornerstonejs/core';
|
|
@@ -92,20 +91,19 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
92
91
|
|
|
93
92
|
const defaultActor = viewport.getDefaultActor();
|
|
94
93
|
|
|
95
|
-
if (!defaultActor || !csUtils.isImageActor(defaultActor)) {
|
|
96
|
-
|
|
97
|
-
}
|
|
94
|
+
// if (!defaultActor || !csUtils.isImageActor(defaultActor)) {
|
|
95
|
+
// throw new Error('Default actor must be an image actor');
|
|
96
|
+
// }
|
|
98
97
|
|
|
99
98
|
const viewportImageData = viewport.getImageData();
|
|
100
99
|
const { imageData: vtkImageData } = viewportImageData;
|
|
101
100
|
let worldToSlice: (point: Types.Point3) => Types.Point2;
|
|
102
101
|
let sliceToWorld: (point: Types.Point2) => Types.Point3;
|
|
103
|
-
let scalarData;
|
|
102
|
+
let { scalarData } = viewportImageData;
|
|
104
103
|
let width;
|
|
105
104
|
let height;
|
|
106
105
|
|
|
107
|
-
if (viewport instanceof
|
|
108
|
-
scalarData = viewportImageData.scalarData;
|
|
106
|
+
if (!(viewport instanceof VolumeViewport) && scalarData) {
|
|
109
107
|
width = viewportImageData.dimensions[0];
|
|
110
108
|
height = viewportImageData.dimensions[1];
|
|
111
109
|
|
|
@@ -155,12 +153,12 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
155
153
|
} else {
|
|
156
154
|
throw new Error('Viewport not supported');
|
|
157
155
|
}
|
|
158
|
-
|
|
156
|
+
scalarData = csUtils.convertToGrayscale(scalarData, width, height);
|
|
159
157
|
const { voiRange } = viewport.getProperties();
|
|
160
158
|
const startPos = worldToSlice(worldPos);
|
|
161
159
|
|
|
162
160
|
this.scissors = LivewireScissors.createInstanceFromRawPixelData(
|
|
163
|
-
scalarData,
|
|
161
|
+
scalarData as Float32Array,
|
|
164
162
|
width,
|
|
165
163
|
height,
|
|
166
164
|
voiRange
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Types } from '@cornerstonejs/core';
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
2
|
import { BucketQueue } from '../BucketQueue';
|
|
3
3
|
|
|
4
4
|
const MAX_UINT32 = 4294967295;
|
|
@@ -28,7 +28,7 @@ export class LivewireScissors {
|
|
|
28
28
|
public readonly height: number;
|
|
29
29
|
|
|
30
30
|
/** Grayscale image */
|
|
31
|
-
private grayscalePixelData:
|
|
31
|
+
private grayscalePixelData: Types.PixelDataTypedArray;
|
|
32
32
|
|
|
33
33
|
// Laplace zero-crossings (either 0 or 1).
|
|
34
34
|
private laplace: Float32Array;
|
|
@@ -57,7 +57,11 @@ export class LivewireScissors {
|
|
|
57
57
|
/** Dijkstra - BucketQueue to sort items by priority */
|
|
58
58
|
private priorityQueueNew: BucketQueue<number>;
|
|
59
59
|
|
|
60
|
-
constructor(
|
|
60
|
+
constructor(
|
|
61
|
+
grayscalePixelData: Types.PixelDataTypedArray,
|
|
62
|
+
width: number,
|
|
63
|
+
height: number
|
|
64
|
+
) {
|
|
61
65
|
const numPixels = grayscalePixelData.length;
|
|
62
66
|
|
|
63
67
|
this.searchGranularityBits = 8; // Bits of resolution for BucketQueue.
|
|
@@ -549,34 +553,4 @@ export class LivewireScissors {
|
|
|
549
553
|
|
|
550
554
|
return new LivewireScissors(grayscalePixelData, width, height);
|
|
551
555
|
}
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* Create a livewire scissor instance from a RGBA image
|
|
555
|
-
* @param rgbaPixelData - RGBA pixel data
|
|
556
|
-
* @param width - Width of the image
|
|
557
|
-
* @param height - Height of the image
|
|
558
|
-
* @returns A LivewireScissors instance
|
|
559
|
-
*/
|
|
560
|
-
public static createInstanceFromRGBAPixelData(
|
|
561
|
-
rgbaPixelData: Uint8ClampedArray,
|
|
562
|
-
width: number,
|
|
563
|
-
height: number
|
|
564
|
-
): LivewireScissors {
|
|
565
|
-
const numPixels = rgbaPixelData.length / 4;
|
|
566
|
-
const grayscalePixelData = new Float32Array(numPixels);
|
|
567
|
-
|
|
568
|
-
// Multiplier to average an RGB sum and convert it to 0-1 range.
|
|
569
|
-
// 1/x because multiplication is faster than division.
|
|
570
|
-
const avgMultiplier = 1 / (3 * 255);
|
|
571
|
-
|
|
572
|
-
for (let i = 0, offset = 0; i < numPixels; i++, offset += 4) {
|
|
573
|
-
const red = rgbaPixelData[offset];
|
|
574
|
-
const green = rgbaPixelData[offset];
|
|
575
|
-
const blue = rgbaPixelData[offset];
|
|
576
|
-
|
|
577
|
-
grayscalePixelData[i] = (red + green + blue) * avgMultiplier;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
return new LivewireScissors(grayscalePixelData, width, height);
|
|
581
|
-
}
|
|
582
556
|
}
|
|
@@ -77,11 +77,7 @@ export default function filterAnnotationsForDisplay(
|
|
|
77
77
|
if (Array.isArray(range)) {
|
|
78
78
|
return frameNumber >= range[0] && frameNumber <= range[1];
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
// number to position - this allows the annotation to display when
|
|
82
|
-
// the video element is not exactly the same timing as expected or when
|
|
83
|
-
// playing video back.
|
|
84
|
-
return Math.abs(frameNumber - range) <= 5;
|
|
80
|
+
return Math.abs(frameNumber - range) < 1;
|
|
85
81
|
});
|
|
86
82
|
} else if (viewport instanceof VolumeViewport) {
|
|
87
83
|
const camera = viewport.getCamera();
|