@cornerstonejs/adapters 0.1.5 → 0.2.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.
- package/dist/@cornerstonejs/adapters.es.js +133 -8
- package/dist/@cornerstonejs/adapters.es.js.map +1 -1
- package/dist/@cornerstonejs/adapters.js +133 -8
- package/dist/@cornerstonejs/adapters.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/Cornerstone3D/CobbAngle.js +125 -0
- package/src/adapters/Cornerstone3D/index.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/adapters",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Adapters for Cornerstone3D to/from formats including DICOM SR and others",
|
|
5
5
|
"src": "src/index.js",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"ndarray": "^1.0.19",
|
|
70
70
|
"pako": "^2.0.4"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "4bf312b91b14fad16638d488064a0a6c097e3514"
|
|
73
73
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { utilities } from "dcmjs";
|
|
2
|
+
import CORNERSTONE_3D_TAG from "./cornerstone3DTag";
|
|
3
|
+
import MeasurementReport from "./MeasurementReport";
|
|
4
|
+
|
|
5
|
+
const { CobbAngle: TID300CobbAngle } = utilities.TID300;
|
|
6
|
+
|
|
7
|
+
const MEASUREMENT_TYPE = "CobbAngle";
|
|
8
|
+
const trackingIdentifierTextValue = `${CORNERSTONE_3D_TAG}:${MEASUREMENT_TYPE}`;
|
|
9
|
+
|
|
10
|
+
class CobbAngle {
|
|
11
|
+
// TODO: this function is required for all Cornerstone Tool Adapters, since it is called by MeasurementReport.
|
|
12
|
+
static getMeasurementData(
|
|
13
|
+
MeasurementGroup,
|
|
14
|
+
sopInstanceUIDToImageIdMap,
|
|
15
|
+
imageToWorldCoords,
|
|
16
|
+
metadata
|
|
17
|
+
) {
|
|
18
|
+
const { defaultState, NUMGroup, SCOORDGroup, ReferencedFrameNumber } =
|
|
19
|
+
MeasurementReport.getSetupMeasurementData(
|
|
20
|
+
MeasurementGroup,
|
|
21
|
+
sopInstanceUIDToImageIdMap,
|
|
22
|
+
metadata,
|
|
23
|
+
CobbAngle.toolType
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const referencedImageId =
|
|
27
|
+
defaultState.annotation.metadata.referencedImageId;
|
|
28
|
+
|
|
29
|
+
const { GraphicData } = SCOORDGroup;
|
|
30
|
+
const worldCoords = [];
|
|
31
|
+
for (let i = 0; i < GraphicData.length; i += 2) {
|
|
32
|
+
const point = imageToWorldCoords(referencedImageId, [
|
|
33
|
+
GraphicData[i],
|
|
34
|
+
GraphicData[i + 1]
|
|
35
|
+
]);
|
|
36
|
+
worldCoords.push(point);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const state = defaultState;
|
|
40
|
+
|
|
41
|
+
state.annotation.data = {
|
|
42
|
+
handles: {
|
|
43
|
+
points: [
|
|
44
|
+
worldCoords[0],
|
|
45
|
+
worldCoords[1],
|
|
46
|
+
worldCoords[2],
|
|
47
|
+
worldCoords[3]
|
|
48
|
+
],
|
|
49
|
+
activeHandleIndex: 0,
|
|
50
|
+
textBox: {
|
|
51
|
+
hasMoved: false
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
cachedStats: {
|
|
55
|
+
[`imageId:${referencedImageId}`]: {
|
|
56
|
+
angle: NUMGroup
|
|
57
|
+
? NUMGroup.MeasuredValueSequence.NumericValue
|
|
58
|
+
: null
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
frameNumber: ReferencedFrameNumber
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return state;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static getTID300RepresentationArguments(tool, worldToImageCoords) {
|
|
68
|
+
const { data, finding, findingSites, metadata } = tool;
|
|
69
|
+
const { cachedStats = {}, handles } = data;
|
|
70
|
+
|
|
71
|
+
const { referencedImageId } = metadata;
|
|
72
|
+
|
|
73
|
+
if (!referencedImageId) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
"CobbAngle.getTID300RepresentationArguments: referencedImageId is not defined"
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const start1 = worldToImageCoords(referencedImageId, handles.points[0]);
|
|
80
|
+
const end1 = worldToImageCoords(referencedImageId, handles.points[1]);
|
|
81
|
+
|
|
82
|
+
const start2 = worldToImageCoords(referencedImageId, handles.points[2]);
|
|
83
|
+
const end2 = worldToImageCoords(referencedImageId, handles.points[3]);
|
|
84
|
+
|
|
85
|
+
const point1 = { x: start1[0], y: start1[1] };
|
|
86
|
+
const point2 = { x: end1[0], y: end1[1] };
|
|
87
|
+
const point3 = { x: start2[0], y: start2[1] };
|
|
88
|
+
const point4 = { x: end2[0], y: end2[1] };
|
|
89
|
+
|
|
90
|
+
const { angle } = cachedStats[`imageId:${referencedImageId}`] || {};
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
point1,
|
|
94
|
+
point2,
|
|
95
|
+
point3,
|
|
96
|
+
point4,
|
|
97
|
+
rAngle: angle,
|
|
98
|
+
trackingIdentifierTextValue,
|
|
99
|
+
finding,
|
|
100
|
+
findingSites: findingSites || []
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
CobbAngle.toolType = MEASUREMENT_TYPE;
|
|
106
|
+
CobbAngle.utilityToolType = MEASUREMENT_TYPE;
|
|
107
|
+
console.log("TID300CobbAngle=", TID300CobbAngle);
|
|
108
|
+
CobbAngle.TID300Representation = TID300CobbAngle;
|
|
109
|
+
CobbAngle.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
|
|
110
|
+
if (!TrackingIdentifier.includes(":")) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const [cornerstone3DTag, toolType] = TrackingIdentifier.split(":");
|
|
115
|
+
|
|
116
|
+
if (cornerstone3DTag !== CORNERSTONE_3D_TAG) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return toolType === MEASUREMENT_TYPE;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
MeasurementReport.registerTool(CobbAngle);
|
|
124
|
+
|
|
125
|
+
export default CobbAngle;
|
|
@@ -4,6 +4,7 @@ import CORNERSTONE_3D_TAG from "./cornerstone3DTag";
|
|
|
4
4
|
|
|
5
5
|
import ArrowAnnotate from "./ArrowAnnotate";
|
|
6
6
|
import Bidirectional from "./Bidirectional";
|
|
7
|
+
import CobbAngle from "./CobbAngle";
|
|
7
8
|
import EllipticalROI from "./EllipticalROI";
|
|
8
9
|
import Length from "./Length";
|
|
9
10
|
import PlanarFreehandROI from "./PlanarFreehandROI";
|
|
@@ -11,6 +12,7 @@ import Probe from "./Probe";
|
|
|
11
12
|
|
|
12
13
|
const Cornerstone3D = {
|
|
13
14
|
Bidirectional,
|
|
15
|
+
CobbAngle,
|
|
14
16
|
Length,
|
|
15
17
|
EllipticalROI,
|
|
16
18
|
ArrowAnnotate,
|