@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
@@ -11,34 +11,20 @@ declare class Probe extends BaseAdapter3D {
11
11
  state: any;
12
12
  SCOORD3DGroup: any;
13
13
  }): any;
14
- static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
15
- points: {
14
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
15
+ points: ({
16
16
  x: any;
17
17
  y: any;
18
18
  z: any;
19
- }[];
19
+ } | {
20
+ x: number;
21
+ y: number;
22
+ z?: undefined;
23
+ })[];
20
24
  trackingIdentifierTextValue: string;
21
- ReferencedFrameOfReferenceUID: any;
22
25
  findingSites: any;
23
26
  finding: any;
24
- use3DSpatialCoordinates: boolean;
25
- } | {
26
- points: any;
27
- trackingIdentifierTextValue: string;
28
- findingSites: any;
29
- finding: any;
30
- use3DSpatialCoordinates: boolean;
31
- };
32
- static getTID300RepresentationArgumentsSCOORD3D(tool: any): {
33
- points: {
34
- x: any;
35
- y: any;
36
- z: any;
37
- }[];
38
- trackingIdentifierTextValue: string;
39
27
  ReferencedFrameOfReferenceUID: any;
40
- findingSites: any;
41
- finding: any;
42
28
  use3DSpatialCoordinates: boolean;
43
29
  };
44
30
  }
@@ -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 { toScoords } from '../helpers/toScoordType.js';
6
+ import '@cornerstonejs/core';
4
7
 
5
8
  var _Probe;
6
9
  const {
@@ -83,7 +86,8 @@ class Probe extends BaseAdapter3D {
83
86
  };
84
87
  return state;
85
88
  }
86
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
89
+ static getTID300RepresentationArguments(tool) {
90
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
87
91
  const {
88
92
  data,
89
93
  metadata
@@ -95,54 +99,23 @@ class Probe extends BaseAdapter3D {
95
99
  const {
96
100
  referencedImageId
97
101
  } = metadata;
98
- if (!referencedImageId) {
99
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
100
- }
101
- const {
102
- handles: {
103
- points = []
104
- }
105
- } = data;
106
- const pointsImage = points.map(point => {
107
- const pointImage = worldToImageCoords(referencedImageId, point);
108
- return {
109
- x: pointImage[0],
110
- y: pointImage[1]
111
- };
112
- });
113
- return {
114
- points: pointsImage,
115
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
116
- findingSites: findingSites || [],
117
- finding,
118
- use3DSpatialCoordinates: false
102
+ const scoordProps = {
103
+ is3DMeasurement,
104
+ referencedImageId
119
105
  };
120
- }
121
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
122
- const {
123
- data,
124
- finding,
125
- findingSites,
126
- metadata
127
- } = tool;
128
106
  const {
129
107
  handles: {
130
108
  points = []
131
109
  }
132
110
  } = data;
133
- const point = points[0];
134
- const pointXYZ = {
135
- x: point[0],
136
- y: point[1],
137
- z: point[2]
138
- };
111
+ const pointsImage = toScoords(scoordProps, points);
139
112
  return {
140
- points: [pointXYZ],
113
+ points: pointsImage,
141
114
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
142
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
143
115
  findingSites: findingSites || [],
144
116
  finding,
145
- use3DSpatialCoordinates: true
117
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
118
+ use3DSpatialCoordinates: is3DMeasurement
146
119
  };
147
120
  }
148
121
  }
@@ -12,7 +12,7 @@ declare class RectangleROI extends BaseAdapter3D {
12
12
  SCOORD3DGroup: any;
13
13
  defaultState: any;
14
14
  }): any;
15
- static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
15
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
16
16
  points: any[];
17
17
  area: any;
18
18
  perimeter: any;
@@ -1,4 +1,5 @@
1
1
  import { utilities } from 'dcmjs';
2
+ import { utilities as utilities$1 } from '@cornerstonejs/core';
2
3
  import MeasurementReport from './MeasurementReport.js';
3
4
  import BaseAdapter3D from './BaseAdapter3D.js';
4
5
 
@@ -6,6 +7,9 @@ var _RectangleROI;
6
7
  const {
7
8
  Polyline: TID300Polyline
8
9
  } = utilities.TID300;
