@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.
Files changed (44) hide show
  1. package/dist/@cornerstonejs/adapters.es.js +3472 -28871
  2. package/dist/@cornerstonejs/adapters.es.js.map +1 -1
  3. package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/Angle.d.ts +44 -0
  4. package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/Bidirectional.d.ts +49 -0
  5. package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/CobbAngle.d.ts +44 -0
  6. package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/MeasurementReport.d.ts +53 -0
  7. package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/PlanarFreehandROI.d.ts +30 -0
  8. package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/RectangleROI.d.ts +30 -0
  9. package/dist/@cornerstonejs/dts/adapters/Cornerstone3D/index.d.ts +21 -0
  10. package/dist/@cornerstonejs/dts/index.d.ts +3 -0
  11. package/package.json +10 -35
  12. package/src/{index.js → index.ts} +0 -0
  13. package/dist/@cornerstonejs/adapters.js +0 -30195
  14. package/dist/@cornerstonejs/adapters.js.map +0 -1
  15. package/src/adapters/Cornerstone/Angle.js +0 -92
  16. package/src/adapters/Cornerstone/ArrowAnnotate.js +0 -106
  17. package/src/adapters/Cornerstone/Bidirectional.js +0 -187
  18. package/src/adapters/Cornerstone/CircleRoi.js +0 -109
  19. package/src/adapters/Cornerstone/CobbAngle.js +0 -96
  20. package/src/adapters/Cornerstone/EllipticalRoi.js +0 -149
  21. package/src/adapters/Cornerstone/FreehandRoi.js +0 -82
  22. package/src/adapters/Cornerstone/Length.js +0 -80
  23. package/src/adapters/Cornerstone/MeasurementReport.js +0 -352
  24. package/src/adapters/Cornerstone/RectangleRoi.js +0 -92
  25. package/src/adapters/Cornerstone/Segmentation.js +0 -118
  26. package/src/adapters/Cornerstone/Segmentation_3X.js +0 -632
  27. package/src/adapters/Cornerstone/Segmentation_4X.js +0 -1543
  28. package/src/adapters/Cornerstone/cornerstone4Tag.js +0 -1
  29. package/src/adapters/Cornerstone/index.js +0 -27
  30. package/src/adapters/Cornerstone3D/ArrowAnnotate.js +0 -155
  31. package/src/adapters/Cornerstone3D/Bidirectional.js +0 -196
  32. package/src/adapters/Cornerstone3D/CobbAngle.js +0 -125
  33. package/src/adapters/Cornerstone3D/CodingScheme.js +0 -16
  34. package/src/adapters/Cornerstone3D/EllipticalROI.js +0 -204
  35. package/src/adapters/Cornerstone3D/Length.js +0 -113
  36. package/src/adapters/Cornerstone3D/MeasurementReport.js +0 -445
  37. package/src/adapters/Cornerstone3D/PlanarFreehandROI.js +0 -137
  38. package/src/adapters/Cornerstone3D/Probe.js +0 -106
  39. package/src/adapters/Cornerstone3D/cornerstone3DTag.js +0 -1
  40. package/src/adapters/Cornerstone3D/index.js +0 -26
  41. package/src/adapters/VTKjs/Segmentation.js +0 -223
  42. package/src/adapters/VTKjs/index.js +0 -7
  43. package/src/adapters/helpers.js +0 -19
  44. package/src/adapters/index.js +0 -11
