@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.
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,101 +1,49 @@
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 _CircleROI;
6
9
  const {
7
10
  Circle: TID300Circle
8
11
  } = utilities.TID300;
9
12
  class CircleROI extends BaseAdapter3D {
10
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
13
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
11
14
  const {
12
- defaultState,
15
+ state,
13
16
  NUMGroup,
14
- SCOORDGroup,
15
- SCOORD3DGroup,
17
+ scoord,
18
+ scoordArgs,
19
+ worldCoords,
20
+ referencedImageId,
16
21
  ReferencedFrameNumber
17
- } = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, CircleROI.toolType);
18
- if (SCOORDGroup) {
19
- return this.getMeasurementDataFromScoord({
20
- defaultState,
21
- SCOORDGroup,
22
- imageToWorldCoords,
23
- NUMGroup,
24
- ReferencedFrameNumber
25
- });
26
- } else if (SCOORD3DGroup) {
27
- return this.getMeasurementDataFromScoord3D({
28
- defaultState,
29
- SCOORD3DGroup
30
- });
31
- } else {
32
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
33
- }
34
- }
35
- static getMeasurementDataFromScoord(_ref) {
36
- let {
37
- defaultState,
38
- SCOORDGroup,
39
- imageToWorldCoords,
40
- NUMGroup,
41
- ReferencedFrameNumber
42
- } = _ref;
43
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
44
- const {
45
- GraphicData
46
- } = SCOORDGroup;
47
- const pointsWorld = [];
48
- for (let i = 0; i < GraphicData.length; i += 2) {
49
- const worldPos = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
50
- pointsWorld.push(worldPos);
51
- }
52
- const state = defaultState;
22
+ } = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
53
23
  state.annotation.data = {
24
+ ...state.annotation.data,
54
25
  handles: {
55
- points: [...pointsWorld],
26
+ points: worldCoords,
56
27
  activeHandleIndex: 0,
57
28
  textBox: {
58
29
  hasMoved: false
59
30
  }
60
31
  },
61
- cachedStats: {
32
+ frameNumber: ReferencedFrameNumber
33
+ };
34
+ if (referencedImageId) {
35
+ state.annotation.data.cachedStats = {
62
36
  [`imageId:${referencedImageId}`]: {
63
37
  area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0,
64
38
  radius: 0,
65
39
  perimeter: 0
66
40
  }
67
- },
68
- frameNumber: ReferencedFrameNumber
69
- };
70
- return state;
71
- }
72
- static getMeasurementDataFromScoord3D(_ref2) {
73
- let {
74
- defaultState,
75
- SCOORD3DGroup
76
- } = _ref2;
77
- const {
78
- GraphicData
79
- } = SCOORD3DGroup;
80
- const pointsWorld = [];
81
- for (let i = 0; i < GraphicData.length; i += 3) {
82
- const worldPos = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
83
- pointsWorld.push(worldPos);
41
+ };
84
42
  }
85
- const state = defaultState;
86
- state.annotation.data = {
87
- handles: {
88
- points: [...pointsWorld],
89
- activeHandleIndex: 0,
90
- textBox: {
91
- hasMoved: false
92
- }
93
- },
94
- cachedStats: {}
95
- };
96
43
  return state;
97
44
  }