10
+ const {
11
+ worldToImageCoords
12
+ } = utilities$1;
9
13
  class RectangleROI extends BaseAdapter3D {
10
14
  static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
11
15
  const {
@@ -93,7 +97,8 @@ class RectangleROI extends BaseAdapter3D {
93
97
  };
94
98
  return state;
95
99
  }
96
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
100
+ static getTID300RepresentationArguments(tool) {
101
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
97
102
  const {
98
103
  data,
99
104
  finding,
@@ -107,7 +112,7 @@ class RectangleROI extends BaseAdapter3D {
107
112
  const {
108
113
  referencedImageId
109
114
  } = metadata;
110
- if (!referencedImageId) {
115
+ if (is3DMeasurement) {
111
116
  return this.getTID300RepresentationArgumentsSCOORD3D(tool);
112
117
  }
113
118
  const corners = handles.points.map(point => worldToImageCoords(referencedImageId, point));
@@ -3,27 +3,18 @@ declare class UltrasoundDirectional extends BaseAdapter3D {
3
3
  static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any): {
4
4
  description?: string;
5
5
  sopInstanceUid?: string;
6
- annotation: {
7
- annotationUID: string;
8
- metadata: {
9
- toolName: string;
10
- referencedImageId?: string;
11
- FrameOfReferenceUID: string;
12
- label: string;
13
- };
14
- data?: unknown;
15
- };
6
+ annotation: import("packages/tools/dist/esm/types").Annotation;
16
7
  finding?: unknown;
17
8
  findingSites?: unknown;
18
9
  };
19
- static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
10
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement: any): {
20
11
  point1: {
21
- x: any;
22
- y: any;
12
+ x: number;
13
+ y: number;
23
14
  };
24
15
  point2: {
25
- x: any;
26
- y: any;
16
+ x: number;
17
+ y: number;
27
18
  };
28
19
  trackingIdentifierTextValue: string;
29
20
  finding: any;
@@ -1,4 +1,5 @@
1
1
  import { utilities } from 'dcmjs';
2
+ import { utilities as utilities$1 } from '@cornerstonejs/core';
2
3
  import MeasurementReport from './MeasurementReport.js';
3
4
  import BaseAdapter3D from './BaseAdapter3D.js';
4
5
 
@@ -6,6 +7,9 @@ var _UltrasoundDirectional;
6
7
  const {
7
8
  Length: TID300Length
8
9
  } = utilities.TID300;
10
+ const {
11
+ worldToImageCoords
12
+ } = utilities$1;
9
13
  class UltrasoundDirectional extends BaseAdapter3D {
10
14
  static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
11
15
  const {
@@ -24,6 +28,7 @@ class UltrasoundDirectional extends BaseAdapter3D {
24
28
  }
25
29
  const state = defaultState;
26
30
  state.annotation.data = {
31
+ ...state.annotation.data,
27
32
  handles: {
28
33
  points: [worldCoords[0], worldCoords[1]],
29
34
  activeHandleIndex: 0,
@@ -31,12 +36,11 @@ class UltrasoundDirectional extends BaseAdapter3D {
31
36
  hasMoved: false
32
37
  }
33
38
  },
34
- cachedStats: {},
35
39
  frameNumber: ReferencedFrameNumber
36
40
  };
37
41
  return state;
38
42
  }
39
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
43
+ static getTID300RepresentationArguments(tool, is3DMeasurement) {
40
44
  const {
41
45
  data,
42
46
  finding,
@@ -4,4 +4,7 @@ import { graphicTypeEquals } from "./graphicTypeEquals";
4
4
  import { downloadDICOMData } from "./downloadDICOMData";
5
5
  export { copyStudyTags } from "./copyStudyTags";
6
6
  export { copySeriesTags } from "./copySeriesTags";
7
+ export * from "./toScoordType";
8
+ export * from "./scoordToWorld";
9
+ export * from "./toPoint3";
7
10
  export { toArray, codeMeaningEquals, graphicTypeEquals, downloadDICOMData };
@@ -4,3 +4,6 @@ export { graphicTypeEquals } from './graphicTypeEquals.js';
4
4
  export { downloadDICOMData } from './downloadDICOMData.js';
5
5
  export { copyStudyTags } from './copyStudyTags.js';
6
6
  export { copySeriesTags } from './copySeriesTags.js';
7
+ export { setWorldToImageCoords, toScoord, toScoords } from './toScoordType.js';
8
+ export { scoordToWorld } from './scoordToWorld.js';
9
+ export { toPoint3 } from './toPoint3.js';
@@ -0,0 +1,5 @@
1
+ import { type Types } from "@cornerstonejs/core";
2
+ export declare function scoordToWorld({ is3DMeasurement, referencedImageId }: {
3
+ is3DMeasurement: any;
4
+ referencedImageId: any;
5
+ }, scoord: any): Types.Point3[];
@@ -0,0 +1,32 @@
1
+ import { utilities } from '@cornerstonejs/core';
2
+
3
+ const {
4
+ imageToWorldCoords
5
+ } = utilities;
6
+ function scoordToWorld(_ref, scoord) {
7
+ let {
8
+ is3DMeasurement,
9
+ referencedImageId
10
+ } = _ref;
11
+ const worldCoords = [];
12
+ if (is3DMeasurement) {
13
+ const {
14
+ GraphicData
15
+ } = scoord;
16
+ for (let i = 0; i < GraphicData.length; i += 3) {
17
+ const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
18
+ worldCoords.push(point);
19
+ }
20
+ } else {
21
+ const {
22
+ GraphicData
23
+ } = scoord;
24
+ for (let i = 0; i < GraphicData.length; i += 2) {
25
+ const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
26
+ worldCoords.push(point);
27
+ }
28
+ }
29
+ return worldCoords;
30
+ }
31
+
32
+ export { scoordToWorld };
@@ -0,0 +1,3 @@
1
+ import type { Types } from "@cornerstonejs/core";
2
+ export declare function toPoint3(flatPoints: number[]): Types.Point3[];
3
+ export default toPoint3;
@@ -0,0 +1,18 @@
1
+ function toPoint3(flatPoints) {
2
+ const points = [];
3
+ if (!flatPoints?.length) {
4
+ return points;
5
+ }
6
+ const {
7
+ length: n
8
+ } = flatPoints;
9
+ if (n % 3 !== 0) {
10
+ throw new Error(`Points array should be divisible by 3 for SCOORD3D, but contents are: ${JSON.stringify(flatPoints)} of length ${n}`);
11
+ }
12
+ for (let i = 0; i < n; i += 3) {
13
+ points.push([flatPoints[i], flatPoints[i + 1], flatPoints[i + 2]]);
14
+ }
15
+ return points;
16
+ }
17
+
18
+ export { toPoint3 as default, toPoint3 };
@@ -0,0 +1,23 @@
1
+ import { type Types, utilities } from "@cornerstonejs/core";
2
+ export declare function toScoord({ is3DMeasurement, referencedImageId }: {
3
+ is3DMeasurement: any;
4
+ referencedImageId: any;
5
+ }, point: any): {
6
+ x: any;
7
+ y: any;
8
+ z: any;
9
+ } | {
10
+ x: number;
11
+ y: number;
12
+ z?: undefined;
13
+ };
14
+ export declare function toScoords(scoordArgs: any, points: Array<Types.Point3>): ({
15
+ x: any;
16
+ y: any;
17
+ z: any;
18
+ } | {
19
+ x: number;
20
+ y: number;
21
+ z?: undefined;
22
+ })[];
23
+ export declare function setWorldToImageCoords(worldToImage?: typeof utilities.worldToImageCoords): void;
@@ -0,0 +1,33 @@
1
+ import { utilities } from '@cornerstonejs/core';
2
+
3
+ const {
4
+ worldToImageCoords: globalWorldToImageCoords
5
+ } = utilities;
6
+ let useWorldToImageCoords = globalWorldToImageCoords;
7
+ function toScoord(_ref, point) {
8
+ let {
9
+ is3DMeasurement,
10
+ referencedImageId
11
+ } = _ref;
12
+ if (is3DMeasurement) {
13
+ return {
14
+ x: point[0],
15
+ y: point[1],
16
+ z: point[2]
17
+ };
18
+ }
19
+ const point2 = useWorldToImageCoords(referencedImageId, point);
20
+ return {
21
+ x: point2[0],
22
+ y: point2[1]
23
+ };
24
+ }
25
+ function toScoords(scoordArgs, points) {
26
+ return points.map(point => toScoord(scoordArgs, point));
27
+ }
28
+ function setWorldToImageCoords() {
29
+ let worldToImage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalWorldToImageCoords;
30
+ useWorldToImageCoords = worldToImage;
31
+ }
32
+
33
+ export { setWorldToImageCoords, toScoord, toScoords };
@@ -4,6 +4,7 @@ import { VTKjsSEG } from './VTKjs/index.js';
4
4
  import './enums/Events.js';
5
5
  import 'dcmjs';
6
6
  import 'buffer';
7
+ import '@cornerstonejs/core';
7
8
 
8
9
  const adaptersSR = {
9
10
  Cornerstone: CornerstoneSR,
@@ -1 +1 @@
1
- export declare const version = "3.31.0";
1
+ export declare const version = "3.31.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/adapters",
3
- "version": "3.31.0",
3
+ "version": "3.31.2",
4
4
  "description": "Adapters for Cornerstone3D to/from formats including DICOM SR and others",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -85,13 +85,13 @@
85
85
  "dependencies": {
86
86
  "@babel/runtime-corejs2": "^7.17.8",
87
87
  "buffer": "^6.0.3",
88
- "dcmjs": "^0.42.0",
88
+ "dcmjs": "^0.43.1",
89
89
  "gl-matrix": "^3.4.3",
90
90
  "ndarray": "^1.0.19"
91
91
  },
92
92
  "peerDependencies": {
93
- "@cornerstonejs/core": "^3.31.0",
94
- "@cornerstonejs/tools": "^3.31.0"
93
+ "@cornerstonejs/core": "^3.31.2",
94
+ "@cornerstonejs/tools": "^3.31.2"
95
95
  },
96
- "gitHead": "ea3e44970a9e535db1f38c8186653ffb7376ecf9"
96
+ "gitHead": "43718ecc1e9a5ba7f970b9fd7213c41f152d22ee"
97
97
  }