@cornerstonejs/adapters 4.0.0-beta.2 → 4.0.0-beta.4

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 (55) hide show
  1. package/README.md +7 -7
  2. package/dist/esm/adapters/Cornerstone/Bidirectional.js +1 -0
  3. package/dist/esm/adapters/Cornerstone/MeasurementReport.js +8 -6
  4. package/dist/esm/adapters/Cornerstone/ParametricMap.js +2 -2
  5. package/dist/esm/adapters/Cornerstone/Segmentation_4X.js +14 -11
  6. package/dist/esm/adapters/Cornerstone3D/Angle.d.ts +25 -62
  7. package/dist/esm/adapters/Cornerstone3D/Angle.js +29 -146
  8. package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.d.ts +15 -27
  9. package/dist/esm/adapters/Cornerstone3D/ArrowAnnotate.js +31 -161
  10. package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.d.ts +12 -21
  11. package/dist/esm/adapters/Cornerstone3D/BaseAdapter3D.js +58 -43
  12. package/dist/esm/adapters/Cornerstone3D/Bidirectional.d.ts +25 -80
  13. package/dist/esm/adapters/Cornerstone3D/Bidirectional.js +36 -173
  14. package/dist/esm/adapters/Cornerstone3D/CircleROI.d.ts +18 -33
  15. package/dist/esm/adapters/Cornerstone3D/CircleROI.js +27 -133
  16. package/dist/esm/adapters/Cornerstone3D/CobbAngle.d.ts +25 -62
  17. package/dist/esm/adapters/Cornerstone3D/CobbAngle.js +24 -149
  18. package/dist/esm/adapters/Cornerstone3D/EllipticalROI.d.ts +18 -30
  19. package/dist/esm/adapters/Cornerstone3D/EllipticalROI.js +27 -241
  20. package/dist/esm/adapters/Cornerstone3D/KeyImage.d.ts +17 -11
  21. package/dist/esm/adapters/Cornerstone3D/KeyImage.js +4 -4
  22. package/dist/esm/adapters/Cornerstone3D/LabelData.d.ts +11 -0
  23. package/dist/esm/adapters/Cornerstone3D/LabelData.js +102 -0
  24. package/dist/esm/adapters/Cornerstone3D/Length.d.ts +17 -45
  25. package/dist/esm/adapters/Cornerstone3D/Length.js +27 -125
  26. package/dist/esm/adapters/Cornerstone3D/MeasurementReport.d.ts +77 -37
  27. package/dist/esm/adapters/Cornerstone3D/MeasurementReport.js +176 -51
  28. package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.d.ts +18 -41
  29. package/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.js +26 -138
  30. package/dist/esm/adapters/Cornerstone3D/Probe.d.ts +17 -32
  31. package/dist/esm/adapters/Cornerstone3D/Probe.js +34 -106
  32. package/dist/esm/adapters/Cornerstone3D/RectangleROI.d.ts +19 -33
  33. package/dist/esm/adapters/Cornerstone3D/RectangleROI.js +28 -115
  34. package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.d.ts +9 -15
  35. package/dist/esm/adapters/Cornerstone3D/UltrasoundDirectional.js +12 -21
  36. package/dist/esm/adapters/Cornerstone3D/constants/index.d.ts +11 -0
  37. package/dist/esm/adapters/Cornerstone3D/constants/index.js +12 -1
  38. package/dist/esm/adapters/Cornerstone3D/index.d.ts +11 -0
  39. package/dist/esm/adapters/Cornerstone3D/index.js +6 -2
  40. package/dist/esm/adapters/helpers/checkOrientation.js +2 -2
  41. package/dist/esm/adapters/helpers/index.d.ts +3 -0
  42. package/dist/esm/adapters/helpers/index.js +3 -0
  43. package/dist/esm/adapters/helpers/scoordToWorld.d.ts +5 -0
  44. package/dist/esm/adapters/helpers/scoordToWorld.js +32 -0
  45. package/dist/esm/adapters/helpers/toArray.js +1 -1
  46. package/dist/esm/adapters/helpers/toPoint3.d.ts +3 -0
  47. package/dist/esm/adapters/helpers/toPoint3.js +18 -0
  48. package/dist/esm/adapters/helpers/toScoordType.d.ts +23 -0
  49. package/dist/esm/adapters/helpers/toScoordType.js +33 -0
  50. package/dist/esm/adapters/index.d.ts +12 -1
  51. package/dist/esm/adapters/index.js +1 -0
  52. package/dist/esm/version.d.ts +1 -1
  53. package/package.json +7 -7
  54. package/dist/esm/adapters/helpers/compareArrays.d.ts +0 -1
  55. package/dist/esm/adapters/helpers/compareArrays.js +0 -18
