@cornerstonejs/tools 4.17.5 → 4.18.0

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.
@@ -298,31 +298,40 @@ class ProbeTool extends AnnotationTool {
298
298
  continue;
299
299
  }
300
300
  const { dimensions, imageData, metadata, voxelManager } = image;
301
- const modality = metadata.Modality;
301
+ const modality = metadata?.Modality;
302
302
  let ijk = transformWorldToIndex(imageData, worldPos);
303
303
  ijk = vec3.round(ijk, ijk);
304
304
  if (csUtils.indexWithinDimensions(ijk, dimensions)) {
305
305
  this.isHandleOutsideImage = false;
306
- let value = voxelManager.getAtIJKPoint(ijk);
307
- if (targetId.startsWith('imageId:')) {
306
+ if (targetId.startsWith('imageId:') && modality !== 'ECG') {
308
307
  const imageId = targetId.split('imageId:')[1];
309
308
  const imageURI = csUtils.imageIdToURI(imageId);
310
309
  const viewports = csUtils.getViewportsWithImageURI(imageURI);
311
310
  const viewport = viewports[0];
312
311
  ijk[2] = viewport.getCurrentImageIdIndex();
313
312
  }
313
+ let value;
314
314
  let modalityUnit;
315
- if (modality === 'US') {
315
+ if (modality === 'ECG') {
316
316
  const calibratedResults = getCalibratedProbeUnitsAndValue(image, [
317
317
  ijk,
318
318
  ]);
319
- const hasEnhancedRegionValues = calibratedResults.values.every((value) => value !== null);
319
+ value = calibratedResults.values;
320
+ modalityUnit = calibratedResults.units;
321
+ }
322
+ else if (modality === 'US') {
323
+ value = voxelManager?.getAtIJKPoint(ijk);
324
+ const calibratedResults = getCalibratedProbeUnitsAndValue(image, [
325
+ ijk,
326
+ ]);
327
+ const hasEnhancedRegionValues = calibratedResults.values.every((v) => v !== null);
320
328
  value = (hasEnhancedRegionValues ? calibratedResults.values : value);
321
329
  modalityUnit = hasEnhancedRegionValues
322
330
  ? calibratedResults.units
323
331
  : 'raw';
324
332
  }
325
333
  else {
334
+ value = voxelManager?.getAtIJKPoint(ijk);
326
335
  modalityUnit = getPixelValueUnits(modality, annotation.metadata.referencedImageId, pixelUnitsOptions);
327
336
  }
328
337
  cachedStats[targetId] = {
@@ -1,5 +1,5 @@
1
1
  import { ChangeTypes, Events } from '../../enums';
2
- import { getEnabledElement, utilities as csUtils, StackViewport, } from '@cornerstonejs/core';
2
+ import { getEnabledElement, utilities as csUtils, StackViewport, ECGViewport, } from '@cornerstonejs/core';
3
3
  import { AnnotationTool } from '../base';
4
4
  import throttle from '../../utilities/throttle';
5
5
  import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
@@ -35,8 +35,9 @@ class UltrasoundDirectionalTool extends AnnotationTool {
35
35
  const worldPos = currentPoints.world;
36
36
  const enabledElement = getEnabledElement(element);
37
37
  const { viewport } = enabledElement;
38
- if (!(viewport instanceof StackViewport)) {
39
- throw new Error('UltrasoundDirectionalTool can only be used on a StackViewport');
38
+ if (!(viewport instanceof StackViewport) &&
39
+ !(viewport instanceof ECGViewport)) {
40
+ throw new Error('UltrasoundDirectionalTool can only be used on a StackViewport or ECGViewport');
40
41
  }
41
42
  hideElementCursor(element);
42
43
  this.isDrawing = true;
@@ -11,6 +11,7 @@ const SUPPORTED_REGION_DATA_TYPES = [
11
11
  const SUPPORTED_PROBE_VARIANT = [
12
12
  '4,3',
13
13
  '4,7',
14
+ '4,-1',
14
15
  ];
15
16
  const UNIT_MAPPING = {
16
17
  0: 'px',
@@ -24,6 +25,7 @@ const UNIT_MAPPING = {
24
25
  8: 'cm\xb2',
25
26
  9: 'cm\xb2/s',
26
27
  0xc: 'degrees',
28
+ [-1]: 'mV',
27
29
  };
28
30
  const EPS = 1e-3;
29
31
  const SQUARE = '\xb2';
@@ -66,7 +68,9 @@ const getCalibratedLengthUnitsAndScale = (image, handles) => {
66
68
  const region = calibration.sequenceOfUltrasoundRegions.find((region) => handles.every((handle) => handle[0] >= region.regionLocationMinX0 &&
67
69
  handle[0] <= region.regionLocationMaxX1 &&
68
70
  handle[1] >= region.regionLocationMinY0 &&
69
- handle[1] <= region.regionLocationMaxY1) && SUPPORTED_REGION_DATA_TYPES.includes(region.regionDataType));
71
+ handle[1] <= region.regionLocationMaxY1) &&
72
+ (SUPPORTED_REGION_DATA_TYPES.includes(region.regionDataType) ||
73
+ SUPPORTED_PROBE_VARIANT.includes(`${region.physicalUnitsXDirection},${region.physicalUnitsYDirection}`)));
70
74
  if (region &&
71
75
  region.physicalUnitsXDirection === region.physicalUnitsYDirection) {
72
76
  const physicalDeltaX = Math.abs(region.physicalDeltaX);
@@ -77,6 +81,19 @@ const getCalibratedLengthUnitsAndScale = (image, handles) => {
77
81
  unit = UNIT_MAPPING[region.physicalUnitsXDirection] || 'unknown';
78
82
  areaUnit = unit + SQUARE;
79
83
  }
84
+ else if (region && region.physicalUnitsYDirection === -1) {
85
+ const physicalDeltaX = Math.abs(region.physicalDeltaX);
86
+ const physicalDeltaY = Math.abs(region.physicalDeltaY);
87
+ scale = 1 / physicalDeltaX;
88
+ scaleY = 1 / physicalDeltaY;
89
+ calibrationType = 'ECG Region';
90
+ unit =
91
+ UNIT_MAPPING[region.physicalUnitsXDirection] ||
92
+ UNIT_MAPPING[region.physicalUnitsYDirection] ||
93
+ 'unknown';
94
+ areaUnit =
95
+ (UNIT_MAPPING[region.physicalUnitsYDirection] || 'px') + SQUARE;
96
+ }
80
97
  }
81
98
  else if (calibration.scale) {
82
99
  scale = calibration.scale;
@@ -101,7 +118,8 @@ const getCalibratedProbeUnitsAndValue = (image, handles) => {
101
118
  return { units, values };
102
119
  }
103
120
  if (calibration.sequenceOfUltrasoundRegions) {
104
- const supportedRegionsMetadata = calibration.sequenceOfUltrasoundRegions.filter((region) => SUPPORTED_REGION_DATA_TYPES.includes(region.regionDataType) &&
121
+ const supportedRegionsMetadata = calibration.sequenceOfUltrasoundRegions.filter((region) => (SUPPORTED_REGION_DATA_TYPES.includes(region.regionDataType) ||
122
+ SUPPORTED_PROBE_VARIANT.includes(`${region.physicalUnitsXDirection},${region.physicalUnitsYDirection}`)) &&
105
123
  SUPPORTED_PROBE_VARIANT.includes(`${region.physicalUnitsXDirection},${region.physicalUnitsYDirection}`));
106
124
  if (!supportedRegionsMetadata?.length) {
107
125
  return { units, values };
@@ -119,11 +137,12 @@ const getCalibratedProbeUnitsAndValue = (image, handles) => {
119
137
  physicalDeltaY;
120
138
  const xValue = (imageIndex[0] - region.regionLocationMinX0 - referencePixelX0) *
121
139
  physicalDeltaX;
122
- calibrationType = 'US Region';
140
+ calibrationType =
141
+ region.physicalUnitsYDirection === -1 ? 'ECG Region' : 'US Region';
123
142
  values = [xValue, yValue];
124
143
  units = [
125
- UNIT_MAPPING[region.physicalUnitsXDirection],
126
- UNIT_MAPPING[region.physicalUnitsYDirection],
144
+ UNIT_MAPPING[region.physicalUnitsXDirection] ?? 'unknown',
145
+ UNIT_MAPPING[region.physicalUnitsYDirection] ?? 'unknown',
127
146
  ];
128
147
  }
129
148
  return {
@@ -1 +1 @@
1
- export declare const version = "4.17.5";
1
+ export declare const version = "4.18.0";
@@ -1 +1 @@
1
- export const version = '4.17.5';
1
+ export const version = '4.18.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "4.17.5",
3
+ "version": "4.18.0",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "3.2.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "4.17.5",
111
+ "@cornerstonejs/core": "4.18.0",
112
112
  "@kitware/vtk.js": "34.15.1",
113
113
  "@types/d3-array": "3.2.1",
114
114
  "@types/d3-interpolate": "3.0.4",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "d42f5ee3747c6521ef3af5e9d1faf69c98157396"
130
+ "gitHead": "7f4a99858ac39083fb1aeab650002ec7d33e3d58"
131
131
  }