@cornerstonejs/tools 1.20.1 → 1.20.3

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 (48) hide show
  1. package/dist/cjs/tools/annotation/CircleROITool.d.ts +1 -2
  2. package/dist/cjs/tools/annotation/CircleROITool.js +7 -7
  3. package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
  4. package/dist/cjs/tools/annotation/DragProbeTool.js +2 -2
  5. package/dist/cjs/tools/annotation/DragProbeTool.js.map +1 -1
  6. package/dist/cjs/tools/annotation/EllipticalROITool.d.ts +1 -2
  7. package/dist/cjs/tools/annotation/EllipticalROITool.js +7 -7
  8. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  9. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +1 -2
  10. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +7 -7
  11. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  12. package/dist/cjs/tools/annotation/ProbeTool.d.ts +1 -2
  13. package/dist/cjs/tools/annotation/ProbeTool.js +8 -8
  14. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  15. package/dist/cjs/tools/annotation/RectangleROITool.d.ts +1 -1
  16. package/dist/cjs/tools/annotation/RectangleROITool.js +8 -8
  17. package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
  18. package/dist/cjs/utilities/getModalityUnit.js +5 -2
  19. package/dist/cjs/utilities/getModalityUnit.js.map +1 -1
  20. package/dist/esm/tools/annotation/CircleROITool.d.ts +1 -2
  21. package/dist/esm/tools/annotation/CircleROITool.js +7 -7
  22. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  23. package/dist/esm/tools/annotation/DragProbeTool.js +2 -2
  24. package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
  25. package/dist/esm/tools/annotation/EllipticalROITool.d.ts +1 -2
  26. package/dist/esm/tools/annotation/EllipticalROITool.js +7 -7
  27. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  28. package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +1 -2
  29. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +7 -7
  30. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  31. package/dist/esm/tools/annotation/ProbeTool.d.ts +1 -2
  32. package/dist/esm/tools/annotation/ProbeTool.js +8 -8
  33. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  34. package/dist/esm/tools/annotation/RectangleROITool.d.ts +1 -1
  35. package/dist/esm/tools/annotation/RectangleROITool.js +8 -8
  36. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  37. package/dist/esm/utilities/getModalityUnit.js +5 -2
  38. package/dist/esm/utilities/getModalityUnit.js.map +1 -1
  39. package/dist/umd/index.js +1 -1
  40. package/dist/umd/index.js.map +1 -1
  41. package/package.json +3 -3
  42. package/src/tools/annotation/CircleROITool.ts +12 -19
  43. package/src/tools/annotation/DragProbeTool.ts +2 -12
  44. package/src/tools/annotation/EllipticalROITool.ts +13 -19
  45. package/src/tools/annotation/PlanarFreehandROITool.ts +12 -15
  46. package/src/tools/annotation/ProbeTool.ts +13 -29
  47. package/src/tools/annotation/RectangleROITool.ts +14 -18
  48. package/src/utilities/getModalityUnit.ts +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.20.1",
3
+ "version": "1.20.3",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.20.1",
32
+ "@cornerstonejs/core": "^1.20.3",
33
33
  "lodash.clonedeep": "4.5.0",
34
34
  "lodash.get": "^4.4.2"
35
35
  },
@@ -52,5 +52,5 @@
52
52
  "type": "individual",
53
53
  "url": "https://ohif.org/donate"
54
54
  },
55
- "gitHead": "d1f465525fe3efe01c74d04cc07ec47308e12d6a"
55
+ "gitHead": "432144a2ffb7cafc1f0ed4e9a25e5feaed5630d6"
56
56
  }
@@ -44,7 +44,6 @@ import {
44
44
  TextBoxHandle,
45
45
  PublicToolProps,
46
46
  ToolProps,
47
- InteractionTypes,
48
47
  SVGDrawingHelper,
49
48
  } from '../../types';