98
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
45
+ static getTID300RepresentationArguments(tool) {
46
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
99
47
  const {
100
48
  data,
101
49
  finding,
@@ -109,20 +57,12 @@ class CircleROI extends BaseAdapter3D {
109
57
  const {
110
58
  referencedImageId
111
59
  } = metadata;
112
- if (!referencedImageId) {
113
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
114
- }
115
- const center = worldToImageCoords(referencedImageId, handles.points[0]);
116
- const end = worldToImageCoords(referencedImageId, handles.points[1]);
117
- const points = [];
118
- points.push({
119
- x: center[0],
120
- y: center[1]
121
- });
122
- points.push({
123
- x: end[0],
124
- y: end[1]
125
- });
60
+ const scoordProps = {
61
+ is3DMeasurement,
62
+ referencedImageId
63
+ };
64
+ const center = toScoord(scoordProps, handles.points[0]);
65
+ const end = toScoord(scoordProps, handles.points[1]);
126
66
  const {
127
67
  area,
128
68
  radius
@@ -132,53 +72,12 @@ class CircleROI extends BaseAdapter3D {
132
72
  area,
133
73
  perimeter,
134
74
  radius,
135
- points,
136
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
137
- finding,
138
- findingSites: findingSites || [],
139
- use3DSpatialCoordinates: false
140
- };
141
- }
142
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
143
- const {
144
- data,
145
- finding,
146
- findingSites,
147
- metadata
148
- } = tool;
149
- const {
150
- cachedStats = {},
151
- handles
152
- } = data;
153
- const center = handles.points[0];
154
- const end = handles.points[1];
155
- const points = [];
156
- points.push({
157
- x: center[0],
158
- y: center[1],
159
- z: center[2]
160
- });
161
- points.push({
162
- x: end[0],
163
- y: end[1],
164
- z: center[2]
165
- });
166
- const cachedStatsKeys = Object.keys(cachedStats)[0];
167
- const {
168
- area = undefined,
169
- radius = 0
170
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
171
- const perimeter = 2 * Math.PI * radius;
172
- return {
173
- area,
174
- perimeter,
175
- radius,
176
- points,
75
+ points: [center, end],
177
76
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
178
77
  finding,
179
78
  findingSites: findingSites || [],
180
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
181
- use3DSpatialCoordinates: true
79
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
80
+ use3DSpatialCoordinates: is3DMeasurement
182
81
  };
183
82
  }
184
83
  }
@@ -1,87 +1,48 @@
1
1
  import BaseAdapter3D from "./BaseAdapter3D";
2
2
  declare class CobbAngle 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
- point1: {
17
- x: any;
18
- y: any;
19
- z: any;
20
- };
21
- point2: {
22
- x: any;
23
- y: any;
24
- z: any;
25
- };
26
- point3: {
27
- x: any;
28
- y: any;
29
- z: any;
30
- };
31
- point4: {
32
- x: any;
33
- y: any;
34
- z: any;
35
- };
36
- rAngle: any;
37
- trackingIdentifierTextValue: string;
38
- finding: any;
39
- findingSites: any;
40
- ReferencedFrameOfReferenceUID: any;
41
- use3DSpatialCoordinates: boolean;
42
- } | {
43
- point1: {
44
- x: any;
45
- y: any;
46
- };
47
- point2: {
48
- x: any;
49
- y: any;
50
- };
51
- point3: {
52
- x: any;
53
- y: any;
54
- };
55
- point4: {
56
- x: any;
57
- y: any;
58
- };
59
- rAngle: any;
60
- trackingIdentifierTextValue: string;
61
- finding: any;
62
- findingSites: any;
63
- 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;
64
9
  };
65
- static getTID300RepresentationArgumentsSCOORD3D(tool: any): {
10
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
66
11
  point1: {
67
12
  x: any;
68
13
  y: any;
69
14
  z: any;
15
+ } | {
16
+ x: number;
17
+ y: number;
18
+ z?: undefined;
70
19
  };
71
20
  point2: {
72
21
  x: any;
73
22
  y: any;
74
23
  z: any;
24
+ } | {
25
+ x: number;
26
+ y: number;
27
+ z?: undefined;
75
28
  };
76
29
  point3: {
77
30
  x: any;
78
31
  y: any;
79
32
  z: any;
33
+ } | {
34
+ x: number;
35
+ y: number;
36
+ z?: undefined;
80
37
  };
81
38
  point4: {
82
39
  x: any;
83
40
  y: any;
84
41
  z: any;
42
+ } | {
43
+ x: number;
44
+ y: number;
45
+ z?: undefined;
85
46
  };
86
47
  rAngle: any;
87
48
  trackingIdentifierTextValue: string;
@@ -1,56 +1,25 @@
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 { toScoords } from '../helpers/toScoordType.js';
6
+ import '@cornerstonejs/core';
4
7
 
5
8
  var _CobbAngle;
6
9
  const {
7
10
  CobbAngle: TID300CobbAngle
8
11
  } = utilities.TID300;
9
12
  class CobbAngle extends BaseAdapter3D {
10
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
13
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
11
14
  const {
12
- defaultState,
15
+ state,
13
16
  NUMGroup,
14
- SCOORDGroup,
15
- SCOORD3DGroup,
17
+ referencedImageId,
18
+ worldCoords,
16
19
  ReferencedFrameNumber
17
20
  } = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, CobbAngle.toolType);
18
- if (SCOORDGroup) {
19
- return this.getMeasurementDataFromScoord({
20
- defaultState,
21
- SCOORDGroup,
22
- imageToWorldCoords,
23
- NUMGroup,
24
- ReferencedFrameNumber
25
- });
26
- } else if (SCOORD3DGroup) {
27
- return this.getMeasurementDataFromScoord3D({
28
- defaultState,
29
- SCOORD3DGroup
30
- });
31
- } else {
32
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
33
- }
34
- }
35
- static getMeasurementDataFromScoord(_ref) {
36
- let {
37
- defaultState,
38
- SCOORDGroup,
39
- imageToWorldCoords,
40
- NUMGroup,
41
- ReferencedFrameNumber
42
- } = _ref;
43
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
44
- const {
45
- GraphicData
46
- } = SCOORDGroup;
47
- const worldCoords = [];
48
- for (let i = 0; i < GraphicData.length; i += 2) {
49
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
50
- worldCoords.push(point);
51
- }
52
- const state = defaultState;
53
21
  state.annotation.data = {
22
+ ...state.annotation.data,
54
23
  handles: {
55
24
  points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
56
25
  activeHandleIndex: 0,
@@ -58,42 +27,19 @@ class CobbAngle extends BaseAdapter3D {
58
27
  hasMoved: false
59
28
  }
60
29
  },
61
- cachedStats: {
30
+ frameNumber: ReferencedFrameNumber
31
+ };
32
+ if (referencedImageId) {
33
+ state.annotation.data.cachedStats = {
62
34
  [`imageId:${referencedImageId}`]: {
63
35
  angle: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
64
36
  }
65
- },
66
- frameNumber: ReferencedFrameNumber
67
- };
68
- return state;
69
- }
70
- static getMeasurementDataFromScoord3D(_ref2) {
71
- let {
72
- defaultState,
73
- SCOORD3DGroup
74
- } = _ref2;
75
- const {
76
- GraphicData
77
- } = SCOORD3DGroup;
78
- const worldCoords = [];
79
- for (let i = 0; i < GraphicData.length; i += 3) {
80
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
81
- worldCoords.push(point);
37
+ };
82
38
  }
83
- const state = defaultState;
84
- state.annotation.data = {
85
- handles: {
86
- points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
87
- activeHandleIndex: 0,
88
- textBox: {
89
- hasMoved: false
90
- }
91
- },
92
- cachedStats: {}
93
- };
94
39
  return state;
95
40
  }
96
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
41
+ static getTID300RepresentationArguments(tool) {
42
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
97
43
  const {
98
44
  data,
99
45
  finding,
@@ -107,29 +53,12 @@ class CobbAngle extends BaseAdapter3D {
107
53
  const {
108
54
  referencedImageId
109
55
  } = metadata;
110
- if (!referencedImageId) {
111
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
112
- }
113
- const start1 = worldToImageCoords(referencedImageId, handles.points[0]);
114
- const end1 = worldToImageCoords(referencedImageId, handles.points[1]);
115
- const start2 = worldToImageCoords(referencedImageId, handles.points[2]);
116
- const end2 = worldToImageCoords(referencedImageId, handles.points[3]);
117
- const point1 = {
118
- x: start1[0],
119
- y: start1[1]
120
- };
121
- const point2 = {
122
- x: end1[0],
123
- y: end1[1]
124
- };
125
- const point3 = {
126
- x: start2[0],
127
- y: start2[1]
128
- };
129
- const point4 = {
130
- x: end2[0],
131
- y: end2[1]
56
+ const scoordProps = {
57
+ is3DMeasurement,
58
+ referencedImageId
132
59
  };
60
+ const points = toScoords(scoordProps, handles.points);
61
+ const [point1, point2, point3, point4] = points;
133
62
  const {
134
63
  angle
135
64
  } = cachedStats[`imageId:${referencedImageId}`] || {};
@@ -142,59 +71,8 @@ class CobbAngle extends BaseAdapter3D {
142
71
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
143
72
  finding,
144
73
  findingSites: findingSites || [],
145
- use3DSpatialCoordinates: false
146
- };
147
- }
148
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
149
- const {
150
- data,
151
- finding,
152
- findingSites,
153
- metadata
154
- } = tool;
155
- const {
156
- cachedStats = {},
157
- handles
158
- } = data;
159
- const start1 = handles.points[0];
160
- const end1 = handles.points[1];
161
- const start2 = handles.points[2];
162
- const end2 = handles.points[3];
163
- const point1 = {
164
- x: start1[0],
165
- y: start1[1],
166
- z: start1[2]
167
- };
168
- const point2 = {
169
- x: end1[0],
170
- y: end1[1],
171
- z: end1[2]
172
- };
173
- const point3 = {
174
- x: start2[0],
175
- y: start2[1],
176
- z: start2[2]
177
- };
178
- const point4 = {
179
- x: end2[0],
180
- y: end2[1],
181
- z: end2[2]
182
- };
183
- const cachedStatsKeys = Object.keys(cachedStats)[0];
184
- const {
185
- angle = undefined
186
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
187
- return {
188
- point1,
189
- point2,
190
- point3,
191
- point4,
192
- rAngle: angle,
193
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
194
- finding,
195
- findingSites: findingSites || [],
196
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
197
- use3DSpatialCoordinates: true
74
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
75
+ use3DSpatialCoordinates: is3DMeasurement
198
76
  };
199
77
  }
200
78
  }
@@ -1,35 +1,13 @@
1
1
  import BaseAdapter3D from "./BaseAdapter3D";
2
2
  declare class EllipticalROI extends BaseAdapter3D {
3
- static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any): any;
4
- static getMeasurementDataFromScoord({ defaultState, SCOORDGroup, imageToWorldCoords, metadata, NUMGroup, ReferencedFrameNumber }: {
5
- defaultState: any;
6
- SCOORDGroup: any;
7
- imageToWorldCoords: any;
8
- metadata: any;
9
- NUMGroup: any;
10
- ReferencedFrameNumber: any;
11
- }): any;
12
- static getMeasurementDataFromScoord3D({ defaultState, SCOORD3DGroup }: {
13
- defaultState: any;
14
- SCOORD3DGroup: any;
15
- }): any;
16
- static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
17
- area: any;
18
- points: any[];
19
- trackingIdentifierTextValue: string;
20
- finding: any;
21
- findingSites: any;
22
- ReferencedFrameOfReferenceUID: any;
23
- use3DSpatialCoordinates: boolean;
24
- } | {
25
- area: any;
26
- points: any[];
27
- trackingIdentifierTextValue: string;
28
- finding: any;
29
- findingSites: any;
30
- use3DSpatialCoordinates: boolean;
3
+ static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any): {
4
+ description?: string;
5
+ sopInstanceUid?: string;
6
+ annotation: import("packages/tools/dist/esm/types").Annotation;
7
+ finding?: unknown;
8
+ findingSites?: unknown;
31
9
  };
32
- static getTID300RepresentationArgumentsSCOORD3D(tool: any): {
10
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
33
11
  area: any;
34
12
  points: any[];
35
13
  trackingIdentifierTextValue: string;