@cornerstonejs/adapters 4.22.9 → 4.22.11

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.
@@ -58,9 +58,9 @@ class PlanarFreehandROI extends BaseAdapter3D {
58
58
  });
59
59
  if (referencedImageId) {
60
60
  state.annotation.data.cachedStats = {
61
- ["imageId:".concat(referencedImageId)]: _objectSpread({
62
- area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
63
- }, restoreAdditionalMetrics(measurementNUMGroups))
61
+ ["imageId:".concat(referencedImageId)]: _objectSpread(_objectSpread({}, !isOpenContour && NUMGroup ? {
62
+ area: NUMGroup.MeasuredValueSequence.NumericValue
63
+ } : {}), restoreAdditionalMetrics(measurementNUMGroups))
64
64
  };
65
65
  }
66
66
  return state;
@@ -6,6 +6,7 @@ import '../helpers/scoordToWorld.js';
6
6
  import MeasurementReport from './MeasurementReport.js';
7
7
  import BaseAdapter3D from './BaseAdapter3D.js';
8
8
  import { extractAllNUMGroups, restoreAdditionalMetrics } from './metricHandler.js';
9
+ import { mapUnitFromUCUM } from './unitMapper.js';
9
10
 
10
11
  var _RectangleROI;
11
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -29,11 +30,15 @@ class RectangleROI extends BaseAdapter3D {
29
30
  const referencedSOPInstanceUID = state.sopInstanceUid;
30
31
  const allNUMGroups = extractAllNUMGroups(MeasurementGroup, referencedSOPInstanceUID);
31
32
  const measurementNUMGroups = allNUMGroups[referencedSOPInstanceUID] || {};
33
+ const restoredMetrics = restoreAdditionalMetrics(measurementNUMGroups);
34
+ const rawAreaUnit = areaGroup === null || areaGroup === void 0 || (_areaGroup$MeasuredVa = areaGroup.MeasuredValueSequence) === null || _areaGroup$MeasuredVa === void 0 || (_areaGroup$MeasuredVa = _areaGroup$MeasuredVa[0]) === null || _areaGroup$MeasuredVa === void 0 ? void 0 : _areaGroup$MeasuredVa.MeasurementUnitsCodeSequence;
35
+ const areaUnitFromSR = rawAreaUnit === null || rawAreaUnit === void 0 ? void 0 : rawAreaUnit.CodeValue;
36
+ const mappedAreaUnit = areaUnitFromSR ? mapUnitFromUCUM(areaUnitFromSR) : restoredMetrics.areaUnit;
32
37
  const cachedStats = referencedImageId ? {
33
38
  ["imageId:".concat(referencedImageId)]: _objectSpread({
34
- area: (areaGroup === null || areaGroup === void 0 || (_areaGroup$MeasuredVa = areaGroup.MeasuredValueSequence) === null || _areaGroup$MeasuredVa === void 0 || (_areaGroup$MeasuredVa = _areaGroup$MeasuredVa[0]) === null || _areaGroup$MeasuredVa === void 0 ? void 0 : _areaGroup$MeasuredVa.NumericValue) || 0,
35
- areaUnit: areaGroup === null || areaGroup === void 0 || (_areaGroup$MeasuredVa2 = areaGroup.MeasuredValueSequence) === null || _areaGroup$MeasuredVa2 === void 0 || (_areaGroup$MeasuredVa2 = _areaGroup$MeasuredVa2[0]) === null || _areaGroup$MeasuredVa2 === void 0 || (_areaGroup$MeasuredVa2 = _areaGroup$MeasuredVa2.MeasurementUnitsCodeSequence) === null || _areaGroup$MeasuredVa2 === void 0 ? void 0 : _areaGroup$MeasuredVa2.CodeValue
36
- }, restoreAdditionalMetrics(measurementNUMGroups))
39
+ area: (areaGroup === null || areaGroup === void 0 || (_areaGroup$MeasuredVa2 = areaGroup.MeasuredValueSequence) === null || _areaGroup$MeasuredVa2 === void 0 || (_areaGroup$MeasuredVa2 = _areaGroup$MeasuredVa2[0]) === null || _areaGroup$MeasuredVa2 === void 0 ? void 0 : _areaGroup$MeasuredVa2.NumericValue) || 0,
40
+ areaUnit: mappedAreaUnit
41
+ }, restoredMetrics)
37
42
  } : {};
38
43
  const handlesPoints = [points[0], points[1], points[3], points[2]];
