larvitar 2.0.5 → 2.0.7
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/README.md +2 -2
- package/dist/imaging/imageRendering.d.ts +1 -71
- package/dist/imaging/imageStore.d.ts +5 -0
- package/dist/imaging/loaders/commonLoader.d.ts +4 -4
- package/dist/imaging/loaders/nrrdLoader.d.ts +1 -51
- package/dist/larvitar.js +13 -1
- package/dist/larvitar.js.map +1 -1
- package/imaging/tools/types.d.ts +19 -19
- package/imaging/types.d.ts +110 -2
- package/package.json +7 -2
- package/.github/workflows/build-docs.yml +0 -59
- package/.github/workflows/codeql-analysis.yml +0 -71
- package/.github/workflows/deploy.yml +0 -37
- package/.vscode/settings.json +0 -4
- package/CODE_OF_CONDUCT.md +0 -76
- package/MIGRATION.md +0 -25
- package/bundler/webpack.common.js +0 -27
- package/bundler/webpack.dev.js +0 -23
- package/bundler/webpack.prod.js +0 -19
- package/decs.d.ts +0 -12
- package/dist/imaging/MetaDataReadable.d.ts +0 -41
- package/dist/imaging/MetaDataTypes.d.ts +0 -3489
- package/imaging/dataDictionary.json +0 -21866
- package/imaging/imageAnonymization.ts +0 -135
- package/imaging/imageColormaps.ts +0 -217
- package/imaging/imageContours.ts +0 -196
- package/imaging/imageIo.ts +0 -251
- package/imaging/imageLayers.ts +0 -121
- package/imaging/imageLoading.ts +0 -299
- package/imaging/imageParsing.ts +0 -444
- package/imaging/imagePresets.ts +0 -156
- package/imaging/imageRendering.ts +0 -1091
- package/imaging/imageReslice.ts +0 -87
- package/imaging/imageStore.ts +0 -487
- package/imaging/imageTags.ts +0 -609
- package/imaging/imageTools.js +0 -708
- package/imaging/imageUtils.ts +0 -1079
- package/imaging/loaders/commonLoader.ts +0 -275
- package/imaging/loaders/dicomLoader.ts +0 -66
- package/imaging/loaders/fileLoader.ts +0 -71
- package/imaging/loaders/multiframeLoader.ts +0 -435
- package/imaging/loaders/nrrdLoader.ts +0 -630
- package/imaging/loaders/resliceLoader.ts +0 -205
- package/imaging/monitors/memory.ts +0 -151
- package/imaging/monitors/performance.ts +0 -34
- package/imaging/parsers/ecg.ts +0 -54
- package/imaging/parsers/nrrd.js +0 -485
- package/imaging/tools/custom/4dSliceScrollTool.js +0 -146
- package/imaging/tools/custom/BorderMagnifyTool.js +0 -99
- package/imaging/tools/custom/contourTool.js +0 -1884
- package/imaging/tools/custom/diameterTool.js +0 -141
- package/imaging/tools/custom/editMaskTool.js +0 -141
- package/imaging/tools/custom/ellipticalRoiOverlayTool.js +0 -534
- package/imaging/tools/custom/polygonSegmentationMixin.js +0 -245
- package/imaging/tools/custom/polylineScissorsTool.js +0 -59
- package/imaging/tools/custom/rectangleRoiOverlayTool.js +0 -564
- package/imaging/tools/custom/seedTool.js +0 -342
- package/imaging/tools/custom/setLabelMap3D.ts +0 -242
- package/imaging/tools/custom/thresholdsBrushTool.js +0 -161
- package/imaging/tools/default.ts +0 -594
- package/imaging/tools/interaction.ts +0 -266
- package/imaging/tools/io.ts +0 -229
- package/imaging/tools/main.ts +0 -427
- package/imaging/tools/segmentation.ts +0 -532
- package/imaging/tools/segmentations.md +0 -38
- package/imaging/tools/state.ts +0 -74
- package/imaging/tools/strategies/eraseFreehand.js +0 -76
- package/imaging/tools/strategies/fillFreehand.js +0 -79
- package/imaging/tools/strategies/index.js +0 -2
- package/imaging/waveforms/ecg.ts +0 -191
- package/index.ts +0 -431
- package/jsdoc.json +0 -52
- package/rollup.config.js +0 -51
- package/template/.gitkeep +0 -0
- package/tsconfig.json +0 -102
- /package/imaging/{MetaDataReadable.ts → MetaDataReadable.d.ts} +0 -0
- /package/imaging/{MetaDataTypes.ts → MetaDataTypes.d.ts} +0 -0
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
/** @module imaging/tools/polygonSegmentationMixin
|
|
2
|
-
* @desc This file ovverides `freehandSegmentationMixin`'s
|
|
3
|
-
* `renderToolData` method
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// external libraries
|
|
7
|
-
import cornerstoneTools from "cornerstone-tools";
|
|
8
|
-
const external = cornerstoneTools.external;
|
|
9
|
-
const draw = cornerstoneTools.importInternal("drawing/draw");
|
|
10
|
-
const drawJoinedLines = cornerstoneTools.importInternal(
|
|
11
|
-
"drawing/drawJoinedLines"
|
|
12
|
-
);
|
|
13
|
-
const getNewContext = cornerstoneTools.importInternal("drawing/getNewContext");
|
|
14
|
-
const { getDiffBetweenPixelData } = cornerstoneTools.importInternal(
|
|
15
|
-
"util/segmentationUtils"
|
|
16
|
-
);
|
|
17
|
-
const { getters, setters } = cornerstoneTools.getModule("segmentation");
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Global var, identify when first point has already been placed
|
|
21
|
-
*/
|
|
22
|
-
let isDrawing = false;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Override for `freehandSegmentationMixin`'s `renderToolData` method to render a polyline instead
|
|
26
|
-
* of a freehand region with the first and last point connected. Apply after the `freehandSegmentationMixin`.
|
|
27
|
-
*
|
|
28
|
-
* @override
|
|
29
|
-
* @param {Object} evt The cornerstone render event.
|
|
30
|
-
* @returns {null}
|
|
31
|
-
*/
|
|
32
|
-
function renderToolData(evt) {
|
|
33
|
-
const eventData = evt.detail;
|
|
34
|
-
const { element } = eventData;
|
|
35
|
-
const color = getters.brushColor(element, true);
|
|
36
|
-
const context = getNewContext(eventData.canvasContext.canvas);
|
|
37
|
-
const handles = this.handles;
|
|
38
|
-
|
|
39
|
-
draw(context, context => {
|
|
40
|
-
const isNotTheFirstHandle = handles.points.length > 1;
|
|
41
|
-
|
|
42
|
-
if (isNotTheFirstHandle) {
|
|
43
|
-
for (let j = 0; j < handles.points.length; j++) {
|
|
44
|
-
const lines = [...handles.points[j].lines];
|
|
45
|
-
|
|
46
|
-
drawJoinedLines(context, element, this.handles.points[j], lines, {
|
|
47
|
-
color
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Returns a handle of a particular tool if it is close to the mouse cursor
|
|
56
|
-
*
|
|
57
|
-
* @private
|
|
58
|
-
* @param {Object} element - The element on which the roi is being drawn.
|
|
59
|
-
* @param {Object} data Data object associated with the tool.
|
|
60
|
-
* @param {*} coords
|
|
61
|
-
* @returns {Number|Object|Boolean}
|
|
62
|
-
*/
|
|
63
|
-
function _pointNearHandle(element, data, coords) {
|
|
64
|
-
if (data.handles === undefined || data.handles.points === undefined) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (data.visible === false) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
for (let i = 0; i < data.handles.points.length; i++) {
|
|
73
|
-
const handleCanvas = external.cornerstone.pixelToCanvas(
|
|
74
|
-
element,
|
|
75
|
-
data.handles.points[i]
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
if (external.cornerstoneMath.point.distance(handleCanvas, coords) < 6) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Entry point, manage workflow starting / ending
|
|
86
|
-
* @param {Object} evt
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
function _checkIfDrawing(evt) {
|
|
90
|
-
const { currentPoints, element } = evt.detail;
|
|
91
|
-
const coords = currentPoints.canvas;
|
|
92
|
-
let data = this;
|
|
93
|
-
|
|
94
|
-
if (isDrawing && _pointNearHandle(element, data, coords)) {
|
|
95
|
-
_applyStrategy.call(this, evt);
|
|
96
|
-
} else if (isDrawing) {
|
|
97
|
-
_setHandlesAndUpdate.call(this, evt);
|
|
98
|
-
} else {
|
|
99
|
-
isDrawing = true;
|
|
100
|
-
_startOutliningRegion.call(this, evt);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Sets the start handle point and claims the eventDispatcher event
|
|
106
|
-
*
|
|
107
|
-
* @private
|
|
108
|
-
* @param {*} evt // mousedown, touchstart, click
|
|
109
|
-
* @returns {void|null}
|
|
110
|
-
*/
|
|
111
|
-
function _startOutliningRegion(evt) {
|
|
112
|
-
const element = evt.detail.element;
|
|
113
|
-
const image = evt.detail.currentPoints.image;
|
|
114
|
-
const points = this.handles.points;
|
|
115
|
-
|
|
116
|
-
points.push({
|
|
117
|
-
x: image.x,
|
|
118
|
-
y: image.y,
|
|
119
|
-
lines: []
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
this.currentHandle += 1;
|
|
123
|
-
|
|
124
|
-
external.cornerstone.updateImage(element);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* This function will update the handles and updateImage to force re-draw
|
|
129
|
-
*
|
|
130
|
-
* @private
|
|
131
|
-
* @method _setHandlesAndUpdate
|
|
132
|
-
* @param {(CornerstoneTools.event#TOUCH_DRAG|CornerstoneTools.event#MOUSE_DRAG|CornerstoneTools.event#MOUSE_MOVE)} evt Interaction event emitted by an enabledElement
|
|
133
|
-
* @returns {void}
|
|
134
|
-
*/
|
|
135
|
-
function _setHandlesAndUpdate(evt) {
|
|
136
|
-
const eventData = evt.detail;
|
|
137
|
-
const element = evt.detail.element;
|
|
138
|
-
|
|
139
|
-
this._addPoint(eventData);
|
|
140
|
-
external.cornerstone.updateImage(element);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Event handler for MOUSE_UP/TOUCH_END during handle drag event loop.
|
|
145
|
-
*
|
|
146
|
-
* @private
|
|
147
|
-
* @method _applyStrategy
|
|
148
|
-
* @param {(CornerstoneTools.event#MOUSE_UP|CornerstoneTools.event#TOUCH_END)} evt Interaction event emitted by an enabledElement
|
|
149
|
-
* @returns {void}
|
|
150
|
-
*/
|
|
151
|
-
function _applyStrategy(evt) {
|
|
152
|
-
const points = this.handles.points;
|
|
153
|
-
const { element } = evt.detail;
|
|
154
|
-
|
|
155
|
-
const { labelmap2D, labelmap3D, currentImageIdIndex } =
|
|
156
|
-
getters.labelmap2D(element);
|
|
157
|
-
|
|
158
|
-
const pixelData = labelmap2D.pixelData;
|
|
159
|
-
const previousPixeldata = pixelData.slice();
|
|
160
|
-
|
|
161
|
-
const operationData = {
|
|
162
|
-
points,
|
|
163
|
-
pixelData,
|
|
164
|
-
segmentIndex: labelmap3D.activeSegmentIndex,
|
|
165
|
-
segmentationMixinType: `freehandSegmentationMixin`
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
this.applyActiveStrategy(evt, operationData);
|
|
169
|
-
|
|
170
|
-
const operation = {
|
|
171
|
-
imageIdIndex: currentImageIdIndex,
|
|
172
|
-
diff: getDiffBetweenPixelData(previousPixeldata, pixelData)
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
setters.pushState(this.element, [operation]);
|
|
176
|
-
|
|
177
|
-
// Invalidate the brush tool data so it is redrawn
|
|
178
|
-
setters.updateSegmentsOnLabelmap2D(labelmap2D);
|
|
179
|
-
external.cornerstone.updateImage(element);
|
|
180
|
-
|
|
181
|
-
this._resetHandles();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Sets the start and end handle points to empty objects
|
|
186
|
-
*
|
|
187
|
-
* @private
|
|
188
|
-
* @method _resetHandles
|
|
189
|
-
* @returns {undefined}
|
|
190
|
-
*/
|
|
191
|
-
function _resetHandles() {
|
|
192
|
-
this.handles = {
|
|
193
|
-
points: []
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
isDrawing = false;
|
|
197
|
-
|
|
198
|
-
this.currentHandle = 0;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Adds a point on mouse click in polygon mode.
|
|
203
|
-
*
|
|
204
|
-
* @private
|
|
205
|
-
* @param {Object} evt - data object associated with an event.
|
|
206
|
-
* @returns {void}
|
|
207
|
-
*/
|
|
208
|
-
function _addPoint(evt) {
|
|
209
|
-
const points = this.handles.points;
|
|
210
|
-
|
|
211
|
-
if (points.length) {
|
|
212
|
-
// Add the line from the current handle to the new handle
|
|
213
|
-
points[this.currentHandle - 1].lines.push({
|
|
214
|
-
x: evt.currentPoints.image.x,
|
|
215
|
-
y: evt.currentPoints.image.y,
|
|
216
|
-
lines: []
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Add the new handle
|
|
221
|
-
points.push({
|
|
222
|
-
x: evt.currentPoints.image.x,
|
|
223
|
-
y: evt.currentPoints.image.y,
|
|
224
|
-
lines: []
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Increment the current handle value
|
|
228
|
-
this.currentHandle += 1;
|
|
229
|
-
|
|
230
|
-
// Force onImageRendered to fire
|
|
231
|
-
external.cornerstone.updateImage(evt.element);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* @mixin polygonSegmentationMixin - segmentation operations for polyline
|
|
236
|
-
* @memberof Mixins
|
|
237
|
-
*/
|
|
238
|
-
export default {
|
|
239
|
-
mouseClickCallback: _checkIfDrawing,
|
|
240
|
-
initializeMixin: _resetHandles,
|
|
241
|
-
renderToolData,
|
|
242
|
-
_resetHandles,
|
|
243
|
-
_addPoint,
|
|
244
|
-
_applyStrategy
|
|
245
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/** @module imaging/tools/custom/polygonScissorsTool
|
|
2
|
-
* @desc This file provides functionalities for
|
|
3
|
-
* a custom polyline scissors cornestone tool
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// external libraries
|
|
7
|
-
import cornerstoneTools from "cornerstone-tools";
|
|
8
|
-
const BaseTool = cornerstoneTools.importInternal("base/BaseTool");
|
|
9
|
-
const { rectangleRoiCursor } = cornerstoneTools.importInternal("tools/cursors");
|
|
10
|
-
|
|
11
|
-
// internal libraries
|
|
12
|
-
import {
|
|
13
|
-
fillInsideFreehand,
|
|
14
|
-
fillOutsideFreehand,
|
|
15
|
-
eraseOutsideFreehand,
|
|
16
|
-
eraseInsideFreehand
|
|
17
|
-
} from "../strategies"; // cannot import strategies in other way 🤷
|
|
18
|
-
import polygonSegmentationMixin from "./polygonSegmentationMixin";
|
|
19
|
-
|
|
20
|
-
// Register custom mixin
|
|
21
|
-
cornerstoneTools.register(
|
|
22
|
-
"mixin",
|
|
23
|
-
"polygonSegmentationMixin",
|
|
24
|
-
polygonSegmentationMixin
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @public
|
|
29
|
-
* @class PolylineScissorsTool
|
|
30
|
-
* @memberof Tools
|
|
31
|
-
* @classdesc Tool for manipulating labelmap data by drawing a polyline polygon.
|
|
32
|
-
* @extends Tools.Base.BaseTool
|
|
33
|
-
*/
|
|
34
|
-
export default class PolylineScissorsTool extends BaseTool {
|
|
35
|
-
/** @inheritdoc */
|
|
36
|
-
constructor(props = {}) {
|
|
37
|
-
const defaultProps = {
|
|
38
|
-
name: "PolylineScissors",
|
|
39
|
-
strategies: {
|
|
40
|
-
FILL_INSIDE: fillInsideFreehand,
|
|
41
|
-
FILL_OUTSIDE: fillOutsideFreehand,
|
|
42
|
-
ERASE_OUTSIDE: eraseOutsideFreehand,
|
|
43
|
-
ERASE_INSIDE: eraseInsideFreehand
|
|
44
|
-
},
|
|
45
|
-
cursors: {
|
|
46
|
-
FILL_INSIDE: rectangleRoiCursor,
|
|
47
|
-
FILL_OUTSIDE: rectangleRoiCursor,
|
|
48
|
-
ERASE_OUTSIDE: rectangleRoiCursor,
|
|
49
|
-
ERASE_INSIDE: rectangleRoiCursor
|
|
50
|
-
},
|
|
51
|
-
defaultStrategy: "FILL_INSIDE",
|
|
52
|
-
supportedInteractionTypes: ["Mouse", "Touch"],
|
|
53
|
-
svgCursor: rectangleRoiCursor,
|
|
54
|
-
mixins: ["polygonSegmentationMixin"]
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
super(props, defaultProps);
|
|
58
|
-
}
|
|
59
|
-
}
|