@cornerstonejs/adapters 0.2.0 → 0.3.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 +3472 -28871
- package/dist/@cornerstonejs/adapters.es.js.map +1 -1
- package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/Angle.d.ts +44 -0
- package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/Bidirectional.d.ts +49 -0
- package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/CobbAngle.d.ts +44 -0
- package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/MeasurementReport.d.ts +53 -0
- package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/PlanarFreehandROI.d.ts +30 -0
- package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/RectangleROI.d.ts +30 -0
- package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/index.d.ts +21 -0
- package/dist/@cornerstonejs/dts/index.d.ts +3 -0
- package/package.json +10 -35
- package/src/{index.js → index.ts} +0 -0
- package/dist/@cornerstonejs/adapters.js +0 -30195
- package/dist/@cornerstonejs/adapters.js.map +0 -1
- package/src/adapters/Cornerstone/Angle.js +0 -92
- package/src/adapters/Cornerstone/ArrowAnnotate.js +0 -106
- package/src/adapters/Cornerstone/Bidirectional.js +0 -187
- package/src/adapters/Cornerstone/CircleRoi.js +0 -109
- package/src/adapters/Cornerstone/CobbAngle.js +0 -96
- package/src/adapters/Cornerstone/EllipticalRoi.js +0 -149
- package/src/adapters/Cornerstone/FreehandRoi.js +0 -82
- package/src/adapters/Cornerstone/Length.js +0 -80
- package/src/adapters/Cornerstone/MeasurementReport.js +0 -352
- package/src/adapters/Cornerstone/RectangleRoi.js +0 -92
- package/src/adapters/Cornerstone/Segmentation.js +0 -118
- package/src/adapters/Cornerstone/Segmentation_3X.js +0 -632
- package/src/adapters/Cornerstone/Segmentation_4X.js +0 -1543
- package/src/adapters/Cornerstone/cornerstone4Tag.js +0 -1
- package/src/adapters/Cornerstone/index.js +0 -27
- package/src/adapters/Cornerstone3D/ArrowAnnotate.js +0 -155
- package/src/adapters/Cornerstone3D/Bidirectional.js +0 -196
- package/src/adapters/Cornerstone3D/CobbAngle.js +0 -125
- package/src/adapters/Cornerstone3D/CodingScheme.js +0 -16
- package/src/adapters/Cornerstone3D/EllipticalROI.js +0 -204
- package/src/adapters/Cornerstone3D/Length.js +0 -113
- package/src/adapters/Cornerstone3D/MeasurementReport.js +0 -445
- package/src/adapters/Cornerstone3D/PlanarFreehandROI.js +0 -137
- package/src/adapters/Cornerstone3D/Probe.js +0 -106
- package/src/adapters/Cornerstone3D/cornerstone3DTag.js +0 -1
- package/src/adapters/Cornerstone3D/index.js +0 -26
- package/src/adapters/VTKjs/Segmentation.js +0 -223
- package/src/adapters/VTKjs/index.js +0 -7
- package/src/adapters/helpers.js +0 -19
- package/src/adapters/index.js +0 -11
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { vec3 } from "gl-matrix";
|
|
2
|
-
import { utilities } from "dcmjs";
|
|
3
|
-
import CORNERSTONE_3D_TAG from "./cornerstone3DTag";
|
|
4
|
-
import MeasurementReport from "./MeasurementReport";
|
|
5
|
-
|
|
6
|
-
const { Ellipse: TID300Ellipse } = utilities.TID300;
|
|
7
|
-
|
|
8
|
-
const ELLIPTICALROI = "EllipticalROI";
|
|
9
|
-
const EPSILON = 1e-4;
|
|
10
|
-
|
|
11
|
-
const trackingIdentifierTextValue = `${CORNERSTONE_3D_TAG}:${ELLIPTICALROI}`;
|
|
12
|
-
|
|
13
|
-
class EllipticalROI {
|
|
14
|
-
static getMeasurementData(
|
|
15
|
-
MeasurementGroup,
|
|
16
|
-
sopInstanceUIDToImageIdMap,
|
|
17
|
-
imageToWorldCoords,
|
|
18
|
-
metadata
|
|
19
|
-
) {
|
|
20
|
-
const { defaultState, NUMGroup, SCOORDGroup, ReferencedFrameNumber } =
|
|
21
|
-
MeasurementReport.getSetupMeasurementData(
|
|
22
|
-
MeasurementGroup,
|
|
23
|
-
sopInstanceUIDToImageIdMap,
|
|
24
|
-
metadata,
|
|
25
|
-
EllipticalROI.toolType
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const referencedImageId =
|
|
29
|
-
defaultState.annotation.metadata.referencedImageId;
|
|
30
|
-
|
|
31
|
-
const { GraphicData } = SCOORDGroup;
|
|
32
|
-
|
|
33
|
-
// GraphicData is ordered as [majorAxisStartX, majorAxisStartY, majorAxisEndX, majorAxisEndY, minorAxisStartX, minorAxisStartY, minorAxisEndX, minorAxisEndY]
|
|
34
|
-
// But Cornerstone3D points are ordered as top, bottom, left, right for the
|
|
35
|
-
// ellipse so we need to identify if the majorAxis is horizontal or vertical
|
|
36
|
-
// in the image plane and then choose the correct points to use for the ellipse.
|
|
37
|
-
const pointsWorld = [];
|
|
38
|
-
for (let i = 0; i < GraphicData.length; i += 2) {
|
|
39
|
-
const worldPos = imageToWorldCoords(referencedImageId, [
|
|
40
|
-
GraphicData[i],
|
|
41
|
-
GraphicData[i + 1]
|
|
42
|
-
]);
|
|
43
|
-
|
|
44
|
-
pointsWorld.push(worldPos);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const majorAxisStart = vec3.fromValues(...pointsWorld[0]);
|
|
48
|
-
const majorAxisEnd = vec3.fromValues(...pointsWorld[1]);
|
|
49
|
-
const minorAxisStart = vec3.fromValues(...pointsWorld[2]);
|
|
50
|
-
const minorAxisEnd = vec3.fromValues(...pointsWorld[3]);
|
|
51
|
-
|
|
52
|
-
const majorAxisVec = vec3.create();
|
|
53
|
-
vec3.sub(majorAxisVec, majorAxisEnd, majorAxisStart);
|
|
54
|
-
|
|
55
|
-
// normalize majorAxisVec to avoid scaling issues
|
|
56
|
-
vec3.normalize(majorAxisVec, majorAxisVec);
|
|
57
|
-
|
|
58
|
-
const minorAxisVec = vec3.create();
|
|
59
|
-
vec3.sub(minorAxisVec, minorAxisEnd, minorAxisStart);
|
|
60
|
-
vec3.normalize(minorAxisVec, minorAxisVec);
|
|
61
|
-
|
|
62
|
-
const imagePlaneModule = metadata.get(
|
|
63
|
-
"imagePlaneModule",
|
|
64
|
-
referencedImageId
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
if (!imagePlaneModule) {
|
|
68
|
-
throw new Error("imageId does not have imagePlaneModule metadata");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const { columnCosines } = imagePlaneModule;
|
|
72
|
-
|
|
73
|
-
// find which axis is parallel to the columnCosines
|
|
74
|
-
const columnCosinesVec = vec3.fromValues(...columnCosines);
|
|
75
|
-
|
|
76
|
-
const projectedMajorAxisOnColVec = vec3.dot(
|
|
77
|
-
columnCosinesVec,
|
|
78
|
-
majorAxisVec
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const projectedMinorAxisOnColVec = vec3.dot(
|
|
82
|
-
columnCosinesVec,
|
|
83
|
-
minorAxisVec
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const absoluteOfMajorDotProduct = Math.abs(projectedMajorAxisOnColVec);
|
|
87
|
-
const absoluteOfMinorDotProduct = Math.abs(projectedMinorAxisOnColVec);
|
|
88
|
-
|
|
89
|
-
let ellipsePoints = [];
|
|
90
|
-
if (Math.abs(absoluteOfMajorDotProduct - 1) < EPSILON) {
|
|
91
|
-
ellipsePoints = [
|
|
92
|
-
pointsWorld[0],
|
|
93
|
-
pointsWorld[1],
|
|
94
|
-
pointsWorld[2],
|
|
95
|
-
pointsWorld[3]
|
|
96
|
-
];
|
|
97
|
-
} else if (Math.abs(absoluteOfMinorDotProduct - 1) < EPSILON) {
|
|
98
|
-
ellipsePoints = [
|
|
99
|
-
pointsWorld[2],
|
|
100
|
-
pointsWorld[3],
|
|
101
|
-
pointsWorld[0],
|
|
102
|
-
pointsWorld[1]
|
|
103
|
-
];
|
|
104
|
-
} else {
|
|
105
|
-
console.warn("OBLIQUE ELLIPSE NOT YET SUPPORTED");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const state = defaultState;
|
|
109
|
-
|
|
110
|
-
state.annotation.data = {
|
|
111
|
-
handles: {
|
|
112
|
-
points: [...ellipsePoints],
|
|
113
|
-
activeHandleIndex: 0,
|
|
114
|
-
textBox: {
|
|
115
|
-
hasMoved: false
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
cachedStats: {
|
|
119
|
-
[`imageId:${referencedImageId}`]: {
|
|
120
|
-
area: NUMGroup
|
|
121
|
-
? NUMGroup.MeasuredValueSequence.NumericValue
|
|
122
|
-
: 0
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
frameNumber: ReferencedFrameNumber
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
return state;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static getTID300RepresentationArguments(tool, worldToImageCoords) {
|
|
132
|
-
const { data, finding, findingSites, metadata } = tool;
|
|
133
|
-
const { cachedStats = {}, handles } = data;
|
|
134
|
-
|
|
135
|
-
const { referencedImageId } = metadata;
|
|
136
|
-
|
|
137
|
-
if (!referencedImageId) {
|
|
138
|
-
throw new Error(
|
|
139
|
-
"EllipticalROI.getTID300RepresentationArguments: referencedImageId is not defined"
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const top = worldToImageCoords(referencedImageId, handles.points[0]);
|
|
144
|
-
const bottom = worldToImageCoords(referencedImageId, handles.points[1]);
|
|
145
|
-
const left = worldToImageCoords(referencedImageId, handles.points[2]);
|
|
146
|
-
const right = worldToImageCoords(referencedImageId, handles.points[3]);
|
|
147
|
-
|
|
148
|
-
// find the major axis and minor axis
|
|
149
|
-
const topBottomLength = Math.abs(top[1] - bottom[1]);
|
|
150
|
-
const leftRightLength = Math.abs(left[0] - right[0]);
|
|
151
|
-
|
|
152
|
-
let points = [];
|
|
153
|
-
if (topBottomLength > leftRightLength) {
|
|
154
|
-
// major axis is bottom to top
|
|
155
|
-
points.push({ x: top[0], y: top[1] });
|
|
156
|
-
points.push({ x: bottom[0], y: bottom[1] });
|
|
157
|
-
|
|
158
|
-
// minor axis is left to right
|
|
159
|
-
points.push({ x: left[0], y: left[1] });
|
|
160
|
-
points.push({ x: right[0], y: right[1] });
|
|
161
|
-
} else {
|
|
162
|
-
// major axis is left to right
|
|
163
|
-
points.push({ x: left[0], y: left[1] });
|
|
164
|
-
points.push({ x: right[0], y: right[1] });
|
|
165
|
-
|
|
166
|
-
// minor axis is bottom to top
|
|
167
|
-
points.push({ x: top[0], y: top[1] });
|
|
168
|
-
points.push({ x: bottom[0], y: bottom[1] });
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const { area } = cachedStats[`imageId:${referencedImageId}`] || {};
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
area,
|
|
175
|
-
points,
|
|
176
|
-
trackingIdentifierTextValue,
|
|
177
|
-
finding,
|
|
178
|
-
findingSites: findingSites || []
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
EllipticalROI.toolType = ELLIPTICALROI;
|
|
184
|
-
EllipticalROI.utilityToolType = ELLIPTICALROI;
|
|
185
|
-
EllipticalROI.TID300Representation = TID300Ellipse;
|
|
186
|
-
EllipticalROI.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
|
|
187
|
-
if (!TrackingIdentifier.includes(":")) {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const [cornerstone3DTag, toolType] = TrackingIdentifier.split(":");
|
|
192
|
-
|
|
193
|
-
if (cornerstone3DTag !== CORNERSTONE_3D_TAG) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// The following is needed since the new cornerstone3D has changed
|
|
198
|
-
// the EllipticalRoi toolName (which was in the old cornerstone) to EllipticalROI
|
|
199
|
-
return toolType.toLowerCase() === ELLIPTICALROI.toLowerCase();
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
MeasurementReport.registerTool(EllipticalROI);
|
|
203
|
-
|
|
204
|
-
export default EllipticalROI;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { utilities } from "dcmjs";
|
|
2
|
-
import CORNERSTONE_3D_TAG from "./cornerstone3DTag";
|
|
3
|
-
import MeasurementReport from "./MeasurementReport";
|
|
4
|
-
|
|
5
|
-
const { Length: TID300Length } = utilities.TID300;
|
|
6
|
-
|
|
7
|
-
const LENGTH = "Length";
|
|
8
|
-
const trackingIdentifierTextValue = `${CORNERSTONE_3D_TAG}:${LENGTH}`;
|
|
9
|
-
|
|
10
|
-
class Length {
|
|
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
|
-
Length.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: [worldCoords[0], worldCoords[1]],
|
|
44
|
-
activeHandleIndex: 0,
|
|
45
|
-
textBox: {
|
|
46
|
-
hasMoved: false
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
cachedStats: {
|
|
50
|
-
[`imageId:${referencedImageId}`]: {
|
|
51
|
-
length: NUMGroup
|
|
52
|
-
? NUMGroup.MeasuredValueSequence.NumericValue
|
|
53
|
-
: 0
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
frameNumber: ReferencedFrameNumber
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return state;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static getTID300RepresentationArguments(tool, worldToImageCoords) {
|
|
63
|
-
const { data, finding, findingSites, metadata } = tool;
|
|
64
|
-
const { cachedStats = {}, handles } = data;
|
|
65
|
-
|
|
66
|
-
const { referencedImageId } = metadata;
|
|
67
|
-
|
|
68
|
-
if (!referencedImageId) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
"Length.getTID300RepresentationArguments: referencedImageId is not defined"
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const start = worldToImageCoords(referencedImageId, handles.points[0]);
|
|
75
|
-
const end = worldToImageCoords(referencedImageId, handles.points[1]);
|
|
76
|
-
|
|
77
|
-
const point1 = { x: start[0], y: start[1] };
|
|
78
|
-
const point2 = { x: end[0], y: end[1] };
|
|
79
|
-
|
|
80
|
-
const { length: distance } =
|
|
81
|
-
cachedStats[`imageId:${referencedImageId}`] || {};
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
point1,
|
|
85
|
-
point2,
|
|
86
|
-
distance,
|
|
87
|
-
trackingIdentifierTextValue,
|
|
88
|
-
finding,
|
|
89
|
-
findingSites: findingSites || []
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
Length.toolType = LENGTH;
|
|
95
|
-
Length.utilityToolType = LENGTH;
|
|
96
|
-
Length.TID300Representation = TID300Length;
|
|
97
|
-
Length.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
|
|
98
|
-
if (!TrackingIdentifier.includes(":")) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const [cornerstone3DTag, toolType] = TrackingIdentifier.split(":");
|
|
103
|
-
|
|
104
|
-
if (cornerstone3DTag !== CORNERSTONE_3D_TAG) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return toolType === LENGTH;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
MeasurementReport.registerTool(Length);
|
|
112
|
-
|
|
113
|
-
export default Length;
|