@@ -1,92 +0,0 @@
1
- import { utilities } from "dcmjs";
2
-
3
- import MeasurementReport from "./MeasurementReport";
4
- import CORNERSTONE_4_TAG from "./cornerstone4Tag";
5
-
6
- const { CobbAngle: TID300CobbAngle } = utilities.TID300;
7
-
8
- const ANGLE = "Angle";
9
-
10
- class Angle {
11
- /**
12
- * Generate TID300 measurement data for a plane angle measurement - use a CobbAngle, but label it as Angle
13
- */
14
- static getMeasurementData(MeasurementGroup) {
15
- const { defaultState, NUMGroup, SCOORDGroup } =
16
- MeasurementReport.getSetupMeasurementData(MeasurementGroup);
17
-
18
- const state = {
19
- ...defaultState,
20
- rAngle: NUMGroup.MeasuredValueSequence.NumericValue,
21
- toolType: Angle.toolType,
22
- handles: {
23
- start: {},
24
- middle: {},
25
- end: {},
26
- textBox: {
27
- hasMoved: false,
28
- movesIndependently: false,
29
- drawnIndependently: true,
30
- allowedOutsideImage: true,
31
- hasBoundingBox: true
32
- }
33
- }
34
- };
35
-
36
- [
37
- state.handles.start.x,
38
- state.handles.start.y,
39
- state.handles.middle.x,
40
- state.handles.middle.y,
41
- state.handles.middle.x,
42
- state.handles.middle.y,
43
- state.handles.end.x,
44
- state.handles.end.y
45
- ] = SCOORDGroup.GraphicData;
46
-
47
- return state;
48
- }
49
-
50
- static getTID300RepresentationArguments(tool) {
51
- const { handles, finding, findingSites } = tool;
52
- const point1 = handles.start;
53
- const point2 = handles.middle;
54
- const point3 = handles.middle;
55
- const point4 = handles.end;
56
- const rAngle = tool.rAngle;
57
-
58
- const trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:Angle";
59
-
60
- return {
61
- point1,
62
- point2,
63
- point3,
64
- point4,
65
- rAngle,
66
- trackingIdentifierTextValue,
67
- finding,
68
- findingSites: findingSites || []
69
- };
70
- }
71
- }
72
-
73
- Angle.toolType = ANGLE;
74
- Angle.utilityToolType = ANGLE;
75
- Angle.TID300Representation = TID300CobbAngle;
76
- Angle.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
77
- if (!TrackingIdentifier.includes(":")) {
78
- return false;
79
- }
80
-
81
- const [cornerstone4Tag, toolType] = TrackingIdentifier.split(":");
82
-
83
- if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
84
- return false;
85
- }
86
-
87
- return toolType === ANGLE;
88
- };
89
-
90
- MeasurementReport.registerTool(Angle);
91
-
92
- export default Angle;
@@ -1,106 +0,0 @@
1
- import { utilities } from "dcmjs";
2
-
3
- import MeasurementReport from "./MeasurementReport";
4
- import CORNERSTONE_4_TAG from "./cornerstone4Tag";
5
-
6
- const { Point: TID300Point } = utilities.TID300;
7
-
8
- const ARROW_ANNOTATE = "ArrowAnnotate";
9
- const CORNERSTONEFREETEXT = "CORNERSTONEFREETEXT";
10
-
11
- class ArrowAnnotate {
12
- static getMeasurementData(MeasurementGroup) {
13
- const { defaultState, SCOORDGroup, findingGroup } =
14
- MeasurementReport.getSetupMeasurementData(MeasurementGroup);
15
-
16
- const text = findingGroup.ConceptCodeSequence.CodeMeaning;
17
-
18
- const { GraphicData } = SCOORDGroup;
19
-
20
- const state = {
21
- ...defaultState,
22
- toolType: ArrowAnnotate.toolType,
23
- active: false,
24
- handles: {
25
- start: {
26
- x: GraphicData[0],
27
- y: GraphicData[1],
28
- highlight: true,
29
- active: false
30
- },
31
- // Use a generic offset if the stored data doesn't have the endpoint, otherwise
32
- // use the actual endpoint.
33
- end: {
34
- x:
35
- GraphicData.length == 4
36
- ? GraphicData[2]
37
- : GraphicData[0] + 20,
38
- y:
39
- GraphicData.length == 4
40
- ? GraphicData[3]
41
- : GraphicData[1] + 20,
42
- highlight: true,
43
- active: false
44
- },
45
- textBox: {
46
- hasMoved: false,
47
- movesIndependently: false,
48
- drawnIndependently: true,
49
- allowedOutsideImage: true,
50
- hasBoundingBox: true
51
- }
52
- },
53
- invalidated: true,
54
- text,
55
- visible: true
56
- };
57
-
58
- return state;
59
- }
60
-
61
- static getTID300RepresentationArguments(tool) {
62
- const points = [tool.handles.start, tool.handles.end];
63
-
64
- let { finding, findingSites } = tool;
65
-
66
- const TID300RepresentationArguments = {
67
- points,
68
- trackingIdentifierTextValue: `cornerstoneTools@^4.0.0:ArrowAnnotate`,
69
- findingSites: findingSites || []
70
- };
71
-
72
- // If freetext finding isn't present, add it from the tool text.
73
- if (!finding || finding.CodeValue !== CORNERSTONEFREETEXT) {
74
- finding = {
75
- CodeValue: CORNERSTONEFREETEXT,
76
- CodingSchemeDesignator: "CST4",
77
- CodeMeaning: tool.text
78
- };
79
- }
80
-
81
- TID300RepresentationArguments.finding = finding;
82
-
83
- return TID300RepresentationArguments;
84
- }
85
- }
86
-
87
- ArrowAnnotate.toolType = ARROW_ANNOTATE;
88
- ArrowAnnotate.utilityToolType = ARROW_ANNOTATE;
89
- ArrowAnnotate.TID300Representation = TID300Point;
90
- ArrowAnnotate.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
91
- if (!TrackingIdentifier.includes(":")) {
92
- return false;
93
- }
94
-
95
- const [cornerstone4Tag, toolType] = TrackingIdentifier.split(":");
96
-
97
- if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
98
- return false;
99
- }
100
-
101
- return toolType === ARROW_ANNOTATE;
102
- };
103
-
104
- MeasurementReport.registerTool(ArrowAnnotate);
105
-
106
- export default ArrowAnnotate;
@@ -1,187 +0,0 @@
1
- import { utilities } from "dcmjs";
2
- import MeasurementReport from "./MeasurementReport";
3
- import CORNERSTONE_4_TAG from "./cornerstone4Tag";
4
- import { toArray } from "../helpers";
5
-
6
- const { Bidirectional: TID300Bidirectional } = utilities.TID300;
7
-
8
- const BIDIRECTIONAL = "Bidirectional";
9
- const LONG_AXIS = "Long Axis";
10
- const SHORT_AXIS = "Short Axis";
11
- const FINDING = "121071";
12
- const FINDING_SITE = "G-C0E3";
13
-
14
- class Bidirectional {
15
- // TODO: this function is required for all Cornerstone Tool Adapters, since it is called by MeasurementReport.
16
- static getMeasurementData(MeasurementGroup) {
17
- const { ContentSequence } = MeasurementGroup;
18
-
19
- const findingGroup = toArray(ContentSequence).find(
20
- group => group.ConceptNameCodeSequence.CodeValue === FINDING
21
- );
22
-
23
- const findingSiteGroups = toArray(ContentSequence).filter(
24
- group => group.ConceptNameCodeSequence.CodeValue === FINDING_SITE
25
- );
26
-
27
- const longAxisNUMGroup = toArray(ContentSequence).find(
28
- group => group.ConceptNameCodeSequence.CodeMeaning === LONG_AXIS
29
- );
30
-
31
- const longAxisSCOORDGroup = toArray(
32
- longAxisNUMGroup.ContentSequence
33
- ).find(group => group.ValueType === "SCOORD");
34
-
35
- const shortAxisNUMGroup = toArray(ContentSequence).find(
36
- group => group.ConceptNameCodeSequence.CodeMeaning === SHORT_AXIS
37
- );
38
-
39
- const shortAxisSCOORDGroup = toArray(
40
- shortAxisNUMGroup.ContentSequence
41
- ).find(group => group.ValueType === "SCOORD");
42
-
43
- const { ReferencedSOPSequence } = longAxisSCOORDGroup.ContentSequence;
44
- const { ReferencedSOPInstanceUID, ReferencedFrameNumber } =
45
- ReferencedSOPSequence;
46
-
47
- // Long axis
48
-
49
- const longestDiameter = String(
50
- longAxisNUMGroup.MeasuredValueSequence.NumericValue
51
- );
52
-
53
- const shortestDiameter = String(
54
- shortAxisNUMGroup.MeasuredValueSequence.NumericValue
55
- );
56
-
57
- const bottomRight = {
58
- x: Math.max(
59
- longAxisSCOORDGroup.GraphicData[0],
60
- longAxisSCOORDGroup.GraphicData[2],
61
- shortAxisSCOORDGroup.GraphicData[0],
62
- shortAxisSCOORDGroup.GraphicData[2]
63
- ),
64
- y: Math.max(
65
- longAxisSCOORDGroup.GraphicData[1],
66
- longAxisSCOORDGroup.GraphicData[3],
67
- shortAxisSCOORDGroup.GraphicData[1],
68
- shortAxisSCOORDGroup.GraphicData[3]
69
- )
70
- };
71
-
72
- const state = {
73
- sopInstanceUid: ReferencedSOPInstanceUID,
74
- frameIndex: ReferencedFrameNumber || 1,
75
- toolType: Bidirectional.toolType,
76
- active: false,
77
- handles: {
78
- start: {
79
- x: longAxisSCOORDGroup.GraphicData[0],
80
- y: longAxisSCOORDGroup.GraphicData[1],
81
- drawnIndependently: false,
82
- allowedOutsideImage: false,
83
- active: false,
84
- highlight: false,
85
- index: 0
86
- },
87
- end: {
88
- x: longAxisSCOORDGroup.GraphicData[2],
89
- y: longAxisSCOORDGroup.GraphicData[3],
90
- drawnIndependently: false,
91
- allowedOutsideImage: false,
92
- active: false,
93
- highlight: false,
94
- index: 1
95
- },
96
- perpendicularStart: {
97
- x: shortAxisSCOORDGroup.GraphicData[0],
98
- y: shortAxisSCOORDGroup.GraphicData[1],
99
- drawnIndependently: false,
100
- allowedOutsideImage: false,
101
- active: false,
102
- highlight: false,
103
- index: 2
104
- },
105
- perpendicularEnd: {
106
- x: shortAxisSCOORDGroup.GraphicData[2],
107
- y: shortAxisSCOORDGroup.GraphicData[3],
108
- drawnIndependently: false,
109
- allowedOutsideImage: false,
110
- active: false,
111
- highlight: false,
112
- index: 3
113
- },
114
- textBox: {
115
- highlight: false,
116
- hasMoved: true,
117
- active: false,
118
- movesIndependently: false,
119
- drawnIndependently: true,
120
- allowedOutsideImage: true,
121
- hasBoundingBox: true,
122
- x: bottomRight.x + 10,
123
- y: bottomRight.y + 10
124
- }
125
- },
126
- invalidated: false,
127
- isCreating: false,
128
- longestDiameter,
129
- shortestDiameter,
130
- toolName: "Bidirectional",
131
- visible: true,
132
- finding: findingGroup
133
- ? findingGroup.ConceptCodeSequence
134
- : undefined,
135
- findingSites: findingSiteGroups.map(fsg => fsg.ConceptCodeSequence)
136
- };
137
-
138
- return state;
139
- }
140
-
141
- static getTID300RepresentationArguments(tool) {
142
- const { start, end, perpendicularStart, perpendicularEnd } =
143
- tool.handles;
144
- const { shortestDiameter, longestDiameter, finding, findingSites } =
145
- tool;
146
-
147
- const trackingIdentifierTextValue =
148
- "cornerstoneTools@^4.0.0:Bidirectional";
149
-
150
- return {
151
- longAxis: {
152
- point1: start,
153
- point2: end
154
- },
155
- shortAxis: {
156
- point1: perpendicularStart,
157
- point2: perpendicularEnd
158
- },
159
- longAxisLength: longestDiameter,
160
- shortAxisLength: shortestDiameter,
161
- trackingIdentifierTextValue,
162
- finding: finding,
163
- findingSites: findingSites || []
164
- };
165
- }
166
- }
167
-
168
- Bidirectional.toolType = BIDIRECTIONAL;
169
- Bidirectional.utilityToolType = BIDIRECTIONAL;
170
- Bidirectional.TID300Representation = TID300Bidirectional;
171
- Bidirectional.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
172
- if (!TrackingIdentifier.includes(":")) {
173
- return false;
174
- }
175
-
176
- const [cornerstone4Tag, toolType] = TrackingIdentifier.split(":");
177
-
178
- if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
179
- return false;
180
- }
181
-
182
- return toolType === BIDIRECTIONAL;
183
- };
184
-
185
- MeasurementReport.registerTool(Bidirectional);
186
-
187
- export default Bidirectional;
@@ -1,109 +0,0 @@
1
- import { utilities } from "dcmjs";
2
- import MeasurementReport from "./MeasurementReport";
3
- import CORNERSTONE_4_TAG from "./cornerstone4Tag";
4
-
5
- const { Circle: TID300Circle } = utilities.TID300;
6
-
7
- const CIRCLEROI = "CircleRoi";
8
-
9
- class CircleRoi {
10
- /** Gets the measurement data for cornerstone, given DICOM SR measurement data. */
11
- static getMeasurementData(MeasurementGroup) {
12
- const { defaultState, NUMGroup, SCOORDGroup } =
13
- MeasurementReport.getSetupMeasurementData(MeasurementGroup);
14
-
15
- const { GraphicData } = SCOORDGroup;
16
-
17
- const center = { x: GraphicData[0], y: GraphicData[1] };
18
- const end = { x: GraphicData[2], y: GraphicData[3] };
19
-
20
- const state = {
21
- ...defaultState,
22
- toolType: CircleRoi.toolType,
23
- active: false,
24
- cachedStats: {
25
- area: NUMGroup
26
- ? NUMGroup.MeasuredValueSequence.NumericValue
27
- : 0,
28
- // Dummy values to be updated by cornerstone
29
- radius: 0,
30
- perimeter: 0
31
- },
32
- handles: {
33
- end: {
34
- ...end,
35
- highlight: false,
36
- active: false
37
- },
38
- initialRotation: 0,
39
- start: {
40
- ...center,
41
- highlight: false,
42
- active: false
43
- },
44
- textBox: {
45
- hasMoved: false,
46
- movesIndependently: false,
47
- drawnIndependently: true,
48
- allowedOutsideImage: true,
49
- hasBoundingBox: true
50
- }
51
- },
52
- invalidated: true,
53
- visible: true
54
- };
55
-
56
- return state;
57
- }
58
-
59
- /**
60
- * Gets the TID 300 representation of a circle, given the cornerstone representation.
61
- *
62
- * @param {Object} tool
63
- * @returns
64
- */
65
- static getTID300RepresentationArguments(tool) {
66
- const { cachedStats = {}, handles, finding, findingSites } = tool;
67
- const { start: center, end } = handles;
68
- const { area, radius } = cachedStats;
69
-
70
- const perimeter = 2 * Math.PI * radius;
71
- const points = [];
72
-
73
- points.push(center);
74
- points.push(end);
75
-
76
- const trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:CircleRoi";
77
-
78
- return {
79
- area,
80
- perimeter,
81
- radius,
82
- points,
83
- trackingIdentifierTextValue,
84
- finding,
85
- findingSites: findingSites || []
86
- };
87
- }
88
- }
89
-
90
- CircleRoi.toolType = CIRCLEROI;
91
- CircleRoi.utilityToolType = CIRCLEROI;
92
- CircleRoi.TID300Representation = TID300Circle;
93
- CircleRoi.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
94
- if (!TrackingIdentifier.includes(":")) {
95
- return false;
96
- }
97
-
98
- const [cornerstone4Tag, toolType] = TrackingIdentifier.split(":");
99
-
100
- if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
101
- return false;
102
- }
103
-
104
- return toolType === CIRCLEROI;
105
- };
106
-
107
- MeasurementReport.registerTool(CircleRoi);
108
-
109
- export default CircleRoi;
@@ -1,96 +0,0 @@
1
- import { utilities } from "dcmjs";
2
- import MeasurementReport from "./MeasurementReport";
3
- import CORNERSTONE_4_TAG from "./cornerstone4Tag";
4
-
5
- const { CobbAngle: TID300CobbAngle } = utilities.TID300;
6
-
7
- const COBB_ANGLE = "CobbAngle";
8
-
9
- class CobbAngle {
10
- // TODO: this function is required for all Cornerstone Tool Adapters, since it is called by MeasurementReport.
11
- static getMeasurementData(MeasurementGroup) {
12
- const { defaultState, NUMGroup, SCOORDGroup } =
13
- MeasurementReport.getSetupMeasurementData(MeasurementGroup);
14
-
15
- const state = {
16
- ...defaultState,
17
- rAngle: NUMGroup.MeasuredValueSequence.NumericValue,
18
- toolType: CobbAngle.toolType,
19
- handles: {
20
- start: {},
21
- end: {},
22
- start2: {
23
- highlight: true,
24
- drawnIndependently: true
25
- },
26
- end2: {
27
- highlight: true,
28
- drawnIndependently: true
29
- },
30
- textBox: {
31
- hasMoved: false,
32
- movesIndependently: false,
33
- drawnIndependently: true,
34
- allowedOutsideImage: true,
35
- hasBoundingBox: true
36
- }
37
- }
38
- };
39
-
40
- [
41
- state.handles.start.x,
42
- state.handles.start.y,
43
- state.handles.end.x,
44
- state.handles.end.y,
45
- state.handles.start2.x,
46
- state.handles.start2.y,
47
- state.handles.end2.x,
48
- state.handles.end2.y
49
- ] = SCOORDGroup.GraphicData;
50
-
51
- return state;
52
- }
53
-
54
- static getTID300RepresentationArguments(tool) {
55
- const { handles, finding, findingSites } = tool;
56
- const point1 = handles.start;
57
- const point2 = handles.end;
58
- const point3 = handles.start2;
59
- const point4 = handles.end2;
60
- const rAngle = tool.rAngle;
61
-
62
- const trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:CobbAngle";
63
-
64
- return {
65
- point1,
66
- point2,
67
- point3,
68
- point4,
69
- rAngle,
70
- trackingIdentifierTextValue,
71
- finding,
72
- findingSites: findingSites || []
73
- };
74
- }
75
- }
76
-
77
- CobbAngle.toolType = COBB_ANGLE;
78
- CobbAngle.utilityToolType = COBB_ANGLE;
79
- CobbAngle.TID300Representation = TID300CobbAngle;
80
- CobbAngle.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
81
- if (!TrackingIdentifier.includes(":")) {
82
- return false;
83
- }
84
-
85
- const [cornerstone4Tag, toolType] = TrackingIdentifier.split(":");
86
-
87
- if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
88
- return false;
89
- }
90
-
91
- return toolType === COBB_ANGLE;
92
- };
93
-
94
- MeasurementReport.registerTool(CobbAngle);
95
-
96
- export default CobbAngle;