39
44
  state.annotation.data = _objectSpread(_objectSpread({}, state.annotation.data), {}, {
@@ -1,5 +1,7 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import { mapUnitFromUCUM } from './unitMapper.js';
2
3
 
4
+ const INTENSITY_METRICS = new Set(['Mean', 'Standard Deviation', 'Maximum', 'Minimum']);
3
5
  function extractAllNUMGroups(MeasurementGroup, referencedSOPInstanceUID) {
4
6
  const numGroupsBySOPInstanceUID = {};
5
7
  if (MeasurementGroup.ContentSequence) {
@@ -13,9 +15,13 @@ function extractAllNUMGroups(MeasurementGroup, referencedSOPInstanceUID) {
13
15
  if (!numGroupsBySOPInstanceUID[referencedSOPInstanceUID]) {
14
16
  numGroupsBySOPInstanceUID[referencedSOPInstanceUID] = {};
15
17
  }
18
+ let unit = '';
19
+ if (unitCode) {
20
+ unit = resolveUnit(codeMeaning, unitCode);
21
+ }
16
22
  numGroupsBySOPInstanceUID[referencedSOPInstanceUID][codeMeaning] = {
17
23
  value: numericValue,
18
- unit: unitCode || ''
24
+ unit
19
25
  };
20
26
  }
21
27
  }
@@ -38,8 +44,14 @@ function restoreAdditionalMetrics(numGroups) {
38
44
  Width: 'width'
39
45
  };
40
46
  const unitCategory = {
47
+ mean: 'modalityUnit',
48
+ stdDev: 'modalityUnit',
49
+ max: 'modalityUnit',
50
+ min: 'modalityUnit',
41
51
  area: 'areaUnit',
42
52
  radius: 'radiusUnit',
53
+ perimeter: 'unit',
54
+ length: 'unit',
43
55
  width: 'widthUnit'
44
56
  };
45
57
  for (const _ref of Object.entries(metricMapping)) {
@@ -59,20 +71,38 @@ function restoreAdditionalMetrics(numGroups) {
59
71
  if (!unit) {
60
72
  continue;
61
73
  }
62
- if (!modalityUnit) {
63
- modalityUnit = unit;
74
+ const mappedUnit = mapUnitFromUCUM(unit);
75
+ if (!mappedUnit) {
76
+ continue;
77
+ }
78
+ if (INTENSITY_METRICS.has(codeMeaning) && !modalityUnit) {
79
+ modalityUnit = mappedUnit;
64
80
  }
65
81
  const category = unitCategory[metricKey];
66
82
  if (category) {
67
83
  if (!additionalMetrics[category]) {
68
- additionalMetrics[category] = unit;
84
+ additionalMetrics[category] = mappedUnit;
69
85
  }
70
86
  } else {
71
- additionalMetrics["".concat(metricKey, "Unit")] = unit;
87
+ additionalMetrics["".concat(metricKey, "Unit")] = mappedUnit;
72
88
  }
73
89
  }
74
90
  additionalMetrics.modalityUnit = modalityUnit;
75
91
  return additionalMetrics;
76
92
  }
93
+ function resolveUnit(codeMeaning, unitCode) {
94
+ if (!unitCode) {
95
+ return '';
96
+ }
97
+ const CodeValue = unitCode.CodeValue,
98
+ CodeMeaning = unitCode.CodeMeaning;
99
+ if (CodeValue === '1') {
100
+ if (!INTENSITY_METRICS.has(codeMeaning) && codeMeaning === 'Area') {
101
+ return "".concat(CodeMeaning, "\xB2");
102
+ }
103
+ return INTENSITY_METRICS.has(codeMeaning) ? '' : CodeMeaning;
104
+ }
105
+ return CodeValue;
106
+ }
77
107
 
78
108
  export { extractAllNUMGroups, restoreAdditionalMetrics };
@@ -0,0 +1,5 @@
1
+ export declare const UCUM_HOUNSFIELD_UNIT = "[hnsf'U]";
2
+ export declare const DISPLAY_HOUNSFIELD_UNIT = "HU";
3
+ export declare const UCUM_SQUARE_MILLIMETER = "mm2";
4
+ export declare const DISPLAY_SQUARE_MILLIMETER = "mm\u00B2";
5
+ export declare function mapUnitFromUCUM(unit: string | undefined): string | undefined;
@@ -0,0 +1,16 @@
1
+ const UCUM_HOUNSFIELD_UNIT = "[hnsf'U]";
2
+ const DISPLAY_HOUNSFIELD_UNIT = 'HU';
3
+ const UCUM_SQUARE_MILLIMETER = 'mm2';
4
+ const DISPLAY_SQUARE_MILLIMETER = 'mm²';
5
+ const UNIT_MAP_FROM_UCUM = {
6
+ [UCUM_HOUNSFIELD_UNIT]: DISPLAY_HOUNSFIELD_UNIT,
7
+ [UCUM_SQUARE_MILLIMETER]: DISPLAY_SQUARE_MILLIMETER
8
+ };
9
+ function mapUnitFromUCUM(unit) {
10
+ if (!unit) {
11
+ return unit;
12
+ }
13
+ return UNIT_MAP_FROM_UCUM[unit] || unit;
14
+ }
15
+
16
+ export { DISPLAY_HOUNSFIELD_UNIT, DISPLAY_SQUARE_MILLIMETER, UCUM_HOUNSFIELD_UNIT, UCUM_SQUARE_MILLIMETER, mapUnitFromUCUM };
@@ -1 +1 @@
1
- export declare const version = "4.22.9";
1
+ export declare const version = "4.22.11";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/adapters",
3
- "version": "4.22.9",
3
+ "version": "4.22.11",
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",
@@ -89,12 +89,12 @@
89
89
  "ndarray": "1.0.19"
90
90
  },
91
91
  "devDependencies": {
92
- "@cornerstonejs/core": "4.22.9",
93
- "@cornerstonejs/tools": "4.22.9"
92
+ "@cornerstonejs/core": "4.22.11",
93
+ "@cornerstonejs/tools": "4.22.11"
94
94
  },
95
95
  "peerDependencies": {
96
- "@cornerstonejs/core": "4.22.9",
97
- "@cornerstonejs/tools": "4.22.9"
96
+ "@cornerstonejs/core": "4.22.11",
97
+ "@cornerstonejs/tools": "4.22.11"
98
98
  },
99
- "gitHead": "8958f5b08f3cd4a234fe7cae163f45b1cd9d009c"
99
+ "gitHead": "9cc703acb396d12b37fdc8af4727218574494caa"
100
100
  }