@cornerstonejs/adapters 3.30.3 → 3.31.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.
Files changed (41) hide show
  1. package/dist/esm/adapters/Cornerstone/Bidirectional.js +1 -0
  2. package/dist/esm/adapters/Cornerstone/MeasurementReport.js +1 -0
  3. package/dist/esm/adapters/Cornerstone3D/Angle.d.ts +23 -62
  4. package/dist/esm/adapters/Cornerstone3D/Angle.js +29 -141
  5. package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.d.ts +13 -27
  6. package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.js +26 -144
  7. package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.d.ts +2 -12
  8. package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.js +13 -42
  9. package/dist/esm/adapters/Cornerstone3D/Bidirectional.d.ts +23 -80
  10. package/dist/esm/adapters/Cornerstone3D/Bidirectional.js +33 -167
  11. package/dist/esm/adapters/Cornerstone3D/CircleROI.d.ts +16 -33
  12. package/dist/esm/adapters/Cornerstone3D/CircleROI.js +28 -129
  13. package/dist/esm/adapters/Cornerstone3D/CobbAngle.d.ts +23 -62
  14. package/dist/esm/adapters/Cornerstone3D/CobbAngle.js +22 -144
  15. package/dist/esm/adapters/Cornerstone3D/EllipticalROI.d.ts +7 -29
  16. package/dist/esm/adapters/Cornerstone3D/EllipticalROI.js +25 -176
  17. package/dist/esm/adapters/Cornerstone3D/KeyImage.d.ts +8 -10
  18. package/dist/esm/adapters/Cornerstone3D/KeyImage.js +2 -2
  19. package/dist/esm/adapters/Cornerstone3D/Length.d.ts +15 -44
  20. package/dist/esm/adapters/Cornerstone3D/Length.js +28 -121
  21. package/dist/esm/adapters/Cornerstone3D/MeasurementReport.d.ts +57 -38
  22. package/dist/esm/adapters/Cornerstone3D/MeasurementReport.js +66 -30
  23. package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.d.ts +16 -41
  24. package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.js +25 -132
  25. package/dist/esm/adapters/Cornerstone3D/Probe.d.ts +7 -21
  26. package/dist/esm/adapters/Cornerstone3D/Probe.js +12 -39
  27. package/dist/esm/adapters/Cornerstone3D/RectangleROI.d.ts +1 -1
  28. package/dist/esm/adapters/Cornerstone3D/RectangleROI.js +7 -2
  29. package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.d.ts +6 -15
  30. package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.js +6 -2
  31. package/dist/esm/adapters/helpers/index.d.ts +3 -0
  32. package/dist/esm/adapters/helpers/index.js +3 -0
  33. package/dist/esm/adapters/helpers/scoordToWorld.d.ts +5 -0
  34. package/dist/esm/adapters/helpers/scoordToWorld.js +32 -0
  35. package/dist/esm/adapters/helpers/toPoint3.d.ts +3 -0
  36. package/dist/esm/adapters/helpers/toPoint3.js +18 -0
  37. package/dist/esm/adapters/helpers/toScoordType.d.ts +23 -0
  38. package/dist/esm/adapters/helpers/toScoordType.js +33 -0
  39. package/dist/esm/adapters/index.js +1 -0
  40. package/dist/esm/version.d.ts +1 -1
  41. package/package.json +5 -5
@@ -1,5 +1,9 @@
1
1
  import CORNERSTONE_3D_TAG from './cornerstone3DTag.js';
2
2
  import MeasurementReport from './MeasurementReport.js';
3
+ import 'dcmjs';
4
+ import 'buffer';
5
+ import { toScoords } from '../helpers/toScoordType.js';
6
+ import '@cornerstonejs/core';
3
7
 
