@cornerstonejs/adapters 3.31.0 → 3.31.2
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/adapters/Cornerstone/Bidirectional.js +1 -0
- package/dist/esm/adapters/Cornerstone/MeasurementReport.js +1 -0
- package/dist/esm/adapters/Cornerstone3D/Angle.d.ts +23 -62
- package/dist/esm/adapters/Cornerstone3D/Angle.js +29 -141
- package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.d.ts +13 -27
- package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.js +26 -144
- package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.d.ts +2 -12
- package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.js +13 -42
- package/dist/esm/adapters/Cornerstone3D/Bidirectional.d.ts +23 -80
- package/dist/esm/adapters/Cornerstone3D/Bidirectional.js +33 -167
- package/dist/esm/adapters/Cornerstone3D/CircleROI.d.ts +16 -33
- package/dist/esm/adapters/Cornerstone3D/CircleROI.js +28 -129
- package/dist/esm/adapters/Cornerstone3D/CobbAngle.d.ts +23 -62
- package/dist/esm/adapters/Cornerstone3D/CobbAngle.js +22 -144
- package/dist/esm/adapters/Cornerstone3D/EllipticalROI.d.ts +7 -29
- package/dist/esm/adapters/Cornerstone3D/EllipticalROI.js +25 -176
- package/dist/esm/adapters/Cornerstone3D/KeyImage.d.ts +8 -10
- package/dist/esm/adapters/Cornerstone3D/KeyImage.js +2 -2
- package/dist/esm/adapters/Cornerstone3D/Length.d.ts +15 -44
- package/dist/esm/adapters/Cornerstone3D/Length.js +28 -121
- package/dist/esm/adapters/Cornerstone3D/MeasurementReport.d.ts +57 -38
- package/dist/esm/adapters/Cornerstone3D/MeasurementReport.js +66 -30
- package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.d.ts +16 -41
- package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.js +25 -132
- package/dist/esm/adapters/Cornerstone3D/Probe.d.ts +7 -21
- package/dist/esm/adapters/Cornerstone3D/Probe.js +12 -39
- package/dist/esm/adapters/Cornerstone3D/RectangleROI.d.ts +1 -1
- package/dist/esm/adapters/Cornerstone3D/RectangleROI.js +7 -2
- package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.d.ts +6 -15
- package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.js +6 -2
- package/dist/esm/adapters/helpers/index.d.ts +3 -0
- package/dist/esm/adapters/helpers/index.js +3 -0
- package/dist/esm/adapters/helpers/scoordToWorld.d.ts +5 -0
- package/dist/esm/adapters/helpers/scoordToWorld.js +32 -0
- package/dist/esm/adapters/helpers/toPoint3.d.ts +3 -0
- package/dist/esm/adapters/helpers/toPoint3.js +18 -0
- package/dist/esm/adapters/helpers/toScoordType.d.ts +23 -0
- package/dist/esm/adapters/helpers/toScoordType.js +33 -0
- package/dist/esm/adapters/index.js +1 -0
- package/dist/esm/version.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
2
|
import { utilities } from 'dcmjs';
|
|
3
|
+
import { utilities as utilities$1 } from '@cornerstonejs/core';
|
|
3
4
|
import MeasurementReport from './MeasurementReport.js';
|
|
4
5
|
import BaseAdapter3D from './BaseAdapter3D.js';
|
|
5
6
|
|
|
@@ -7,56 +8,22 @@ var _EllipticalROI;
|
|
|
7
8
|
const {
|
|
8
9
|
Ellipse: TID300Ellipse
|
|
9
10
|
} = utilities.TID300;
|
|
11
|
+
const {
|
|
12
|
+
worldToImageCoords
|
|
13
|
+
} = utilities$1;
|
|
10
14
|
const EPSILON = 1e-4;
|
|
11
15
|
class EllipticalROI extends BaseAdapter3D {
|
|
12
16
|
static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
|
|
13
17
|
const {
|
|
14
|
-
|
|
18
|
+
state,
|
|
15
19
|
NUMGroup,
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
scoord,
|
|
21
|
+
scoordArgs,
|
|
22
|
+
worldCoords,
|
|
23
|
+
referencedImageId,
|
|
18
24
|
ReferencedFrameNumber
|
|
19
25
|
} = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, EllipticalROI.toolType);
|
|
20
|
-
|
|
21
|
-
return this.getMeasurementDataFromScoord({
|
|
22
|
-
defaultState,
|
|
23
|
-
SCOORDGroup,
|
|
24
|
-
imageToWorldCoords,
|
|
25
|
-
metadata,
|
|
26
|
-
NUMGroup,
|
|
27
|
-
ReferencedFrameNumber
|
|
28
|
-
});
|
|
29
|
-
} else if (SCOORD3DGroup) {
|
|
30
|
-
return this.getMeasurementDataFromScoord3D({
|
|
31
|
-
defaultState,
|
|
32
|
-
SCOORD3DGroup
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
static getMeasurementDataFromScoord(_ref) {
|
|
39
|
-
let {
|
|
40
|
-
defaultState,
|
|
41
|
-
SCOORDGroup,
|
|
42
|
-
imageToWorldCoords,
|
|
43
|
-
metadata,
|
|
44
|
-
NUMGroup,
|
|
45
|
-
ReferencedFrameNumber
|
|
46
|
-
} = _ref;
|
|
47
|
-
const referencedImageId = defaultState.annotation.metadata.referencedImageId;
|
|
48
|
-
const {
|
|
49
|
-
GraphicData
|
|
50
|
-
} = SCOORDGroup;
|
|
51
|
-
const pointsWorld = [];
|
|
52
|
-
for (let i = 0; i < GraphicData.length; i += 2) {
|
|
53
|
-
const worldPos = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
|
|
54
|
-
pointsWorld.push(worldPos);
|
|
55
|
-
}
|
|
56
|
-
const majorAxisStart = vec3.fromValues(...pointsWorld[0]);
|
|
57
|
-
const majorAxisEnd = vec3.fromValues(...pointsWorld[1]);
|
|
58
|
-
const minorAxisStart = vec3.fromValues(...pointsWorld[2]);
|
|
59
|
-
const minorAxisEnd = vec3.fromValues(...pointsWorld[3]);
|
|
26
|
+
const [majorAxisStart, majorAxisEnd, minorAxisStart, minorAxisEnd] = worldCoords;
|
|
60
27
|
const majorAxisVec = vec3.create();
|
|
61
28
|
vec3.sub(majorAxisVec, majorAxisEnd, majorAxisStart);
|
|
62
29
|
vec3.normalize(majorAxisVec, majorAxisVec);
|
|
@@ -77,14 +44,15 @@ class EllipticalROI extends BaseAdapter3D {
|
|
|
77
44
|
const absoluteOfMinorDotProduct = Math.abs(projectedMinorAxisOnColVec);
|
|
78
45
|
let ellipsePoints = [];
|
|
79
46
|
if (Math.abs(absoluteOfMajorDotProduct - 1) < EPSILON) {
|
|
80
|
-
ellipsePoints =
|
|
47
|
+
ellipsePoints = worldCoords;
|
|
81
48
|
} else if (Math.abs(absoluteOfMinorDotProduct - 1) < EPSILON) {
|
|
82
|
-
ellipsePoints = [
|
|
49
|
+
ellipsePoints = [worldCoords[2], worldCoords[3], worldCoords[0], worldCoords[1]];
|
|
83
50
|
} else {
|
|
84
51
|
console.warn("OBLIQUE ELLIPSE NOT YET SUPPORTED");
|
|
52
|
+
return null;
|
|
85
53
|
}
|
|
86
|
-
const state = defaultState;
|
|
87
54
|
state.annotation.data = {
|
|
55
|
+
...state.annotation.data,
|
|
88
56
|
handles: {
|
|
89
57
|
points: [...ellipsePoints],
|
|
90
58
|
activeHandleIndex: 0,
|
|
@@ -92,52 +60,19 @@ class EllipticalROI extends BaseAdapter3D {
|
|
|
92
60
|
hasMoved: false
|
|
93
61
|
}
|
|
94
62
|
},
|
|
95
|
-
|
|
63
|
+
frameNumber: ReferencedFrameNumber
|
|
64
|
+
};
|
|
65
|
+
if (referencedImageId) {
|
|
66
|
+
state.annotation.data.cachedStats = {
|
|
96
67
|
[`imageId:${referencedImageId}`]: {
|
|
97
68
|
area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0
|
|
98
69
|
}
|
|
99
|
-
}
|
|
100
|
-
frameNumber: ReferencedFrameNumber
|
|
101
|
-
};
|
|
102
|
-
return state;
|
|
103
|
-
}
|
|
104
|
-
static getMeasurementDataFromScoord3D(_ref2) {
|
|
105
|
-
let {
|
|
106
|
-
defaultState,
|
|
107
|
-
SCOORD3DGroup
|
|
108
|
-
} = _ref2;
|
|
109
|
-
const {
|
|
110
|
-
GraphicData
|
|
111
|
-
} = SCOORD3DGroup;
|
|
112
|
-
const pointsWorld = [];
|
|
113
|
-
for (let i = 0; i < GraphicData.length; i += 3) {
|
|
114
|
-
const worldPos = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
|
|
115
|
-
pointsWorld.push(worldPos);
|
|
70
|
+
};
|
|
116
71
|
}
|
|
117
|
-
const majorAxisStart = vec3.fromValues(...pointsWorld[0]);
|
|
118
|
-
const majorAxisEnd = vec3.fromValues(...pointsWorld[1]);
|
|
119
|
-
const minorAxisStart = vec3.fromValues(...pointsWorld[2]);
|
|
120
|
-
const minorAxisEnd = vec3.fromValues(...pointsWorld[3]);
|
|
121
|
-
const majorAxisVec = vec3.create();
|
|
122
|
-
vec3.sub(majorAxisVec, majorAxisEnd, majorAxisStart);
|
|
123
|
-
vec3.normalize(majorAxisVec, majorAxisVec);
|
|
124
|
-
const minorAxisVec = vec3.create();
|
|
125
|
-
vec3.sub(minorAxisVec, minorAxisEnd, minorAxisStart);
|
|
126
|
-
vec3.normalize(minorAxisVec, minorAxisVec);
|
|
127
|
-
const state = defaultState;
|
|
128
|
-
state.annotation.data = {
|
|
129
|
-
handles: {
|
|
130
|
-
points: [majorAxisStart, majorAxisEnd, minorAxisStart, minorAxisEnd],
|
|
131
|
-
activeHandleIndex: 0,
|
|
132
|
-
textBox: {
|
|
133
|
-
hasMoved: false
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
cachedStats: {}
|
|
137
|
-
};
|
|
138
72
|
return state;
|
|
139
73
|
}
|
|
140
|
-
static getTID300RepresentationArguments(tool
|
|
74
|
+
static getTID300RepresentationArguments(tool) {
|
|
75
|
+
let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
141
76
|
const {
|
|
142
77
|
data,
|
|
143
78
|
finding,
|
|
@@ -152,9 +87,6 @@ class EllipticalROI extends BaseAdapter3D {
|
|
|
152
87
|
const {
|
|
153
88
|
referencedImageId
|
|
154
89
|
} = metadata;
|
|
155
|
-
if (!referencedImageId) {
|
|
156
|
-
return this.getTID300RepresentationArgumentsSCOORD3D(tool);
|
|
157
|
-
}
|
|
158
90
|
let top, bottom, left, right;
|
|
159
91
|
if (rotation == 90 || rotation == 270) {
|
|
160
92
|
bottom = worldToImageCoords(referencedImageId, handles.points[2]);
|
|
@@ -167,8 +99,8 @@ class EllipticalROI extends BaseAdapter3D {
|
|
|
167
99
|
left = worldToImageCoords(referencedImageId, handles.points[2]);
|
|
168
100
|
right = worldToImageCoords(referencedImageId, handles.points[3]);
|
|
169
101
|
}
|
|
170
|
-
const topBottomLength = Math.abs(top
|
|
171
|
-
const leftRightLength = Math.abs(left
|
|
102
|
+
const topBottomLength = Math.abs(top.y - bottom.y);
|
|
103
|
+
const leftRightLength = Math.abs(left.x - right.x);
|
|
172
104
|
const points = [];
|
|
173
105
|
if (topBottomLength > leftRightLength) {
|
|
174
106
|
points.push({
|
|
@@ -214,91 +146,8 @@ class EllipticalROI extends BaseAdapter3D {
|
|
|
214
146
|
trackingIdentifierTextValue: this.trackingIdentifierTextValue,
|
|
215
147
|
finding,
|
|
216
148
|
findingSites: findingSites || [],
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
static getTID300RepresentationArgumentsSCOORD3D(tool) {
|
|
221
|
-
const {
|
|
222
|
-
data,
|
|
223
|
-
finding,
|
|
224
|
-
findingSites,
|
|
225
|
-
metadata
|
|
226
|
-
} = tool;
|
|
227
|
-
const {
|
|
228
|
-
cachedStats,
|
|
229
|
-
handles
|
|
230
|
-
} = data;
|
|
231
|
-
const rotation = data.initialRotation || 0;
|
|
232
|
-
let top, bottom, left, right;
|
|
233
|
-
if (rotation == 90 || rotation == 270) {
|
|
234
|
-
bottom = handles.points[2];
|
|
235
|
-
top = handles.points[3];
|
|
236
|
-
left = handles.points[0];
|
|
237
|
-
right = handles.points[1];
|
|
238
|
-
} else {
|
|
239
|
-
top = handles.points[0];
|
|
240
|
-
bottom = handles.points[1];
|
|
241
|
-
left = handles.points[2];
|
|
242
|
-
right = handles.points[3];
|
|
243
|
-
}
|
|
244
|
-
const topBottomLength = Math.sqrt((top[0] - bottom[0]) ** 2 + (top[1] - bottom[1]) ** 2 + (top[2] - bottom[2]) ** 2);
|
|
245
|
-
const leftRightLength = Math.sqrt((left[0] - right[0]) ** 2 + (left[1] - right[1]) ** 2 + (left[2] - right[2]) ** 2);
|
|
246
|
-
const points = [];
|
|
247
|
-
if (topBottomLength > leftRightLength) {
|
|
248
|
-
points.push({
|
|
249
|
-
x: top[0],
|
|
250
|
-
y: top[1],
|
|
251
|
-
z: top[2]
|
|
252
|
-
});
|
|
253
|
-
points.push({
|
|
254
|
-
x: bottom[0],
|
|
255
|
-
y: bottom[1],
|
|
256
|
-
z: bottom[2]
|
|
257
|
-
});
|
|
258
|
-
points.push({
|
|
259
|
-
x: left[0],
|
|
260
|
-
y: left[1],
|
|
261
|
-
z: left[2]
|
|
262
|
-
});
|
|
263
|
-
points.push({
|
|
264
|
-
x: right[0],
|
|
265
|
-
y: right[1],
|
|
266
|
-
z: right[2]
|
|
267
|
-
});
|
|
268
|
-
} else {
|
|
269
|
-
points.push({
|
|
270
|
-
x: left[0],
|
|
271
|
-
y: left[1],
|
|
272
|
-
z: left[2]
|
|
273
|
-
});
|
|
274
|
-
points.push({
|
|
275
|
-
x: right[0],
|
|
276
|
-
y: right[1],
|
|
277
|
-
z: right[2]
|
|
278
|
-
});
|
|
279
|
-
points.push({
|
|
280
|
-
x: top[0],
|
|
281
|
-
y: top[1],
|
|
282
|
-
z: top[2]
|
|
283
|
-
});
|
|
284
|
-
points.push({
|
|
285
|
-
x: bottom[0],
|
|
286
|
-
y: bottom[1],
|
|
287
|
-
z: bottom[2]
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
const cachedStatsKeys = Object.keys(cachedStats)[0];
|
|
291
|
-
const {
|
|
292
|
-
area = undefined
|
|
293
|
-
} = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
|
|
294
|
-
return {
|
|
295
|
-
area,
|
|
296
|
-
points,
|
|
297
|
-
trackingIdentifierTextValue: this.trackingIdentifierTextValue,
|
|
298
|
-
finding,
|
|
299
|
-
findingSites: findingSites || [],
|
|
300
|
-
ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
|
|
301
|
-
use3DSpatialCoordinates: true
|
|
149
|
+
ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
|
|
150
|
+
use3DSpatialCoordinates: is3DMeasurement
|
|
302
151
|
};
|
|
303
152
|
}
|
|
304
153
|
}
|
|
@@ -4,22 +4,20 @@ export default class KeyImage extends Probe {
|
|
|
4
4
|
static trackingPointIdentifier: string;
|
|
5
5
|
static trackingSeriesPointIdentifier: string;
|
|
6
6
|
static getMeasurementData(measurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any, trackingIdentifier: any): any;
|
|
7
|
-
static getTID300RepresentationArguments(tool: any
|
|
8
|
-
points: {
|
|
7
|
+
static getTID300RepresentationArguments(tool: any): {
|
|
8
|
+
points: ({
|
|
9
9
|
x: any;
|
|
10
10
|
y: any;
|
|
11
11
|
z: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
use3DSpatialCoordinates: boolean;
|
|
18
|
-
} | {
|
|
19
|
-
points: any;
|
|
12
|
+
} | {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
z?: undefined;
|
|
16
|
+
})[];
|
|
20
17
|
trackingIdentifierTextValue: string;
|
|
21
18
|
findingSites: any;
|
|
22
19
|
finding: any;
|
|
20
|
+
ReferencedFrameOfReferenceUID: any;
|
|
23
21
|
use3DSpatialCoordinates: boolean;
|
|
24
22
|
};
|
|
25
23
|
}
|
|
@@ -14,8 +14,8 @@ class KeyImage extends Probe {
|
|
|
14
14
|
data.isPoint = trackingIdentifier.indexOf("Point") !== -1;
|
|
15
15
|
return baseData;
|
|
16
16
|
}
|
|
17
|
-
static getTID300RepresentationArguments(tool
|
|
18
|
-
const tid300Arguments = super.getTID300RepresentationArguments(tool
|
|
17
|
+
static getTID300RepresentationArguments(tool) {
|
|
18
|
+
const tid300Arguments = super.getTID300RepresentationArguments(tool);
|
|
19
19
|
const {
|
|
20
20
|
data
|
|
21
21
|
} = tool;
|
|
@@ -1,59 +1,30 @@
|
|
|
1
1
|
import BaseAdapter3D from "./BaseAdapter3D";
|
|
2
2
|
export default class Length extends BaseAdapter3D {
|
|
3
|
-
static
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}): any;
|
|
10
|
-
static getMeasurementDataFromScoord3d({ defaultState, SCOORD3DGroup }: {
|
|
11
|
-
defaultState: any;
|
|
12
|
-
SCOORD3DGroup: any;
|
|
13
|
-
}): any;
|
|
14
|
-
static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any): any;
|
|
15
|
-
static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
|
|
16
|
-
point1: {
|
|
17
|
-
x: any;
|
|
18
|
-
y: any;
|
|
19
|
-
z: any;
|
|
20
|
-
};
|
|
21
|
-
point2: {
|
|
22
|
-
x: any;
|
|
23
|
-
y: any;
|
|
24
|
-
z: any;
|
|
25
|
-
};
|
|
26
|
-
distance: any;
|
|
27
|
-
trackingIdentifierTextValue: string;
|
|
28
|
-
finding: any;
|
|
29
|
-
findingSites: any;
|
|
30
|
-
ReferencedFrameOfReferenceUID: any;
|
|
31
|
-
use3DSpatialCoordinates: boolean;
|
|
32
|
-
} | {
|
|
33
|
-
point1: {
|
|
34
|
-
x: any;
|
|
35
|
-
y: any;
|
|
36
|
-
};
|
|
37
|
-
point2: {
|
|
38
|
-
x: any;
|
|
39
|
-
y: any;
|
|
40
|
-
};
|
|
41
|
-
distance: any;
|
|
42
|
-
trackingIdentifierTextValue: string;
|
|
43
|
-
finding: any;
|
|
44
|
-
findingSites: any;
|
|
45
|
-
use3DSpatialCoordinates: boolean;
|
|
3
|
+
static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, metadata: any): {
|
|
4
|
+
description?: string;
|
|
5
|
+
sopInstanceUid?: string;
|
|
6
|
+
annotation: import("packages/tools/dist/esm/types").Annotation;
|
|
7
|
+
finding?: unknown;
|
|
8
|
+
findingSites?: unknown;
|
|
46
9
|
};
|
|
47
|
-
static
|
|
10
|
+
static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
|
|
48
11
|
point1: {
|
|
49
12
|
x: any;
|
|
50
13
|
y: any;
|
|
51
14
|
z: any;
|
|
15
|
+
} | {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
z?: undefined;
|
|
52
19
|
};
|
|
53
20
|
point2: {
|
|
54
21
|
x: any;
|
|
55
22
|
y: any;
|
|
56
23
|
z: any;
|
|
24
|
+
} | {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
z?: undefined;
|
|
57
28
|
};
|
|
58
29
|
distance: any;
|
|
59
30
|
trackingIdentifierTextValue: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { utilities } from 'dcmjs';
|
|
2
2
|
import MeasurementReport from './MeasurementReport.js';
|
|
3
3
|
import BaseAdapter3D from './BaseAdapter3D.js';
|
|
4
|
+
import 'buffer';
|
|
5
|
+
import { toScoord } from '../helpers/toScoordType.js';
|
|
6
|
+
import '@cornerstonejs/core';
|
|
4
7
|
|
|
5
8
|
var _Length;
|
|
6
9
|
const {
|
|
@@ -8,25 +11,23 @@ const {
|
|
|
8
11
|
} = utilities.TID300;
|
|
9
12
|
const LENGTH = "Length";
|
|
10
13
|
class Length extends BaseAdapter3D {
|
|
11
|
-
static
|
|
12
|
-
let {
|
|
13
|
-
defaultState,
|
|
14
|
-
NUMGroup,
|
|
15
|
-
SCOORDGroup,
|
|
16
|
-
ReferencedFrameNumber,
|
|
17
|
-
imageToWorldCoords
|
|
18
|
-
} = _ref;
|
|
19
|
-
const referencedImageId = defaultState.annotation.metadata.referencedImageId;
|
|
14
|
+
static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
|
|
20
15
|
const {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
state,
|
|
17
|
+
NUMGroup,
|
|
18
|
+
scoord,
|
|
19
|
+
scoordArgs,
|
|
20
|
+
worldCoords,
|
|
21
|
+
referencedImageId,
|
|
22
|
+
ReferencedFrameNumber
|
|
23
|
+
} = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
|
|
24
|
+
const cachedStats = referencedImageId ? {
|
|
25
|
+
[`imageId:${referencedImageId}`]: {
|
|
26
|
+
length: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0
|
|
27
|
+
}
|
|
28
|
+
} : {};
|
|
29
29
|
state.annotation.data = {
|
|
30
|
+
...state.annotation.data,
|
|
30
31
|
handles: {
|
|
31
32
|
points: [worldCoords[0], worldCoords[1]],
|
|
32
33
|
activeHandleIndex: 0,
|
|
@@ -34,63 +35,13 @@ class Length extends BaseAdapter3D {
|
|
|
34
35
|
hasMoved: false
|
|
35
36
|
}
|
|
36
37
|
},
|
|
37
|
-
cachedStats
|
|
38
|
-
[`imageId:${referencedImageId}`]: {
|
|
39
|
-
length: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0
|
|
40
|
-
}
|
|
41
|
-
},
|
|
38
|
+
cachedStats,
|
|
42
39
|
frameNumber: ReferencedFrameNumber
|
|
43
40
|
};
|
|
44
41
|
return state;
|
|
45
42
|
}
|
|
46
|
-
static
|
|
47
|
-
let
|
|
48
|
-
defaultState,
|
|
49
|
-
SCOORD3DGroup
|
|
50
|
-
} = _ref2;
|
|
51
|
-
const {
|
|
52
|
-
GraphicData
|
|
53
|
-
} = SCOORD3DGroup;
|
|
54
|
-
const worldCoords = GraphicData;
|
|
55
|
-
const state = defaultState;
|
|
56
|
-
state.annotation.data = {
|
|
57
|
-
handles: {
|
|
58
|
-
points: [worldCoords.slice(0, 3), worldCoords.slice(3, 6)],
|
|
59
|
-
activeHandleIndex: 0,
|
|
60
|
-
textBox: {
|
|
61
|
-
hasMoved: false
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
cachedStats: {}
|
|
65
|
-
};
|
|
66
|
-
return state;
|
|
67
|
-
}
|
|
68
|
-
static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
|
|
69
|
-
const {
|
|
70
|
-
defaultState,
|
|
71
|
-
NUMGroup,
|
|
72
|
-
SCOORDGroup,
|
|
73
|
-
SCOORD3DGroup,
|
|
74
|
-
ReferencedFrameNumber
|
|
75
|
-
} = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
|
|
76
|
-
if (SCOORDGroup) {
|
|
77
|
-
return this.getMeasurementDataFromScoord({
|
|
78
|
-
defaultState,
|
|
79
|
-
NUMGroup,
|
|
80
|
-
SCOORDGroup,
|
|
81
|
-
ReferencedFrameNumber,
|
|
82
|
-
imageToWorldCoords
|
|
83
|
-
});
|
|
84
|
-
} else if (SCOORD3DGroup) {
|
|
85
|
-
return this.getMeasurementDataFromScoord3d({
|
|
86
|
-
defaultState,
|
|
87
|
-
SCOORD3DGroup
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
90
|
-
throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
static getTID300RepresentationArguments(tool, worldToImageCoords) {
|
|
43
|
+
static getTID300RepresentationArguments(tool) {
|
|
44
|
+
let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
94
45
|
const {
|
|
95
46
|
data,
|
|
96
47
|
finding,
|
|
@@ -104,19 +55,12 @@ class Length extends BaseAdapter3D {
|
|
|
104
55
|
const {
|
|
105
56
|
referencedImageId
|
|
106
57
|
} = metadata;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const start = worldToImageCoords(referencedImageId, handles.points[0]);
|
|
111
|
-
const end = worldToImageCoords(referencedImageId, handles.points[1]);
|
|
112
|
-
const point1 = {
|
|
113
|
-
x: start[0],
|
|
114
|
-
y: start[1]
|
|
115
|
-
};
|
|
116
|
-
const point2 = {
|
|
117
|
-
x: end[0],
|
|
118
|
-
y: end[1]
|
|
58
|
+
const scoordProps = {
|
|
59
|
+
is3DMeasurement,
|
|
60
|
+
referencedImageId
|
|
119
61
|
};
|
|
62
|
+
const point1 = toScoord(scoordProps, handles.points[0]);
|
|
63
|
+
const point2 = toScoord(scoordProps, handles.points[1]);
|
|
120
64
|
const {
|
|
121
65
|
length: distance
|
|
122
66
|
} = cachedStats[`imageId:${referencedImageId}`] || {};
|
|
@@ -127,45 +71,8 @@ class Length extends BaseAdapter3D {
|
|
|
127
71
|
trackingIdentifierTextValue: this.trackingIdentifierTextValue,
|
|
128
72
|
finding,
|
|
129
73
|
findingSites: findingSites || [],
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
static getTID300RepresentationArgumentsSCOORD3D(tool) {
|
|
134
|
-
const {
|
|
135
|
-
data,
|
|
136
|
-
finding,
|
|
137
|
-
findingSites,
|
|
138
|
-
metadata
|
|
139
|
-
} = tool;
|
|
140
|
-
const {
|
|
141
|
-
cachedStats = {},
|
|
142
|
-
handles
|
|
143
|
-
} = data;
|
|
144
|
-
const start = handles.points[0];
|
|
145
|
-
const end = handles.points[1];
|
|
146
|
-
const point1 = {
|
|
147
|
-
x: start[0],
|
|
148
|
-
y: start[1],
|
|
149
|
-
z: start[2]
|
|
150
|
-
};
|
|
151
|
-
const point2 = {
|
|
152
|
-
x: end[0],
|
|
153
|
-
y: end[1],
|
|
154
|
-
z: end[2]
|
|
155
|
-
};
|
|
156
|
-
const cachedStatsKeys = Object.keys(cachedStats)[0];
|
|
157
|
-
const {
|
|
158
|
-
length: distance = undefined
|
|
159
|
-
} = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
|
|
160
|
-
return {
|
|
161
|
-
point1,
|
|
162
|
-
point2,
|
|
163
|
-
distance,
|
|
164
|
-
trackingIdentifierTextValue: this.trackingIdentifierTextValue,
|
|
165
|
-
finding,
|
|
166
|
-
findingSites: findingSites || [],
|
|
167
|
-
ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
|
|
168
|
-
use3DSpatialCoordinates: true
|
|
74
|
+
ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
|
|
75
|
+
use3DSpatialCoordinates: is3DMeasurement
|
|
169
76
|
};
|
|
170
77
|
}
|
|
171
78
|
}
|