50
49
  import { CircleROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
@@ -52,8 +51,6 @@ import { CircleROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
52
51
  import {
53
52
  AnnotationCompletedEventDetail,
54
53
  AnnotationModifiedEventDetail,
55
- MouseDragEventType,
56
- MouseMoveEventType,
57
54
  } from '../../types/EventTypes';
58
55
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
59
56
  import { pointInShapeCallback } from '../../utilities';
@@ -678,16 +675,6 @@ class CircleROITool extends AnnotationTool {
678
675
 
679
676
  const { centerPointRadius } = this.configuration;
680
677
 
681
- const modalityUnitOptions = {
682
- isPreScaled: isViewportPreScaled(viewport, targetId),
683
-
684
- isSuvScaled: this.isSuvScaled(
685
- viewport,
686
- targetId,
687
- annotation.metadata.referencedImageId
688
- ),
689
- };
690
-
691
678
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
692
679
  // force to recalculate the stats from the points
693
680
  if (
@@ -710,16 +697,14 @@ class CircleROITool extends AnnotationTool {
710
697
  annotation,
711
698
  viewport,
712
699
  renderingEngine,
713
- enabledElement,
714
- modalityUnitOptions
700
+ enabledElement
715
701
  );
716
702
  } else if (annotation.invalidated) {
717
703
  this._throttledCalculateCachedStats(
718
704
  annotation,
719
705
  viewport,
720
706
  renderingEngine,
721
- enabledElement,
722
- modalityUnitOptions
707
+ enabledElement
723
708
  );
724
709
  // If the invalidated data is as a result of volumeViewport manipulation
725
710
  // of the tools, we need to invalidate the related viewports data, so that
@@ -889,8 +874,7 @@ class CircleROITool extends AnnotationTool {
889
874
  annotation,
890
875
  viewport,
891
876
  renderingEngine,
892
- enabledElement,
893
- modalityUnitOptions: ModalityUnitOptions
877
+ enabledElement
894
878
  ) => {
895
879
  const data = annotation.data;
896
880
  const { viewportId, renderingEngineId } = enabledElement;
@@ -985,6 +969,15 @@ class CircleROITool extends AnnotationTool {
985
969
  (worldHeight / aspect / scale / 2)
986
970
  );
987
971
 
972
+ const modalityUnitOptions = {
973
+ isPreScaled: isViewportPreScaled(viewport, targetId),
974
+ isSuvScaled: this.isSuvScaled(
975
+ viewport,
976
+ targetId,
977
+ annotation.metadata.referencedImageId
978
+ ),
979
+ };
980
+
988
981
  const modalityUnit = getModalityUnit(
989
982
  metadata.Modality,
990
983
  annotation.metadata.referencedImageId,
@@ -176,19 +176,9 @@ class DragProbeTool extends ProbeTool {
176
176
  value: null,
177
177
  };
178
178
 
179
- this._calculateCachedStats(
180
- annotation,
181
- renderingEngine,
182
- enabledElement,
183
- modalityUnitOptions
184
- );
179
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
185
180
  } else if (annotation.invalidated) {
186
- this._calculateCachedStats(
187
- annotation,
188
- renderingEngine,
189
- enabledElement,
190
- modalityUnitOptions
191
- );
181
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
192
182
  }
193
183
 
194
184
  // If rendering engine has been destroyed while rendering
@@ -47,7 +47,6 @@ import {
47
47
  TextBoxHandle,
48
48
  PublicToolProps,
49
49
  ToolProps,
50
- InteractionTypes,
51
50
  SVGDrawingHelper,
52
51
  } from '../../types';
53
52
  import { EllipticalROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
@@ -55,8 +54,6 @@ import { EllipticalROIAnnotation } from '../../types/ToolSpecificAnnotationTypes
55
54
  import {
56
55
  AnnotationCompletedEventDetail,
57
56
  AnnotationModifiedEventDetail,
58
- MouseDragEventType,
59
- MouseMoveEventType,
60
57
  } from '../../types/EventTypes';
61
58
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
62
59
  import { pointInShapeCallback } from '../../utilities/';
@@ -800,16 +797,6 @@ class EllipticalROITool extends AnnotationTool {
800
797
 
801
798
  const { centerPointRadius } = this.configuration;
802
799
 
803
- const modalityUnitOptions = {
804
- isPreScaled: isViewportPreScaled(viewport, targetId),
805
-
806
- isSuvScaled: this.isSuvScaled(
807
- viewport,
808
- targetId,
809
- annotation.metadata.referencedImageId
810
- ),
811
- };
812
-
813
800
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
814
801
  // force to recalculate the stats from the points
815
802
  if (
@@ -829,16 +816,14 @@ class EllipticalROITool extends AnnotationTool {
829
816
  annotation,
830
817
  viewport,
831
818
  renderingEngine,
832
- enabledElement,
833
- modalityUnitOptions
819
+ enabledElement
834
820
  );
835
821
  } else if (annotation.invalidated) {
836
822
  this._throttledCalculateCachedStats(
837
823
  annotation,
838
824
  viewport,
839
825
  renderingEngine,
840
- enabledElement,
841
- modalityUnitOptions
826
+ enabledElement
842
827
  );
843
828
  // If the invalidated data is as a result of volumeViewport manipulation
844
829
  // of the tools, we need to invalidate the related viewports data, so that
@@ -1013,8 +998,7 @@ class EllipticalROITool extends AnnotationTool {
1013
998
  annotation,
1014
999
  viewport,
1015
1000
  renderingEngine,
1016
- enabledElement,
1017
- modalityUnitOptions: ModalityUnitOptions
1001
+ enabledElement
1018
1002
  ) => {
1019
1003
  const data = annotation.data;
1020
1004
  const { viewportId, renderingEngineId } = enabledElement;
@@ -1107,6 +1091,16 @@ class EllipticalROITool extends AnnotationTool {
1107
1091
  scale /
1108
1092
  scale;
1109
1093
 
1094
+ const modalityUnitOptions = {
1095
+ isPreScaled: isViewportPreScaled(viewport, targetId),
1096
+
1097
+ isSuvScaled: this.isSuvScaled(
1098
+ viewport,
1099
+ targetId,
1100
+ annotation.metadata.referencedImageId
1101
+ ),
1102
+ };
1103
+
1110
1104
  const modalityUnit = getModalityUnit(
1111
1105
  metadata.Modality,
1112
1106
  annotation.metadata.referencedImageId,
@@ -678,15 +678,6 @@ class PlanarFreehandROITool extends AnnotationTool {
678
678
  return;
679
679
  }
680
680
 
681
- const modalityUnitOptions = {
682
- isPreScaled: isViewportPreScaled(viewport, targetId),
683
- isSuvScaled: this.isSuvScaled(
684
- viewport,
685
- targetId,
686
- annotation.metadata.referencedImageId
687
- ),
688
- };
689
-
690
681
  if (!this.commonData?.movingTextBox) {
691
682
  const { data } = annotation;
692
683
  if (
@@ -706,16 +697,14 @@ class PlanarFreehandROITool extends AnnotationTool {
706
697
  annotation,
707
698
  viewport,
708
699
  renderingEngine,
709
- enabledElement,
710
- modalityUnitOptions
700
+ enabledElement
711
701
  );
712
702
  } else if (annotation.invalidated) {
713
703
  this._throttledCalculateCachedStats(
714
704
  annotation,
715
705
  viewport,
716
706
  renderingEngine,
717
- enabledElement,
718
- modalityUnitOptions
707
+ enabledElement
719
708
  );
720
709
  }
721
710
  }
@@ -730,8 +719,7 @@ class PlanarFreehandROITool extends AnnotationTool {
730
719
  annotation,
731
720
  viewport,
732
721
  renderingEngine,
733
- enabledElement,
734
- modalityUnitOptions: ModalityUnitOptions
722
+ enabledElement
735
723
  ) => {
736
724
  const data = annotation.data;
737
725
  const { cachedStats, polyline: points } = data;
@@ -868,6 +856,15 @@ class PlanarFreehandROITool extends AnnotationTool {
868
856
  boundsIJK
869
857
  );
870
858
 
859
+ const modalityUnitOptions = {
860
+ isPreScaled: isViewportPreScaled(viewport, targetId),
861
+ isSuvScaled: this.isSuvScaled(
862
+ viewport,
863
+ targetId,
864
+ annotation.metadata.referencedImageId
865
+ ),
866
+ };
867
+
871
868
  const modalityUnit = getModalityUnit(
872
869
  metadata.Modality,
873
870
  annotation.metadata.referencedImageId,
@@ -442,16 +442,6 @@ class ProbeTool extends AnnotationTool {
442
442
 
443
443
  const color = this.getStyle('color', styleSpecifier, annotation);
444
444
 
445
- const modalityUnitOptions = {
446
- isPreScaled: isViewportPreScaled(viewport, targetId),
447
-
448
- isSuvScaled: this.isSuvScaled(
449
- viewport,
450
- targetId,
451
- annotation.metadata.referencedImageId
452
- ),
453
- };
454
-
455
445
  if (
456
446
  !data.cachedStats[targetId] ||
457
447
  data.cachedStats[targetId].value == null
@@ -462,19 +452,9 @@ class ProbeTool extends AnnotationTool {
462
452
  value: null,
463
453
  };
464
454
 
465
- this._calculateCachedStats(
466
- annotation,
467
- renderingEngine,
468
- enabledElement,
469
- modalityUnitOptions
470
- );
455
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
471
456
  } else if (annotation.invalidated) {
472
- this._calculateCachedStats(
473
- annotation,
474
- renderingEngine,
475
- enabledElement,
476
- modalityUnitOptions
477
- );
457
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
478
458
 
479
459
  // If the invalidated data is as a result of volumeViewport manipulation
480
460
  // of the tools, we need to invalidate the related stackViewports data if
@@ -557,14 +537,9 @@ class ProbeTool extends AnnotationTool {
557
537
  return renderStatus;
558
538
  };
559
539
 
560
- _calculateCachedStats(
561
- annotation,
562
- renderingEngine,
563
- enabledElement,
564
- modalityUnitOptions: ModalityUnitOptions
565
- ) {
540
+ _calculateCachedStats(annotation, renderingEngine, enabledElement) {
566
541
  const data = annotation.data;
567
- const { viewportId, renderingEngineId } = enabledElement;
542
+ const { viewportId, renderingEngineId, viewport } = enabledElement;
568
543
 
569
544
  const worldPos = data.handles.points[0];
570
545
  const { cachedStats } = data;
@@ -574,6 +549,15 @@ class ProbeTool extends AnnotationTool {
574
549
  for (let i = 0; i < targetIds.length; i++) {
575
550
  const targetId = targetIds[i];
576
551
 
552
+ const modalityUnitOptions = {
553
+ isPreScaled: isViewportPreScaled(viewport, targetId),
554
+ isSuvScaled: this.isSuvScaled(
555
+ viewport,
556
+ targetId,
557
+ annotation.metadata.referencedImageId
558
+ ),
559
+ };
560
+
577
561
  const image = this.getTargetIdImage(targetId, renderingEngine);
578
562
 
579
563
  // If image does not exists for the targetId, skip. This can be due
@@ -45,7 +45,6 @@ import {
45
45
  TextBoxHandle,
46
46
  ToolProps,
47
47
  PublicToolProps,
48
- InteractionTypes,
49
48
  SVGDrawingHelper,
50
49
  } from '../../types';
51
50
  import { RectangleROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
@@ -659,16 +658,6 @@ class RectangleROITool extends AnnotationTool {
659
658
 
660
659
  const { viewPlaneNormal, viewUp } = viewport.getCamera();
661
660
 
662
- const modalityUnitOptions = {
663
- isPreScaled: isViewportPreScaled(viewport, targetId),
664
-
665
- isSuvScaled: this.isSuvScaled(
666
- viewport,
667
- targetId,
668
- annotation.metadata.referencedImageId
669
- ),
670
- };
671
-
672
661
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
673
662
  // force to recalculate the stats from the points
674
663
  if (
@@ -689,8 +678,7 @@ class RectangleROITool extends AnnotationTool {
689
678
  viewPlaneNormal,
690
679
  viewUp,
691
680
  renderingEngine,
692
- enabledElement,
693
- modalityUnitOptions
681
+ enabledElement
694
682
  );
695
683
  } else if (annotation.invalidated) {
696
684
  this._throttledCalculateCachedStats(
@@ -698,8 +686,7 @@ class RectangleROITool extends AnnotationTool {
698
686
  viewPlaneNormal,
699
687
  viewUp,
700
688
  renderingEngine,
701
- enabledElement,
702
- modalityUnitOptions
689
+ enabledElement
703
690
  );
704
691
 
705
692
  // If the invalidated data is as a result of volumeViewport manipulation
@@ -881,11 +868,10 @@ class RectangleROITool extends AnnotationTool {
881
868
  viewPlaneNormal,
882
869
  viewUp,
883
870
  renderingEngine,
884
- enabledElement,
885
- modalityUnitOptions
871
+ enabledElement
886
872
  ) => {
887
873
  const { data } = annotation;
888
- const { viewportId, renderingEngineId } = enabledElement;
874
+ const { viewportId, renderingEngineId, viewport } = enabledElement;
889
875
 
890
876
  const worldPos1 = data.handles.points[0];
891
877
  const worldPos2 = data.handles.points[3];
@@ -954,6 +940,16 @@ class RectangleROITool extends AnnotationTool {
954
940
 
955
941
  const area = Math.abs(worldWidth * worldHeight) / (scale * scale);
956
942
 
943
+ const modalityUnitOptions = {
944
+ isPreScaled: isViewportPreScaled(viewport, targetId),
945
+
946
+ isSuvScaled: this.isSuvScaled(
947
+ viewport,
948
+ targetId,
949
+ annotation.metadata.referencedImageId
950
+ ),
951
+ };
952
+
957
953
  const modalityUnit = getModalityUnit(
958
954
  metadata.Modality,
959
955
  annotation.metadata.referencedImageId,
@@ -28,8 +28,14 @@ function _handlePTModality(imageId: string, options: ModalityUnitOptions) {
28
28
  return 'SUV';
29
29
  }
30
30
 
31
- const petSeriesModule = metaData.get('petSeriesModule', imageId);
32
- return petSeriesModule?.units || 'unitless';
31
+ const generalSeriesModule = metaData.get('generalSeriesModule', imageId);
32
+
33
+ // it might be possible that the referenceImageId is not the one
34
+ // that is being displayed. So we need to get the modality from imageId again
35
+ if (generalSeriesModule?.modality === 'PT') {
36
+ const petSeriesModule = metaData.get('petSeriesModule', imageId);
37
+ return petSeriesModule?.units || 'unitless';
38
+ }
33
39
  }
34
40
 
35
41
  export { getModalityUnit, ModalityUnitOptions };