4
8
  class BaseAdapter3D {
5
9
  static init(toolType, representation, options) {
@@ -52,9 +56,9 @@ class BaseAdapter3D {
52
56
  };
53
57
  return state;
54
58
  }
55
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
59
+ static getTID300RepresentationArguments(tool) {
60
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
56
61
  const {
57
- data,
58
62
  metadata
59
63
  } = tool;
60
64
  const {
@@ -64,52 +68,19 @@ class BaseAdapter3D {
64
68
  const {
65
69
  referencedImageId
66
70
  } = metadata;
67
- if (!referencedImageId) {
68
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
69
- }
70
- const {
71
- handles: {
72
- points = []
73
- }
74
- } = data;
75
- const pointsImage = points.map(point => {
76
- const pointImage = worldToImageCoords(referencedImageId, point);
77
- return {
78
- x: pointImage[0],
79
- y: pointImage[1]
80
- };
81
- });
71
+ const scoordProps = {
72
+ is3DMeasurement,
73
+ referencedImageId
74
+ };
75
+ const pointsImage = toScoords(scoordProps, tool.data.handles.points);
82
76
  const tidArguments = {
83
77
  points: pointsImage,
84
78
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
85
79
  findingSites: findingSites || [],
86
- finding
87
- };
88
- return tidArguments;
89
- }
90
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
91
- const {
92
- data,
93
80
  finding,
94
- findingSites
95
- } = tool;
96
- const {
97
- handles: {
98
- points = []
99
- }
100
- } = data;
101
- const point = points[0];
102
- const pointXYZ = {
103
- x: point[0],
104
- y: point[1],
105
- z: point[2]
106
- };
107
- return {
108
- points: [pointXYZ],
109
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
110
- findingSites: findingSites || [],
111
- finding
81
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null
112
82
  };
83
+ return tidArguments;
113
84
  }
114
85
  }
115
86
 
@@ -1,96 +1,31 @@
1
1
  import BaseAdapter3D from "./BaseAdapter3D";
2
2
  declare class Bidirectional extends BaseAdapter3D {
3
- static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any): any;
4
- static getMeasurementDataFromScoord({ longAxisNUMGroup, shortAxisNUMGroup, longAxisSCOORDGroup, shortAxisSCOORDGroup, referencedImageId, imageToWorldCoords, ReferencedFrameNumber, defaultState }: {
5
- longAxisNUMGroup: any;
6
- shortAxisNUMGroup: any;
7
- longAxisSCOORDGroup: any;
8
- shortAxisSCOORDGroup: any;
9
- referencedImageId: any;
10
- imageToWorldCoords: any;
11
- ReferencedFrameNumber: any;
12
- defaultState: any;
13
- }): any;
14
- static getMeasurementDataFromScoord3d({ longAxisNUMGroup, shortAxisNUMGroup, defaultState }: {
15
- longAxisNUMGroup: any;
16
- shortAxisNUMGroup: any;
17
- defaultState: any;
18
- }): any;
19
- static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
20
- longAxis: {
21
- point1: {
22
- x: any;
23
- y: any;
24
- z: any;
25
- };
26
- point2: {
27
- x: any;
28
- y: any;
29
- z: any;
30
- };
31
- };
32
- shortAxis: {
33
- point1: {
34
- x: any;
35
- y: any;
36
- z: any;
37
- };
38
- point2: {
39
- x: any;
40
- y: any;
41
- z: any;
42
- };
43
- };
44
- longAxisLength: any;
45
- shortAxisLength: any;
46
- trackingIdentifierTextValue: string;
47
- finding: any;
48
- findingSites: any;
49
- ReferencedFrameOfReferenceUID: any;
50
- use3DSpatialCoordinates: boolean;
51
- } | {
52
- longAxis: {
53
- point1: {
54
- x: any;
55
- y: any;
56
- };
57
- point2: {
58
- x: any;
59
- y: any;
60
- };
61
- };
62
- shortAxis: {
63
- point1: {
64
- x: any;
65
- y: any;
66
- };
67
- point2: {
68
- x: any;
69
- y: any;
70
- };
71
- };
72
- longAxisLength: any;
73
- shortAxisLength: any;
74
- trackingIdentifierTextValue: string;
75
- finding: any;
76
- findingSites: any;
77
- 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;
78
9
  };
