@cornerstonejs/tools 3.9.0 → 3.9.2
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.
- package/dist/esm/tools/annotation/CircleROITool.js +4 -0
- package/dist/esm/tools/annotation/EllipticalROITool.js +4 -0
- package/dist/esm/tools/annotation/RectangleROITool.js +6 -1
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +4 -3
- package/dist/esm/types/CalculatorTypes.d.ts +3 -0
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +17 -0
- package/package.json +3 -3
|
@@ -29,6 +29,7 @@ class CircleROITool extends AnnotationTool {
|
|
|
29
29
|
preventHandleOutsideImage: false,
|
|
30
30
|
storePointData: false,
|
|
31
31
|
centerPointRadius: 0,
|
|
32
|
+
calculateStats: true,
|
|
32
33
|
getTextLines: defaultGetTextLines,
|
|
33
34
|
statsCalculator: BasicStatsCalculator,
|
|
34
35
|
},
|
|
@@ -462,6 +463,9 @@ class CircleROITool extends AnnotationTool {
|
|
|
462
463
|
return renderStatus;
|
|
463
464
|
};
|
|
464
465
|
this._calculateCachedStats = (annotation, viewport, renderingEngine, enabledElement) => {
|
|
466
|
+
if (!this.configuration.calculateStats) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
465
469
|
const data = annotation.data;
|
|
466
470
|
const { element } = viewport;
|
|
467
471
|
const wasInvalidated = annotation.invalidated;
|
|
@@ -28,6 +28,7 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
28
28
|
preventHandleOutsideImage: false,
|
|
29
29
|
storePointData: false,
|
|
30
30
|
centerPointRadius: 0,
|
|
31
|
+
calculateStats: true,
|
|
31
32
|
getTextLines: defaultGetTextLines,
|
|
32
33
|
statsCalculator: BasicStatsCalculator,
|
|
33
34
|
},
|
|
@@ -539,6 +540,9 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
539
540
|
return renderStatus;
|
|
540
541
|
};
|
|
541
542
|
this._calculateCachedStats = (annotation, viewport, renderingEngine) => {
|
|
543
|
+
if (!this.configuration.calculateStats) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
542
546
|
const data = annotation.data;
|
|
543
547
|
const { element } = viewport;
|
|
544
548
|
const { points } = data.handles;
|
|
@@ -27,6 +27,7 @@ class RectangleROITool extends AnnotationTool {
|
|
|
27
27
|
storePointData: false,
|
|
28
28
|
shadow: true,
|
|
29
29
|
preventHandleOutsideImage: false,
|
|
30
|
+
calculateStats: true,
|
|
30
31
|
getTextLines: defaultGetTextLines,
|
|
31
32
|
statsCalculator: BasicStatsCalculator,
|
|
32
33
|
},
|
|
@@ -59,6 +60,7 @@ class RectangleROITool extends AnnotationTool {
|
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
},
|
|
63
|
+
cachedStats: {},
|
|
62
64
|
},
|
|
63
65
|
});
|
|
64
66
|
addAnnotation(annotation, element);
|
|
@@ -437,6 +439,9 @@ class RectangleROITool extends AnnotationTool {
|
|
|
437
439
|
};
|
|
438
440
|
};
|
|
439
441
|
this._calculateCachedStats = (annotation, viewPlaneNormal, viewUp, renderingEngine, enabledElement) => {
|
|
442
|
+
if (!this.configuration.calculateStats) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
440
445
|
const { data } = annotation;
|
|
441
446
|
const { viewport } = enabledElement;
|
|
442
447
|
const { element } = viewport;
|
|
@@ -555,7 +560,7 @@ class RectangleROITool extends AnnotationTool {
|
|
|
555
560
|
function defaultGetTextLines(data, targetId) {
|
|
556
561
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
557
562
|
const { area, mean, max, stdDev, areaUnit, modalityUnit } = cachedVolumeStats;
|
|
558
|
-
if (mean === undefined) {
|
|
563
|
+
if (mean === undefined || mean === null) {
|
|
559
564
|
return;
|
|
560
565
|
}
|
|
561
566
|
const textLines = [];
|
|
@@ -172,10 +172,11 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
|
|
|
172
172
|
let endCoord = endCoordinate;
|
|
173
173
|
if (Array.isArray(startCoordinate)) {
|
|
174
174
|
startCoord = this._getCoordinateForViewplaneNormal(startCoord, viewplaneNormal);
|
|
175
|
+
const indexOfDirection = this._getIndexOfCoordinatesForViewplaneNormal(viewplaneNormal);
|
|
176
|
+
data.handles.points.forEach((point) => {
|
|
177
|
+
point[indexOfDirection] = startCoord;
|
|
178
|
+
});
|
|
175
179
|
data.startCoordinate = startCoord;
|
|
176
|
-
data.handles.points[0][this._getIndexOfCoordinatesForViewplaneNormal(viewplaneNormal)] = startCoord;
|
|
177
|
-
data.startCoordinate = startCoord;
|
|
178
|
-
data.handles.points[0][this._getIndexOfCoordinatesForViewplaneNormal(viewplaneNormal)] = startCoord;
|
|
179
180
|
}
|
|
180
181
|
if (Array.isArray(endCoordinate)) {
|
|
181
182
|
endCoord = this._getCoordinateForViewplaneNormal(endCoord, viewplaneNormal);
|
|
@@ -17,6 +17,7 @@ function createBasicStatsState(storePointData) {
|
|
|
17
17
|
m4: [0],
|
|
18
18
|
allValues: [[]],
|
|
19
19
|
pointsInShape: storePointData ? PointsManager.create3(1024) : null,
|
|
20
|
+
sumLPS: [0, 0, 0],
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
function basicStatsCallback(state, newValue, pointLPS = null, pointIJK = null) {
|
|
@@ -37,6 +38,11 @@ function basicStatsCallback(state, newValue, pointLPS = null, pointIJK = null) {
|
|
|
37
38
|
}
|
|
38
39
|
const newArray = Array.isArray(newValue) ? newValue : [newValue];
|
|
39
40
|
state.count += 1;
|
|
41
|
+
if (pointLPS) {
|
|
42
|
+
state.sumLPS[0] += pointLPS[0];
|
|
43
|
+
state.sumLPS[1] += pointLPS[1];
|
|
44
|
+
state.sumLPS[2] += pointLPS[2];
|
|
45
|
+
}
|
|
40
46
|
state.max.forEach((it, idx) => {
|
|
41
47
|
const value = newArray[idx];
|
|
42
48
|
state.allValues[idx].push(value);
|
|
@@ -84,6 +90,7 @@ function calculateMedian(values) {
|
|
|
84
90
|
function basicGetStatistics(state, unit) {
|
|
85
91
|
const mean = state.sum.map((sum) => sum / state.count);
|
|
86
92
|
const stdDev = state.m2.map((squaredDiffSum) => Math.sqrt(squaredDiffSum / state.count));
|
|
93
|
+
const center = state.sumLPS.map((sum) => sum / state.count);
|
|
87
94
|
const skewness = state.m3.map((m3, idx) => {
|
|
88
95
|
const variance = state.m2[idx] / state.count;
|
|
89
96
|
if (variance === 0) {
|
|
@@ -165,9 +172,18 @@ function basicGetStatistics(state, unit) {
|
|
|
165
172
|
unit: null,
|
|
166
173
|
},
|
|
167
174
|
pointsInShape: state.pointsInShape,
|
|
175
|
+
center: {
|
|
176
|
+
name: 'center',
|
|
177
|
+
label: 'Center',
|
|
178
|
+
value: center ? [...center] : null,
|
|
179
|
+
unit: null,
|
|
180
|
+
},
|
|
168
181
|
array: [],
|
|
169
182
|
};
|
|
170
183
|
named.array.push(named.min, named.max, named.mean, named.stdDev, named.median, named.skewness, named.kurtosis, named.count, named.maxLPS, named.minLPS);
|
|
184
|
+
if (named.center.value) {
|
|
185
|
+
named.array.push(named.center);
|
|
186
|
+
}
|
|
171
187
|
const store = state.pointsInShape !== null;
|
|
172
188
|
const freshState = createBasicStatsState(store);
|
|
173
189
|
state.max = freshState.max;
|
|
@@ -184,6 +200,7 @@ function basicGetStatistics(state, unit) {
|
|
|
184
200
|
state.m4 = freshState.m4;
|
|
185
201
|
state.allValues = freshState.allValues;
|
|
186
202
|
state.pointsInShape = freshState.pointsInShape;
|
|
203
|
+
state.sumLPS = freshState.sumLPS;
|
|
187
204
|
return named;
|
|
188
205
|
}
|
|
189
206
|
export class BasicStatsCalculator extends Calculator {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"canvas": "^3.1.0"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@cornerstonejs/core": "^3.9.
|
|
106
|
+
"@cornerstonejs/core": "^3.9.2",
|
|
107
107
|
"@kitware/vtk.js": "32.12.1",
|
|
108
108
|
"@types/d3-array": "^3.0.4",
|
|
109
109
|
"@types/d3-interpolate": "^3.0.1",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"type": "individual",
|
|
123
123
|
"url": "https://ohif.org/donate"
|
|
124
124
|
},
|
|
125
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "7fdba50da86956a4c35e45dbdc21ab3b8decea72"
|
|
126
126
|
}
|