@cornerstonejs/tools 1.4.3 → 1.4.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 (50) hide show
  1. package/dist/cjs/tools/annotation/CircleROITool.d.ts +3 -2
  2. package/dist/cjs/tools/annotation/CircleROITool.js +15 -12
  3. package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
  4. package/dist/cjs/tools/annotation/DragProbeTool.js +7 -5
  5. package/dist/cjs/tools/annotation/DragProbeTool.js.map +1 -1
  6. package/dist/cjs/tools/annotation/EllipticalROITool.d.ts +3 -2
  7. package/dist/cjs/tools/annotation/EllipticalROITool.js +15 -12
  8. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  9. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +3 -2
  10. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +15 -12
  11. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  12. package/dist/cjs/tools/annotation/ProbeTool.d.ts +3 -3
  13. package/dist/cjs/tools/annotation/ProbeTool.js +19 -45
  14. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  15. package/dist/cjs/tools/annotation/RectangleROITool.d.ts +2 -2
  16. package/dist/cjs/tools/annotation/RectangleROITool.js +15 -12
  17. package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
  18. package/dist/cjs/utilities/getModalityUnit.d.ts +6 -2
  19. package/dist/cjs/utilities/getModalityUnit.js +14 -5
  20. package/dist/cjs/utilities/getModalityUnit.js.map +1 -1
  21. package/dist/esm/tools/annotation/CircleROITool.d.ts +3 -2
  22. package/dist/esm/tools/annotation/CircleROITool.js +16 -13
  23. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  24. package/dist/esm/tools/annotation/DragProbeTool.js +7 -5
  25. package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
  26. package/dist/esm/tools/annotation/EllipticalROITool.d.ts +3 -2
  27. package/dist/esm/tools/annotation/EllipticalROITool.js +16 -13
  28. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  29. package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +3 -2
  30. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +16 -13
  31. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  32. package/dist/esm/tools/annotation/ProbeTool.d.ts +3 -3
  33. package/dist/esm/tools/annotation/ProbeTool.js +16 -45
  34. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  35. package/dist/esm/tools/annotation/RectangleROITool.d.ts +2 -2
  36. package/dist/esm/tools/annotation/RectangleROITool.js +15 -12
  37. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  38. package/dist/esm/utilities/getModalityUnit.d.ts +6 -2
  39. package/dist/esm/utilities/getModalityUnit.js +14 -5
  40. package/dist/esm/utilities/getModalityUnit.js.map +1 -1
  41. package/dist/umd/index.js +1 -1
  42. package/dist/umd/index.js.map +1 -1
  43. package/package.json +3 -3
  44. package/src/tools/annotation/CircleROITool.ts +33 -28
  45. package/src/tools/annotation/DragProbeTool.ts +23 -16
  46. package/src/tools/annotation/EllipticalROITool.ts +33 -29
  47. package/src/tools/annotation/PlanarFreehandROITool.ts +32 -27
  48. package/src/tools/annotation/ProbeTool.ts +44 -71
  49. package/src/tools/annotation/RectangleROITool.ts +30 -28
  50. package/src/utilities/getModalityUnit.ts +25 -9