package/README.md CHANGED
@@ -9,17 +9,17 @@
9
9
  # History
10
10
 
11
11
  - 2014
12
- - [DCMTK](dcmtk.org) cross compiled to javascript at [CTK Hackfest](http://www.commontk.org/index.php/CTK-Hackfest-May-2014). While this was useful and powerful, it was heavyweight for typical web usage.
12
+ - [DCMTK](dcmtk.org) cross compiled to javascript at [CTK Hackfest](http://www.commontk.org/index.php/CTK-Hackfest-May-2014). While this was useful and powerful, it was heavyweight for typical web usage.
13
13
  - 2016
14
- - A [Medical Imaging Web Appliction meeting at Stanford](http://qiicr.org/web/outreach/Medical-Imaging-Web-Apps/) and [follow-on hackfest in Boston](http://qiicr.org/web/outreach/MIWS-hackfest/) helped elaborate the needs for manipulating DICOM in pure Javascript.
15
- - Based on [DICOM Part 10 read/write code](https://github.com/OHIF/dicom-dimse) initiated by Weiwei Wu of [OHIF](http://ohif.org), Steve Pieper [developed further features](https://github.com/pieper/sites/tree/gh-pages/dcmio) and [examples of creating multiframe and segmentation objects](https://github.com/pieper/sites/tree/gh-pages/DICOMzero) discussed with the community at RSNA
14
+ - A [Medical Imaging Web Appliction meeting at Stanford](http://qiicr.org/web/outreach/Medical-Imaging-Web-Apps/) and [follow-on hackfest in Boston](http://qiicr.org/web/outreach/MIWS-hackfest/) helped elaborate the needs for manipulating DICOM in pure Javascript.
15
+ - Based on [DICOM Part 10 read/write code](https://github.com/OHIF/dicom-dimse) initiated by Weiwei Wu of [OHIF](http://ohif.org), Steve Pieper [developed further features](https://github.com/pieper/sites/tree/gh-pages/dcmio) and [examples of creating multiframe and segmentation objects](https://github.com/pieper/sites/tree/gh-pages/DICOMzero) discussed with the community at RSNA
16
16
  - 2017
17
- - At [NA-MIC Project Week 25](https://na-mic.org/wiki/Project_Week_25) Erik Ziegler and Steve Pieper [worked](https://na-mic.org/wiki/Project_Week_25/DICOM_Segmentation_Support_for_Cornerstone_and_OHIF_Viewer)
18
- with the community to define some example use cases to mix the pure JavaScript DICOM code with Cornerstone and [CornerstoneTools](https://github.com/chafey/cornerstoneTools).
17
+ - At [NA-MIC Project Week 25](https://na-mic.org/wiki/Project_Week_25) Erik Ziegler and Steve Pieper [worked](https://na-mic.org/wiki/Project_Week_25/DICOM_Segmentation_Support_for_Cornerstone_and_OHIF_Viewer)
18
+ with the community to define some example use cases to mix the pure JavaScript DICOM code with Cornerstone and [CornerstoneTools](https://github.com/chafey/cornerstoneTools).
19
19
  - 2018-2022
20
- - Work continues to develop SR and SEG support to [OHIFViewer](http://ohif.org) allow interoperability with [DICOM4QI](https://legacy.gitbook.com/book/qiicr/dicom4qi/details)
20
+ - Work continues to develop SR and SEG support to [OHIFViewer](http://ohif.org) allow interoperability with [DICOM4QI](https://legacy.gitbook.com/book/qiicr/dicom4qi/details)
21
21
  - 2023
22
- - Moved the adapters into cornerstone3D from dcmjsj
22
+ - Moved the adapters into cornerstone3D from dcmjsj
23
23
 
24
24
  # Support
25
25
 
@@ -3,6 +3,7 @@ import MeasurementReport from './MeasurementReport.js';
3
3
  import CORNERSTONE_4_TAG from './cornerstone4Tag.js';
4
4
  import { toArray } from '../helpers/toArray.js';
5
5
  import 'buffer';
6
+ import '@cornerstonejs/core';
6
7
 
7
8
  const {
8
9
  Bidirectional: TID300Bidirectional
@@ -2,6 +2,7 @@ import { utilities, derivations, normalizers, data } from 'dcmjs';
2
2
  import { toArray } from '../helpers/toArray.js';
3
3
  import { codeMeaningEquals } from '../helpers/codeMeaningEquals.js';
4
4
  import 'buffer';
5
+ import '@cornerstonejs/core';
5
6
 
6
7
  const {
7
8
  TID1500,
@@ -48,8 +49,9 @@ const codeValueMatch = (group, code, oldCode) => {
48
49
  function getTID300ContentItem(tool, ReferencedSOPSequence, adapterClass) {
49
50
  const args = adapterClass.getTID300RepresentationArguments(tool);
50
51
  args.ReferencedSOPSequence = ReferencedSOPSequence;
51
- const TID300Measurement = new adapterClass.TID300Representation(args);
52
- return TID300Measurement;
52
+ args.ReferencedFrameOfReferenceUID = args.use3DSpatialCoordinates ? tool.metadata.FrameOfReferenceUID : null;
53
+ const tid300Measurement = new adapterClass.TID300Representation(args);
54
+ return tid300Measurement;
53
55
  }
54
56
  function getMeasurementGroup(toolType, toolData, ReferencedSOPSequence) {
55
57
  const toolTypeData = toolData[toolType];
@@ -60,10 +62,10 @@ function getMeasurementGroup(toolType, toolData, ReferencedSOPSequence) {
60
62
 
61
63
  // Loop through the array of tool instances
62
64
  // for this tool
63
- const Measurements = toolTypeData.data.map(tool => {
65
+ const measurements = toolTypeData.data.map(tool => {
64
66
  return getTID300ContentItem(tool, ReferencedSOPSequence, toolClass);
65
67
  });
66
- return new TID1501MeasurementGroup(Measurements);
68
+ return new TID1501MeasurementGroup(measurements);
67
69
  }
68
70
  class MeasurementReport {
69
71
  static getSetupMeasurementData(MeasurementGroup) {
@@ -161,7 +163,7 @@ class MeasurementReport {
161
163
  });
162
164
  allMeasurementGroups = allMeasurementGroups.concat(measurementGroups);
163
165
  });
164
- const MeasurementReport = new TID1500MeasurementReport({
166
+ const tid1500MeasurementReport = new TID1500MeasurementReport({
165
167
  TID1501MeasurementGroups: allMeasurementGroups
166
168
  }, options);
167
169
 
@@ -203,7 +205,7 @@ class MeasurementReport {
203
205
  derivationSourceDataset._meta = _meta;
204
206
  derivationSourceDataset._vrMap = _vrMap;
205
207
  const report = new StructuredReport([derivationSourceDataset]);
206
- const contentItem = MeasurementReport.contentItem(derivationSourceDataset);
208
+ const contentItem = tid1500MeasurementReport.contentItem(derivationSourceDataset);
207
209
 
208
210
  // Merge the derived dataset with the content from the Measurement Report
209
211
  report.dataset = Object.assign(report.dataset, contentItem);
@@ -1,6 +1,6 @@
1
1
  import { log, data, normalizers } from 'dcmjs';
2
2
  import checkOrientation from '../helpers/checkOrientation.js';
3
- import compareArrays from '../helpers/compareArrays.js';
3
+ import { utilities } from '@cornerstonejs/core';
4
4
 
5
5
  const {
6
6
  DicomMessage,
@@ -167,7 +167,7 @@ function getImageIdOfSourceImagebyGeometry(ReferencedSeriesInstanceUID, FrameOfR
167
167
  if (sourceImageMetadata === undefined || sourceImageMetadata.ImagePositionPatient === undefined || sourceImageMetadata.FrameOfReferenceUID !== FrameOfReferenceUID || sourceImageMetadata.SeriesInstanceUID !== ReferencedSeriesInstanceUID) {
168
168
  continue;
169
169
  }
170
- if (compareArrays(PerFrameFunctionalGroup.PlanePositionSequence[0].ImagePositionPatient, sourceImageMetadata.ImagePositionPatient, tolerance)) {
170
+ if (utilities.isEqual(PerFrameFunctionalGroup.PlanePositionSequence[0].ImagePositionPatient, sourceImageMetadata.ImagePositionPatient, tolerance)) {
171
171
  return imageIds[imageIdsIndex];
172
172
  }
173
173
  }
@@ -2,7 +2,7 @@ import { utilities, log, data, normalizers, derivations } from 'dcmjs';
2
2
  import ndarray from 'ndarray';
3
3
  import getDatasetsFromImages from '../helpers/getDatasetsFromImages.js';
4
4
  import checkOrientation from '../helpers/checkOrientation.js';
5
- import compareArrays from '../helpers/compareArrays.js';
5
+ import { utilities as utilities$1 } from '@cornerstonejs/core';
6
6
  import { Events } from '../enums/Events.js';
7
7
 
8
8
  const {
@@ -913,6 +913,9 @@ function getImageIdOfSourceImageBySourceImageSequence(SourceImageSequence, sopUI
913
913
  if (ReferencedFrameNumber !== undefined) {
914
914
  if (baseImageId.includes("frames/")) {
915
915
  return baseImageId.replace(/frames\/\d+/, `frames/${ReferencedFrameNumber}`);
916
+ } else if (baseImageId.includes("dicomfile:")) {
917
+ // dicomfile base 1, despite having frame=
918
+ return baseImageId.replace(/frame=\d+/, `frame=${ReferencedFrameNumber}`);
916
919
  } else if (baseImageId.includes("frame=")) {
917
920
  return baseImageId.replace(/frame=\d+/, `frame=${ReferencedFrameNumber - 1}`);
918
921
  } else {
@@ -967,10 +970,10 @@ function getImageIdOfSourceImagebyGeometry(ReferencedSeriesInstanceUID, FrameOfR
967
970
  // For multiframe images, check each frame's position
968
971
  if (isMultiframe) {
969
972
  const framePosition = metadataProvider.get("imagePlaneModule", imageId)?.imagePositionPatient;
970
- if (framePosition && compareArrays(segFramePosition, framePosition, tolerance)) {
973
+ if (framePosition && utilities$1.isEqual(segFramePosition, framePosition, tolerance)) {
971
974
  return imageId;
972
975
  }
973
- } else if (compareArrays(segFramePosition, sourceImageMetadata.ImagePositionPatient, tolerance)) {
976
+ } else if (utilities$1.isEqual(segFramePosition, sourceImageMetadata.ImagePositionPatient, tolerance)) {
974
977
  return imageId;
975
978
  }
976
979
  }
@@ -1012,38 +1015,38 @@ function getValidOrientations(iop) {
1012
1015
  * @return {Ndarray} The aligned pixelData.
1013
1016
  */
1014
1017
  function alignPixelDataWithSourceData(pixelData2D, iop, orientations, tolerance) {
1015
- if (compareArrays(iop, orientations[0], tolerance)) {
1018
+ if (utilities$1.isEqual(iop, orientations[0], tolerance)) {
1016
1019
  return pixelData2D;
1017
- } else if (compareArrays(iop, orientations[1], tolerance)) {
1020
+ } else if (utilities$1.isEqual(iop, orientations[1], tolerance)) {
1018
1021
  // Flipped vertically.
1019
1022
 
1020
1023
  // Undo Flip
1021
1024
  return flipMatrix2D.v(pixelData2D);
1022
- } else if (compareArrays(iop, orientations[2], tolerance)) {
1025
+ } else if (utilities$1.isEqual(iop, orientations[2], tolerance)) {
1023
1026
  // Flipped horizontally.
1024
1027
 
1025
1028
  // Unfo flip
1026
1029
  return flipMatrix2D.h(pixelData2D);
1027
- } else if (compareArrays(iop, orientations[3], tolerance)) {
1030
+ } else if (utilities$1.isEqual(iop, orientations[3], tolerance)) {
1028
1031
  //Rotated 90 degrees
1029
1032
 
1030
1033
  // Rotate back
1031
1034
  return rotateMatrix902D(pixelData2D);
1032
- } else if (compareArrays(iop, orientations[4], tolerance)) {
1035
+ } else if (utilities$1.isEqual(iop, orientations[4], tolerance)) {
1033
1036
  //Rotated 90 degrees and fliped horizontally.
1034
1037
 
1035
1038
  // Undo flip and rotate back.
1036
1039
  return rotateMatrix902D(flipMatrix2D.h(pixelData2D));
1037
- } else if (compareArrays(iop, orientations[5], tolerance)) {
1040
+ } else if (utilities$1.isEqual(iop, orientations[5], tolerance)) {
1038
1041
  // Rotated 90 degrees and fliped vertically
1039
1042
 
1040
1043
  // Unfo flip and rotate back.
1041
1044
  return rotateMatrix902D(flipMatrix2D.v(pixelData2D));
1042
- } else if (compareArrays(iop, orientations[6], tolerance)) {
1045
+ } else if (utilities$1.isEqual(iop, orientations[6], tolerance)) {
1043
1046
  // Rotated 180 degrees. // TODO -> Do this more effeciently, there is a 1:1 mapping like 90 degree rotation.
1044
1047
 
1045
1048
  return rotateMatrix902D(rotateMatrix902D(pixelData2D));
1046
- } else if (compareArrays(iop, orientations[7], tolerance)) {
1049
+ } else if (utilities$1.isEqual(iop, orientations[7], tolerance)) {
1047
1050
  // Rotated 270 degrees
1048
1051
 
1049
1052
  // Rotate back.
@@ -1,87 +1,50 @@
1
1
  import BaseAdapter3D from "./BaseAdapter3D";
2
2
  declare class Angle 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;
9
+ commentGroup?: any;
10
+ commentPositionGroup?: any;
64
11
  };
65
- static getTID300RepresentationArgumentsSCOORD3D(tool: any): {
12
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
66
13
  point1: {
67
14
  x: any;
68
15
  y: any;
69
16
  z: any;
17
+ } | {
18
+ x: number;
19
+ y: number;
20
+ z?: undefined;
70
21
  };
71
22
  point2: {
72
23
  x: any;
73
24
  y: any;
74
25
  z: any;
26
+ } | {
27
+ x: number;
28
+ y: number;
29
+ z?: undefined;
75
30
  };
76
31
  point3: {
77
32
  x: any;
78
33
  y: any;
79
34
  z: any;
35
+ } | {
36
+ x: number;
37
+ y: number;
38
+ z?: undefined;
80
39
  };
81
40
  point4: {
82
41
  x: any;
83
42
  y: any;
84
43
  z: any;
44
+ } | {
45
+ x: number;
46
+ y: number;
47
+ z?: undefined;
85
48
  };
86
49
  rAngle: any;
87
50
  trackingIdentifierTextValue: string;
@@ -1,99 +1,41 @@
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 _Angle;
6
9
  const {
7
10
  CobbAngle: TID300CobbAngle
8
11
  } = utilities.TID300;
9
12
  class Angle 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
+ worldCoords,
18
+ referencedImageId,
16
19
  ReferencedFrameNumber
17
- } = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, Angle.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;
20
+ } = MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
21
+ const cachedStats = referencedImageId ? {
22
+ [`imageId:${referencedImageId}`]: {
23
+ angle: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
24
+ }
25
+ } : {};
53
26
  state.annotation.data = {
27
+ ...state.annotation.data,
54
28
  handles: {
55
- points: [worldCoords[0], worldCoords[1], worldCoords[3]],
56
- activeHandleIndex: 0,
57
- textBox: {
58
- hasMoved: false
59
- }
60
- },
61
- cachedStats: {
62
- [`imageId:${referencedImageId}`]: {
63
- angle: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
64
- }
29
+ ...state.annotation.data.handles,
30
+ points: [worldCoords[0], worldCoords[1], worldCoords[3]]
65
31
  },
32
+ cachedStats,
66
33
  frameNumber: ReferencedFrameNumber
67
34
  };
68
35
  return state;
69
36
  }
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);
82
- }
83
- const state = defaultState;
84
- state.annotation.data = {
85
- handles: {
86
- points: [worldCoords[0], worldCoords[1], worldCoords[3]],
87
- activeHandleIndex: 0,
88
- textBox: {
89
- hasMoved: false
90
- }
91
- },
92
- cachedStats: {}
93
- };
94
- return state;
95
- }
96
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
37
+ static getTID300RepresentationArguments(tool) {
38
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
97
39
  const {
98
40
  data,
99
41
  finding,
@@ -107,74 +49,15 @@ class Angle extends BaseAdapter3D {
107
49
  const {
108
50
  referencedImageId
109
51
  } = metadata;
110
- if (!referencedImageId) {
111
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
112
- }
113
- const start1 = worldToImageCoords(referencedImageId, handles.points[0]);
114
- const middle = worldToImageCoords(referencedImageId, handles.points[1]);
115
- const end = worldToImageCoords(referencedImageId, handles.points[2]);
116
- const point1 = {
117
- x: start1[0],
118
- y: start1[1]
119
- };
120
- const point2 = {
121
- x: middle[0],
122
- y: middle[1]
123
- };
124
- const point3 = point2;
125
- const point4 = {
126
- x: end[0],
127
- y: end[1]
128
- };
129
- const {
130
- angle
131
- } = cachedStats[`imageId:${referencedImageId}`] || {};
132
- return {
133
- point1,
134
- point2,
135
- point3,
136
- point4,
137
- rAngle: angle,
138
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
139
- finding,
140
- findingSites: findingSites || [],
141
- use3DSpatialCoordinates: false
142
- };
143
- }
144
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
145
- const {
146
- data,
147
- finding,
148
- findingSites,
149
- metadata
150
- } = tool;
151
- const {
152
- cachedStats = {},
153
- handles
154
- } = data;
155
- const start = handles.points[0];
156
- const middle = handles.points[1];
157
- const end = handles.points[2];
158
- const point1 = {
159
- x: start[0],
160
- y: start[1],
161
- z: start[2]
162
- };
163
- const point2 = {
164
- x: middle[0],
165
- y: middle[1],
166
- z: middle[2]
167
- };
168
- const point3 = point2;
169
- const point4 = {
170
- x: end[0],
171
- y: end[1],
172
- z: end[2]
52
+ const scoordProps = {
53
+ is3DMeasurement,
54
+ referencedImageId
173
55
  };
174
- const cachedStatsKeys = Object.keys(cachedStats)[0];
175
- const {
176
- angle
177
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
56
+ const point1 = toScoord(scoordProps, handles.points[0]);
57
+ const point2 = toScoord(scoordProps, handles.points[1]);
58
+ const point3 = toScoord(scoordProps, handles.points[1]);
59
+ const point4 = toScoord(scoordProps, handles.points[2]);
60
+ const angle = cachedStats[`imageId:${referencedImageId}`]?.angle;
178
61
  return {
179
62
  point1,
180
63
  point2,
@@ -184,8 +67,8 @@ class Angle extends BaseAdapter3D {
184
67
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
185
68
  finding,
186
69
  findingSites: findingSites || [],
187
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
188
- use3DSpatialCoordinates: true
70
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
71
+ use3DSpatialCoordinates: is3DMeasurement
189
72
  };
190
73
  }
191
74
  }
@@ -1,36 +1,24 @@
1
1
  import BaseAdapter3D from "./BaseAdapter3D";
2
2
  declare class ArrowAnnotate extends BaseAdapter3D {
3
- static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, imageToWorldCoords: any, metadata: any, _trackingIdentifier: any): any;
4
- static getMeasurementDataFromScoord3D({ SCOORD3DGroup, defaultState, text }: {
5
- SCOORD3DGroup: any;
6
- defaultState: any;
7
- text: any;
8
- }): any;
9
- static getMeasurementDataFromScoord({ SCOORDGroup, referencedImageId, metadata, imageToWorldCoords, defaultState, text, ReferencedFrameNumber }: {
10
- SCOORDGroup: any;
11
- referencedImageId: any;
12
- metadata: any;
13
- imageToWorldCoords: any;
14
- defaultState: any;
15
- text: any;
16
- ReferencedFrameNumber: any;
17
- }): any;
18
- static getTID300RepresentationArguments(tool: any, worldToImageCoords: any): {
19
- points: {
20
- x: any;
21
- y: any;
22
- }[];
23
- trackingIdentifierTextValue: string;
24
- findingSites: any;
25
- finding: any;
26
- use3DSpatialCoordinates: boolean;
3
+ static getMeasurementData(MeasurementGroup: any, sopInstanceUIDToImageIdMap: any, metadata: any, _trackingIdentifier: any): {
4
+ description?: string;
5
+ sopInstanceUid?: string;
6
+ annotation: import("packages/tools/dist/esm/types").Annotation;
7
+ finding?: unknown;
8
+ findingSites?: unknown;
9
+ commentGroup?: any;
10
+ commentPositionGroup?: any;
27
11
  };
28
- static getTID300RepresentationArgumentsSCOORD3D(tool: any): {
29
- points: {
12
+ static getTID300RepresentationArguments(tool: any, is3DMeasurement?: boolean): {
13
+ points: ({
30
14
  x: any;
31
15
  y: any;
32
16
  z: any;
33
- }[];
17
+ } | {
18
+ x: number;
19
+ y: number;
20
+ z?: undefined;
21
+ })[];
34
22
  trackingIdentifierTextValue: string;
35
23
  findingSites: any;
36
24
  finding: any;