79
- static getTID300RepresentationArgumentsSCOORD3D({ tool, shortAxisPoints, longAxisPoints }: {
80
- tool: any;
81
- shortAxisPoints: any;
82
- longAxisPoints: any;
83
- }): {
10
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
84
11
  longAxis: {
85
12
  point1: {
86
13
  x: any;
87
14
  y: any;
88
15
  z: any;
16
+ } | {
17
+ x: number;
18
+ y: number;
19
+ z?: undefined;
89
20
  };
90
21
  point2: {
91
22
  x: any;
92
23
  y: any;
93
24
  z: any;
25
+ } | {
26
+ x: number;
27
+ y: number;
28
+ z?: undefined;
94
29
  };
95
30
  };
96
31
  shortAxis: {
@@ -98,11 +33,19 @@ declare class Bidirectional extends BaseAdapter3D {
98
33
  x: any;
99
34
  y: any;
100
35
  z: any;
36
+ } | {
37
+ x: number;
38
+ y: number;
39
+ z?: undefined;
101
40
  };
102
41
  point2: {
103
42
  x: any;
104
43
  y: any;
105
44
  z: any;
45
+ } | {
46
+ x: number;
47
+ y: number;
48
+ z?: undefined;
106
49
  };
107
50
  };
108
51
  longAxisLength: any;
@@ -2,6 +2,8 @@ import { utilities } from 'dcmjs';
2
2
  import MeasurementReport from './MeasurementReport.js';
3
3
  import { toArray } from '../helpers/toArray.js';
4
4
  import 'buffer';
5
+ import { toScoord } from '../helpers/toScoordType.js';
6
+ import { scoordToWorld } from '../helpers/scoordToWorld.js';
5
7
  import BaseAdapter3D from './BaseAdapter3D.js';
6
8
 
7
9
  var _Bidirectional;
@@ -11,61 +13,25 @@ const {
11
13
  const LONG_AXIS = "Long Axis";
12
14
  const SHORT_AXIS = "Short Axis";
13
15
  class Bidirectional extends BaseAdapter3D {
14
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
16
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
15
17
  const {
16
- defaultState,
18
+ state,
19
+ scoordArgs,
20
+ referencedImageId,
17
21
  ReferencedFrameNumber
18
22
  } = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, Bidirectional.toolType);
19
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
20
23
  const {
21
24
  ContentSequence
22
25
  } = MeasurementGroup;
23
26
  const longAxisNUMGroup = toArray(ContentSequence).find(group => group.ConceptNameCodeSequence.CodeMeaning === LONG_AXIS);
24
27
  const shortAxisNUMGroup = toArray(ContentSequence).find(group => group.ConceptNameCodeSequence.CodeMeaning === SHORT_AXIS);
25
- const longAxisSCOORDGroup = toArray(longAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD");
26
- const shortAxisSCOORDGroup = toArray(shortAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD");
27
- if (longAxisSCOORDGroup && shortAxisSCOORDGroup) {
28
- return this.getMeasurementDataFromScoord({
29
- longAxisNUMGroup,
30
- shortAxisNUMGroup,
31
- longAxisSCOORDGroup,
32
- shortAxisSCOORDGroup,
33
- referencedImageId,
34
- imageToWorldCoords,
35
- ReferencedFrameNumber,
36
- defaultState
37
- });
38
- } else {
39
- return this.getMeasurementDataFromScoord3d({
40
- longAxisNUMGroup,
41
- shortAxisNUMGroup,
42
- defaultState
43
- });
44
- }
45
- }
46
- static getMeasurementDataFromScoord(_ref) {
47
- let {
48
- longAxisNUMGroup,
49
- shortAxisNUMGroup,
50
- longAxisSCOORDGroup,
51
- shortAxisSCOORDGroup,
52
- referencedImageId,
53
- imageToWorldCoords,
54
- ReferencedFrameNumber,
55
- defaultState
56
- } = _ref;
28
+ const longAxisScoordGroup = toArray(longAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D" || group.ValueType === "SCOORD");
29
+ const shortAxisScoordGroup = toArray(shortAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D" || group.ValueType === "SCOORD");
57
30
  const worldCoords = [];
58
- [longAxisSCOORDGroup, shortAxisSCOORDGroup].forEach(group => {
59
- const {
60
- GraphicData
61
- } = group;
62
- for (let i = 0; i < GraphicData.length; i += 2) {
63
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
64
- worldCoords.push(point);
65
- }
66
- });
67
- const state = defaultState;
31
+ worldCoords.push(...scoordToWorld(scoordArgs, longAxisScoordGroup.GraphicData));
32
+ worldCoords.push(...scoordToWorld(scoordArgs, shortAxisScoordGroup.GraphicData));
68
33
  state.annotation.data = {
34
+ ...state.annotation.data,
69
35
  handles: {
70
36
  points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
71
37
  activeHandleIndex: 0,
@@ -73,48 +39,20 @@ class Bidirectional extends BaseAdapter3D {
73
39
  hasMoved: false
74
40
  }
75
41
  },
76
- cachedStats: {
42
+ frameNumber: ReferencedFrameNumber
43
+ };
44
+ if (referencedImageId) {
45
+ state.annotation.data.cachedStats = {
77
46
  [`imageId:${referencedImageId}`]: {
78
47
  length: longAxisNUMGroup.MeasuredValueSequence.NumericValue,
79
48
  width: shortAxisNUMGroup.MeasuredValueSequence.NumericValue
80
49
  }
81
- },
82
- frameNumber: ReferencedFrameNumber
83
- };
84
- return state;
85
- }
86
- static getMeasurementDataFromScoord3d(_ref2) {
87
- let {
88
- longAxisNUMGroup,
89
- shortAxisNUMGroup,
90
- defaultState
91
- } = _ref2;
92
- const worldCoords = [];
93
- const longAxisSCOORD3DGroup = toArray(longAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D");
94
- const shortAxisSCOORD3DGroup = toArray(shortAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D");
95
- [longAxisSCOORD3DGroup, shortAxisSCOORD3DGroup].forEach(group => {
96
- const {
97
- GraphicData
98
- } = group;
99
- for (let i = 0; i < GraphicData.length; i += 3) {
100
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
101
- worldCoords.push(point);
102
- }
103
- });
104
- const state = defaultState;
105
- state.annotation.data = {
106
- handles: {
107
- points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
108
- activeHandleIndex: 0,
109
- textBox: {
110
- hasMoved: false
111
- }
112
- },
113
- cachedStats: {}
114
- };
50
+ };
51
+ }
115
52
  return state;
116
53
  }
117
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
54
+ static getTID300RepresentationArguments(tool) {
55
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
118
56
  const {
119
57
  data,
120
58
  finding,
@@ -128,6 +66,10 @@ class Bidirectional extends BaseAdapter3D {
128
66
  const {
129
67
  referencedImageId
130
68
  } = metadata;
69
+ const scoordProps = {
70
+ is3DMeasurement,
71
+ referencedImageId
72
+ };
131
73
  const {
132
74
  points
133
75
  } = handles;
@@ -144,106 +86,30 @@ class Bidirectional extends BaseAdapter3D {
144
86
  shortAxisPoints = secondPointPairs;
145
87
  longAxisPoints = firstPointPairs;
146
88
  }
147
- if (!referencedImageId) {
148
- return this.getTID300RepresentationArgumentsSCOORD3D({
149
- tool,
150
- shortAxisPoints,
151
- longAxisPoints
152
- });
153
- }
154
- const longAxisStartImage = worldToImageCoords(referencedImageId, shortAxisPoints[0]);
155
- const longAxisEndImage = worldToImageCoords(referencedImageId, shortAxisPoints[1]);
156
- const shortAxisStartImage = worldToImageCoords(referencedImageId, longAxisPoints[0]);
157
- const shortAxisEndImage = worldToImageCoords(referencedImageId, longAxisPoints[1]);
89
+ const longAxisStartImage = toScoord(scoordProps, shortAxisPoints[0]);
90
+ const longAxisEndImage = toScoord(scoordProps, shortAxisPoints[1]);
91
+ const shortAxisStartImage = toScoord(scoordProps, longAxisPoints[0]);
92
+ const shortAxisEndImage = toScoord(scoordProps, longAxisPoints[1]);
158
93
  const {
159
94
  length,
160
95
  width
161
96
  } = cachedStats[`imageId:${referencedImageId}`] || {};
162
97
  return {
163
98
  longAxis: {
164
- point1: {
165
- x: longAxisStartImage[0],
166
- y: longAxisStartImage[1]
167
- },
168
- point2: {
169
- x: longAxisEndImage[0],
170
- y: longAxisEndImage[1]
171
- }
99
+ point1: longAxisStartImage,
100
+ point2: longAxisEndImage
172
101
  },
173
102
  shortAxis: {
174
- point1: {
175
- x: shortAxisStartImage[0],
176
- y: shortAxisStartImage[1]
177
- },
178
- point2: {
179
- x: shortAxisEndImage[0],
180
- y: shortAxisEndImage[1]
181
- }
182
- },
183
- longAxisLength: length,
184
- shortAxisLength: width,
185
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
186
- finding: finding,
187
- findingSites: findingSites || [],
188
- use3DSpatialCoordinates: false
189
- };
190
- }
191
- static getTID300RepresentationArgumentsSCOORD3D(_ref3) {
192
- let {
193
- tool,
194
- shortAxisPoints,
195
- longAxisPoints
196
- } = _ref3;
197
- const {
198
- data,
199
- finding,
200
- findingSites,
201
- metadata
202
- } = tool;
203
- const {
204
- cachedStats = {}
205
- } = data;
206
- const longAxisStart = shortAxisPoints[0];
207
- const longAxisEnd = shortAxisPoints[1];
208
- const shortAxisStart = longAxisPoints[0];
209
- const shortAxisEnd = longAxisPoints[1];
210
- const cachedStatsKeys = Object.keys(cachedStats)[0];
211
- const {
212
- length = undefined,
213
- width = undefined
214
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
215
- return {
216
- longAxis: {
217
- point1: {
218
- x: longAxisStart[0],
219
- y: longAxisStart[1],
220
- z: longAxisStart[2]
221
- },
222
- point2: {
223
- x: longAxisEnd[0],
224
- y: longAxisEnd[1],
225
- z: longAxisEnd[2]
226
- }
227
- },
228
- shortAxis: {
229
- point1: {
230
- x: shortAxisStart[0],
231
- y: shortAxisStart[1],
232
- z: shortAxisStart[2]
233
- },
234
- point2: {
235
- x: shortAxisEnd[0],
236
- y: shortAxisEnd[1],
237
- z: shortAxisEnd[2]
238
- }
103
+ point1: shortAxisStartImage,
104
+ point2: shortAxisEndImage
239
105
  },
240
106
  longAxisLength: length,
241
107
  shortAxisLength: width,
242
108
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
243
109
  finding: finding,
244
110
  findingSites: findingSites || [],
245
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
246
- use3DSpatialCoordinates: true
111
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
112
+ use3DSpatialCoordinates: is3DMeasurement
247
113
  };
248
114
  }
249
115
  }
@@ -1,42 +1,25 @@
1
1
  import BaseAdapter3D from "./BaseAdapter3D";
2
2
  declare class CircleROI extends BaseAdapter3D {
3
- static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any): any;
4
- static getMeasurementDataFromScoord({ defaultState, SCOORDGroup, imageToWorldCoords, NUMGroup, ReferencedFrameNumber }: {
5
- defaultState: any;
6
- SCOORDGroup: any;
7
- imageToWorldCoords: any;
8
- NUMGroup: any;
9
- ReferencedFrameNumber: any;
10
- }): any;
11
- static getMeasurementDataFromScoord3D({ defaultState, SCOORD3DGroup }: {
12
- defaultState: any;
13
- SCOORD3DGroup: any;
14
- }): any;
15
- static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
16
- area: any;
17
- perimeter: number;
18
- radius: any;
19
- points: any[];
20
- trackingIdentifierTextValue: string;
21
- finding: any;
22
- findingSites: any;
23
- ReferencedFrameOfReferenceUID: any;
24
- use3DSpatialCoordinates: boolean;
25
- } | {
26
- area: any;
27
- perimeter: number;
28
- radius: any;
29
- points: any[];
30
- trackingIdentifierTextValue: string;
31
- finding: any;
32
- findingSites: any;
33
- 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;
34
9
  };
35
- static getTID300RepresentationArgumentsSCOORD3D(tool: any): {
10
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
36
11
  area: any;
37
12
  perimeter: number;
38
13
  radius: any;
39
- points: any[];
14
+ points: ({
15
+ x: any;
16
+ y: any;
17
+ z: any;
18
+ } | {
19
+ x: number;
20
+ y: number;
21
+ z?: undefined;
22
+ })[];
40
23
  trackingIdentifierTextValue: string;
41
24
  finding: any;
42
25
  findingSites: any;