@cornerstonejs/tools 1.65.4 → 1.65.5
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/cjs/tools/annotation/CircleROITool.js +4 -4
- package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.js +5 -5
- package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +4 -4
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/RectangleROITool.js +4 -4
- package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/cjs/types/CalculatorTypes.d.ts +29 -1
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/utilities/math/basic/BasicStatsCalculator.d.ts +2 -2
- package/dist/cjs/utilities/math/basic/BasicStatsCalculator.js +34 -11
- package/dist/cjs/utilities/math/basic/BasicStatsCalculator.js.map +1 -1
- package/dist/cjs/utilities/math/basic/Calculator.d.ts +2 -2
- package/dist/cjs/utilities/math/basic/Calculator.js.map +1 -1
- package/dist/esm/tools/annotation/CircleROITool.js +4 -4
- package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +5 -5
- package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +4 -4
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/annotation/RectangleROITool.js +4 -4
- package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +34 -11
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.js.map +1 -1
- package/dist/esm/utilities/math/basic/Calculator.js.map +1 -1
- package/dist/types/types/CalculatorTypes.d.ts +29 -1
- package/dist/types/types/CalculatorTypes.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utilities/math/basic/BasicStatsCalculator.d.ts +2 -2
- package/dist/types/utilities/math/basic/BasicStatsCalculator.d.ts.map +1 -1
- package/dist/types/utilities/math/basic/Calculator.d.ts +2 -2
- package/dist/types/utilities/math/basic/Calculator.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/tools/annotation/CircleROITool.ts +4 -4
- package/src/tools/annotation/EllipticalROITool.ts +5 -5
- package/src/tools/annotation/PlanarFreehandROITool.ts +4 -4
- package/src/tools/annotation/RectangleROITool.ts +4 -4
- package/src/types/CalculatorTypes.ts +14 -1
- package/src/types/index.ts +4 -1
- package/src/utilities/math/basic/BasicStatsCalculator.ts +44 -14
- package/src/utilities/math/basic/Calculator.ts +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.65.
|
|
3
|
+
"version": "1.65.5",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/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.65.
|
|
32
|
+
"@cornerstonejs/core": "^1.65.5",
|
|
33
33
|
"@icr/polyseg-wasm": "0.4.0",
|
|
34
34
|
"@types/offscreencanvas": "2019.7.3",
|
|
35
35
|
"comlink": "^4.4.1",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"type": "individual",
|
|
60
60
|
"url": "https://ohif.org/donate"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "bc54ae70cb2180d5ce42cc7eaa17633f0bb5f34a"
|
|
63
63
|
}
|
|
@@ -980,10 +980,10 @@ class CircleROITool extends AnnotationTool {
|
|
|
980
980
|
cachedStats[targetId] = {
|
|
981
981
|
Modality: metadata.Modality,
|
|
982
982
|
area,
|
|
983
|
-
mean: stats
|
|
984
|
-
max: stats
|
|
985
|
-
stdDev: stats
|
|
986
|
-
statsArray: stats,
|
|
983
|
+
mean: stats.mean?.value,
|
|
984
|
+
max: stats.max?.value,
|
|
985
|
+
stdDev: stats.stdDev?.value,
|
|
986
|
+
statsArray: stats.array,
|
|
987
987
|
pointsInShape: pointsInShape,
|
|
988
988
|
isEmptyArea,
|
|
989
989
|
areaUnit: getCalibratedAreaUnits(null, image),
|
|
@@ -1099,11 +1099,11 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
1099
1099
|
cachedStats[targetId] = {
|
|
1100
1100
|
Modality: metadata.Modality,
|
|
1101
1101
|
area,
|
|
1102
|
-
mean: stats
|
|
1103
|
-
max: stats
|
|
1104
|
-
stdDev: stats
|
|
1105
|
-
statsArray: stats,
|
|
1106
|
-
pointsInShape
|
|
1102
|
+
mean: stats.mean?.value,
|
|
1103
|
+
max: stats.max?.value,
|
|
1104
|
+
stdDev: stats.stdDev?.value,
|
|
1105
|
+
statsArray: stats.array,
|
|
1106
|
+
pointsInShape,
|
|
1107
1107
|
isEmptyArea,
|
|
1108
1108
|
areaUnit: getCalibratedAreaUnits(null, image),
|
|
1109
1109
|
modalityUnit,
|
|
@@ -835,10 +835,10 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
835
835
|
cachedStats[targetId] = {
|
|
836
836
|
Modality: metadata.Modality,
|
|
837
837
|
area,
|
|
838
|
-
mean: stats
|
|
839
|
-
max: stats
|
|
840
|
-
stdDev: stats
|
|
841
|
-
statsArray: stats,
|
|
838
|
+
mean: stats.mean?.value,
|
|
839
|
+
max: stats.max?.value,
|
|
840
|
+
stdDev: stats.stdDev?.value,
|
|
841
|
+
statsArray: stats.array,
|
|
842
842
|
pointsInShape: pointsInShape,
|
|
843
843
|
areaUnit: getCalibratedAreaUnits(null, image),
|
|
844
844
|
modalityUnit,
|
|
@@ -954,10 +954,10 @@ class RectangleROITool extends AnnotationTool {
|
|
|
954
954
|
cachedStats[targetId] = {
|
|
955
955
|
Modality: metadata.Modality,
|
|
956
956
|
area,
|
|
957
|
-
mean: stats
|
|
958
|
-
stdDev: stats
|
|
959
|
-
max: stats
|
|
960
|
-
statsArray: stats,
|
|
957
|
+
mean: stats.mean?.value,
|
|
958
|
+
stdDev: stats.stdDev?.value,
|
|
959
|
+
max: stats.max?.value,
|
|
960
|
+
statsArray: stats.array,
|
|
961
961
|
pointsInShape: pointsInShape,
|
|
962
962
|
areaUnit: getCalibratedAreaUnits(null, image),
|
|
963
963
|
modalityUnit,
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
type Statistics = {
|
|
2
2
|
name: string;
|
|
3
|
+
label?: string;
|
|
3
4
|
value: number | number[];
|
|
4
5
|
unit: null | string;
|
|
5
6
|
};
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
type NamedStatistics = {
|
|
9
|
+
mean: Statistics & { name: 'mean' };
|
|
10
|
+
max: Statistics & { name: 'max' };
|
|
11
|
+
stdDev: Statistics & { name: 'stdDev' };
|
|
12
|
+
stdDevWithSumSquare: Statistics & { name: 'stdDevWithSumSquare' };
|
|
13
|
+
count: Statistics & { name: 'count' };
|
|
14
|
+
area?: Statistics & { name: 'area' };
|
|
15
|
+
volume?: Statistics & { name: 'volume' };
|
|
16
|
+
circumferance?: Statistics & { name: 'circumferance' };
|
|
17
|
+
array: Statistics[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type { Statistics, NamedStatistics };
|
package/src/types/index.ts
CHANGED
|
@@ -64,7 +64,7 @@ import type { ContourSegmentationData } from './ContourTypes';
|
|
|
64
64
|
import type IAnnotationManager from './IAnnotationManager';
|
|
65
65
|
import type AnnotationGroupSelector from './AnnotationGroupSelector';
|
|
66
66
|
import type AnnotationRenderContext from './AnnotationRenderContext';
|
|
67
|
-
import type { Statistics } from './CalculatorTypes';
|
|
67
|
+
import type { Statistics, NamedStatistics } from './CalculatorTypes';
|
|
68
68
|
import type { CanvasCoordinates } from '../utilities/math/ellipse/getCanvasEllipseCorners';
|
|
69
69
|
import {
|
|
70
70
|
LabelmapToolOperationData,
|
|
@@ -162,6 +162,9 @@ export type {
|
|
|
162
162
|
ContourSegmentationData,
|
|
163
163
|
//Statistics
|
|
164
164
|
Statistics,
|
|
165
|
+
NamedStatistics,
|
|
166
|
+
|
|
167
|
+
// Labelmap data
|
|
165
168
|
LabelmapToolOperationData,
|
|
166
169
|
LabelmapToolOperationDataStack,
|
|
167
170
|
LabelmapToolOperationDataVolume,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Statistics } from '../../../types';
|
|
1
|
+
import { NamedStatistics, Statistics } from '../../../types';
|
|
2
2
|
import Calculator from './Calculator';
|
|
3
3
|
|
|
4
4
|
export default class BasicStatsCalculator extends Calculator {
|
|
@@ -46,15 +46,15 @@ export default class BasicStatsCalculator extends Calculator {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Basic function that calculates statictics for a given array of points.
|
|
49
|
-
* @param points
|
|
50
49
|
* @returns An object that contains :
|
|
51
50
|
* max : The maximum value of the array
|
|
52
51
|
* mean : mean of the array
|
|
53
52
|
* stdDev : standard deviation of the array
|
|
54
53
|
* stdDevWithSumSquare : standard deviation of the array using sum²
|
|
54
|
+
* array : An array of hte above values, in order.
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
|
-
static getStatistics = ():
|
|
57
|
+
static getStatistics = (): NamedStatistics => {
|
|
58
58
|
const mean = this.sum.map((sum) => sum / this.count);
|
|
59
59
|
const stdDev = this.squaredDiffSum.map((squaredDiffSum) =>
|
|
60
60
|
Math.sqrt(squaredDiffSum / this.count)
|
|
@@ -62,7 +62,46 @@ export default class BasicStatsCalculator extends Calculator {
|
|
|
62
62
|
const stdDevWithSumSquare = this.sumSquares.map((it, idx) =>
|
|
63
63
|
Math.sqrt(this.sumSquares[idx] / this.count - mean[idx] ** 2)
|
|
64
64
|
);
|
|
65
|
-
|
|
65
|
+
|
|
66
|
+
const named: NamedStatistics = {
|
|
67
|
+
max: {
|
|
68
|
+
name: 'max',
|
|
69
|
+
label: 'Max Pixel',
|
|
70
|
+
value: singleArrayAsNumber(this.max),
|
|
71
|
+
unit: null,
|
|
72
|
+
},
|
|
73
|
+
mean: {
|
|
74
|
+
name: 'mean',
|
|
75
|
+
label: 'Mean Pixel',
|
|
76
|
+
value: singleArrayAsNumber(mean),
|
|
77
|
+
unit: null,
|
|
78
|
+
},
|
|
79
|
+
stdDev: {
|
|
80
|
+
name: 'stdDev',
|
|
81
|
+
label: 'Standard Deviation',
|
|
82
|
+
value: singleArrayAsNumber(stdDev),
|
|
83
|
+
unit: null,
|
|
84
|
+
},
|
|
85
|
+
stdDevWithSumSquare: {
|
|
86
|
+
name: 'stdDevWithSumSquare',
|
|
87
|
+
value: singleArrayAsNumber(stdDevWithSumSquare),
|
|
88
|
+
unit: null,
|
|
89
|
+
},
|
|
90
|
+
count: {
|
|
91
|
+
name: 'count',
|
|
92
|
+
label: 'Pixel Count',
|
|
93
|
+
value: this.count,
|
|
94
|
+
unit: null,
|
|
95
|
+
},
|
|
96
|
+
array: [],
|
|
97
|
+
};
|
|
98
|
+
named.array.push(
|
|
99
|
+
named.max,
|
|
100
|
+
named.mean,
|
|
101
|
+
named.stdDev,
|
|
102
|
+
named.stdDevWithSumSquare,
|
|
103
|
+
named.count
|
|
104
|
+
);
|
|
66
105
|
|
|
67
106
|
this.max = [-Infinity];
|
|
68
107
|
this.sum = [0];
|
|
@@ -70,16 +109,7 @@ export default class BasicStatsCalculator extends Calculator {
|
|
|
70
109
|
this.squaredDiffSum = [0];
|
|
71
110
|
this.count = 0;
|
|
72
111
|
|
|
73
|
-
return
|
|
74
|
-
{ name: 'max', value: singleArrayAsNumber(currentMax), unit: null },
|
|
75
|
-
{ name: 'mean', value: singleArrayAsNumber(mean), unit: null },
|
|
76
|
-
{ name: 'stdDev', value: singleArrayAsNumber(stdDev), unit: null },
|
|
77
|
-
{
|
|
78
|
-
name: 'stdDevWithSumSquare',
|
|
79
|
-
value: singleArrayAsNumber(stdDevWithSumSquare),
|
|
80
|
-
unit: null,
|
|
81
|
-
},
|
|
82
|
-
];
|
|
112
|
+
return named;
|
|
83
113
|
};
|
|
84
114
|
}
|
|
85
115
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NamedStatistics } from '../../../types';
|
|
2
2
|
|
|
3
3
|
abstract class Calculator {
|
|
4
4
|
static run: ({ value }) => void;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Gets the statistics as both an array of values, as well as the named values.
|
|
7
|
+
*/
|
|
8
|
+
static getStatistics: () => NamedStatistics;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
export default Calculator;
|