@@ -649,6 +649,16 @@ class RectangleROITool extends AnnotationTool {
649
649
 
650
650
  const { viewPlaneNormal, viewUp } = viewport.getCamera();
651
651
 
652
+ const modalityUnitOptions = {
653
+ isPreScaled: isViewportPreScaled(viewport, targetId),
654
+
655
+ isSuvScaled: this.isSuvScaled(
656
+ viewport,
657
+ targetId,
658
+ annotation.metadata.referencedImageId
659
+ ),
660
+ };
661
+
652
662
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
653
663
  // force to recalculate the stats from the points
654
664
  if (
@@ -669,7 +679,8 @@ class RectangleROITool extends AnnotationTool {
669
679
  viewPlaneNormal,
670
680
  viewUp,
671
681
  renderingEngine,
672
- enabledElement
682
+ enabledElement,
683
+ modalityUnitOptions
673
684
  );
674
685
  } else if (annotation.invalidated) {
675
686
  this._throttledCalculateCachedStats(
@@ -677,7 +688,8 @@ class RectangleROITool extends AnnotationTool {
677
688
  viewPlaneNormal,
678
689
  viewUp,
679
690
  renderingEngine,
680
- enabledElement
691
+ enabledElement,
692
+ modalityUnitOptions
681
693
  );
682
694
 
683
695
  // If the invalidated data is as a result of volumeViewport manipulation
@@ -769,20 +781,7 @@ class RectangleROITool extends AnnotationTool {
769
781
 
770
782
  renderStatus = true;
771
783
 
772
- const isPreScaled = isViewportPreScaled(viewport, targetId);
773
-
774
- const isSuvScaled = this.isSuvScaled(
775
- viewport,
776
- targetId,
777
- annotation.metadata.referencedImageId
778
- );
779
-
780
- const textLines = this._getTextLines(
781
- data,
782
- targetId,
783
- isPreScaled,
784
- isSuvScaled
785
- );
784
+ const textLines = this._getTextLines(data, targetId);
786
785
  if (!textLines || textLines.length === 0) {
787
786
  continue;
788
787
  }
@@ -849,26 +848,21 @@ class RectangleROITool extends AnnotationTool {
849
848
  * @param targetId - The volumeId of the volume to display the stats for.
850
849
  * @param isPreScaled - Whether the viewport is pre-scaled or not.
851
850
  */
852
- _getTextLines = (
853
- data,
854
- targetId: string,
855
- isPreScaled: boolean,
856
- isSuvScaled: boolean
857
- ): string[] | undefined => {
851
+ _getTextLines = (data, targetId: string): string[] | undefined => {
858
852
  const cachedVolumeStats = data.cachedStats[targetId];
859
- const { area, mean, max, stdDev, Modality, areaUnit } = cachedVolumeStats;
853
+ const { area, mean, max, stdDev, areaUnit, modalityUnit } =
854
+ cachedVolumeStats;
860
855
 
861
856
  if (mean === undefined) {
862
857
  return;
863
858
  }
864
859
 
865
860
  const textLines: string[] = [];
866
- const unit = getModalityUnit(Modality, isPreScaled, isSuvScaled);
867
861
 
868
862
  textLines.push(`Area: ${area.toFixed(2)} ${areaUnit}\xb2`);
869
- textLines.push(`Mean: ${mean.toFixed(2)} ${unit}`);
870
- textLines.push(`Max: ${max.toFixed(2)} ${unit}`);
871
- textLines.push(`Std Dev: ${stdDev.toFixed(2)} ${unit}`);
863
+ textLines.push(`Mean: ${mean.toFixed(2)} ${modalityUnit}`);
864
+ textLines.push(`Max: ${max.toFixed(2)} ${modalityUnit}`);
865
+ textLines.push(`Std Dev: ${stdDev.toFixed(2)} ${modalityUnit}`);
872
866
 
873
867
  return textLines;
874
868
  };
@@ -889,7 +883,8 @@ class RectangleROITool extends AnnotationTool {
889
883
  viewPlaneNormal,
890
884
  viewUp,
891
885
  renderingEngine,
892
- enabledElement
886
+ enabledElement,
887
+ modalityUnitOptions
893
888
  ) => {
894
889
  const { data } = annotation;
895
890
  const { viewportId, renderingEngineId } = enabledElement;
@@ -997,6 +992,12 @@ class RectangleROITool extends AnnotationTool {
997
992
  stdDev /= count;
998
993
  stdDev = Math.sqrt(stdDev);
999
994
 
995
+ const modalityUnit = getModalityUnit(
996
+ metadata.Modality,
997
+ annotation.metadata.referencedImageId,
998
+ modalityUnitOptions
999
+ );
1000
+
1000
1001
  cachedStats[targetId] = {
1001
1002
  Modality: metadata.Modality,
1002
1003
  area,
@@ -1004,6 +1005,7 @@ class RectangleROITool extends AnnotationTool {
1004
1005
  stdDev,
1005
1006
  max,
1006
1007
  areaUnit: hasPixelSpacing ? 'mm' : 'px',
1008
+ modalityUnit,
1007
1009
  };
1008
1010
  } else {
1009
1011
  this.isHandleOutsideImage = true;
@@ -1,19 +1,35 @@
1
+ import { metaData } from '@cornerstonejs/core';
2
+
3
+ type ModalityUnitOptions = {
4
+ isPreScaled: boolean;
5
+ isSuvScaled: boolean;
6
+ };
7
+
1
8
  function getModalityUnit(
2
9
  modality: string,
3
- isPreScaled: boolean,
4
- isSuvScaled: boolean
10
+ imageId: string,
11
+ options: ModalityUnitOptions
5
12
  ): string {
6
13
  if (modality === 'CT') {
7
14
  return 'HU';
8
- } else if (
9
- modality === 'PT' &&
10
- isPreScaled === true &&
11
- isSuvScaled === true
12
- ) {
13
- return 'SUV';
15
+ } else if (modality === 'PT') {
16
+ return _handlePTModality(imageId, options);
14
17
  } else {
15
18
  return '';
16
19
  }
17
20
  }
18
21
 
19
- export { getModalityUnit };
22
+ function _handlePTModality(imageId: string, options: ModalityUnitOptions) {
23
+ if (!options.isPreScaled) {
24
+ return 'raw';
25
+ }
26
+
27
+ if (options.isSuvScaled) {
28
+ return 'SUV';
29
+ }
30
+
31
+ const petSeriesModule = metaData.get('petSeriesModule', imageId);
32
+ return petSeriesModule?.units || 'unitless';
33
+ }
34
+
35
+ export { getModalityUnit, ModalityUnitOptions };