larvitar 0.20.0 → 1.2.2
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/.github/workflows/build-docs.yml +1 -1
- package/.github/workflows/deploy.yml +2 -11
- package/MIGRATION.md +25 -0
- package/README.md +28 -27
- package/imaging/dataDictionary.json +21865 -21865
- package/imaging/{image_anonymization.js → imageAnonymization.js} +1 -1
- package/imaging/{image_colormaps.js → imageColormaps.js} +2 -2
- package/imaging/{image_contours.js → imageContours.js} +1 -2
- package/imaging/{image_io.js → imageIo.js} +18 -15
- package/imaging/{image_layers.js → imageLayers.js} +2 -2
- package/imaging/{image_loading.js → imageLoading.js} +9 -6
- package/imaging/imageParsing.js +301 -0
- package/imaging/{image_presets.js → imagePresets.js} +2 -2
- package/imaging/{image_rendering.js → imageRendering.js} +36 -32
- package/imaging/imageReslice.js +78 -0
- package/imaging/{image_store.js → imageStore.js} +24 -7
- package/imaging/{image_tools.js → imageTools.js} +15 -23
- package/imaging/{image_utils.js → imageUtils.js} +1 -1
- package/imaging/loaders/commonLoader.js +1 -1
- package/imaging/loaders/dicomLoader.js +1 -1
- package/imaging/loaders/fileLoader.js +2 -2
- package/imaging/loaders/multiframeLoader.js +6 -2
- package/imaging/loaders/nrrdLoader.js +11 -7
- package/imaging/tools/{contourTool.js → custom/contourTool.js} +25 -20
- package/imaging/tools/{diameterTool.js → custom/diameterTool.js} +9 -3
- package/imaging/tools/{editMaskTool.js → custom/editMaskTool.js} +7 -1
- package/imaging/tools/{polylineScissorsTool.js → custom/polylineScissorsTool.js} +12 -5
- package/imaging/tools/{seedTool.js → custom/seedTool.js} +3 -3
- package/imaging/tools/{thresholdsBrushTool.js → custom/thresholdsBrushTool.js} +7 -1
- package/imaging/tools/{tools.default.js → default.js} +9 -2
- package/imaging/tools/{tools.interaction.js → interaction.js} +13 -6
- package/imaging/tools/{tools.io.js → io.js} +15 -6
- package/imaging/tools/{tools.main.js → main.js} +14 -13
- package/imaging/tools/polygonSegmentationMixin.js +8 -4
- package/imaging/tools/{tools.segmentation.js → segmentation.js} +171 -58
- package/imaging/tools/segmentations.md +38 -0
- package/imaging/tools/setLabelMap3D.js +248 -0
- package/imaging/tools/{tools.state.js → state.js} +7 -1
- package/imaging/tools/strategies/eraseFreehand.js +8 -9
- package/imaging/tools/strategies/fillFreehand.js +8 -9
- package/index.js +41 -39
- package/modules/vuex/larvitar.js +2 -1
- package/package.json +11 -8
- package/imaging/image_parsing.js +0 -307
- package/imaging/image_reslice.js +0 -80
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @module imaging/
|
|
1
|
+
/** @module imaging/imageStore
|
|
2
2
|
* @desc This file provides functionalities
|
|
3
3
|
* for data config store.
|
|
4
4
|
*/
|
|
@@ -171,6 +171,22 @@ class Larvitar_Store {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Removes all the series from the store
|
|
176
|
+
* @function resetSeriesIds
|
|
177
|
+
*/
|
|
178
|
+
resetSeriesIds(seriesId) {
|
|
179
|
+
if (this.VUEX_STORE) {
|
|
180
|
+
let dispatch = "resetSeriesIds";
|
|
181
|
+
let route = this.vuex_module
|
|
182
|
+
? this.vuex_module + "/" + dispatch
|
|
183
|
+
: dispatch;
|
|
184
|
+
this.vuex_store.dispatch(route, seriesId);
|
|
185
|
+
} else {
|
|
186
|
+
delete this.state.series[seriesId];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
174
190
|
/**
|
|
175
191
|
* Set a value into store
|
|
176
192
|
* @function set
|
|
@@ -259,15 +275,16 @@ class Larvitar_Store {
|
|
|
259
275
|
|
|
260
276
|
/**
|
|
261
277
|
* Instancing the store
|
|
262
|
-
* @param {Object}
|
|
263
|
-
* @param {String}
|
|
278
|
+
* @param {Object} vuexStore - The app vuex store [optional]
|
|
279
|
+
* @param {String} vuexModule - The name of the vuex store module, can be null
|
|
280
|
+
* @param {Boolean} registerModule - If true, the module is registered under Vuex global store
|
|
264
281
|
*/
|
|
265
282
|
|
|
266
|
-
export function initLarvitarStore(
|
|
267
|
-
if (
|
|
268
|
-
larvitar_store = new Larvitar_Store(
|
|
283
|
+
export function initLarvitarStore(vuexStore, vuexModule, registerModule) {
|
|
284
|
+
if (vuexStore) {
|
|
285
|
+
larvitar_store = new Larvitar_Store(vuexStore, vuexModule);
|
|
269
286
|
if (registerModule) {
|
|
270
|
-
|
|
287
|
+
vuexStore.registerModule(vuexModule, larvitar);
|
|
271
288
|
}
|
|
272
289
|
} else {
|
|
273
290
|
larvitar_store = new Larvitar_Store();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @module imaging/
|
|
1
|
+
/** @module imaging/imageTools
|
|
2
2
|
* @desc This file provides functionalities for
|
|
3
3
|
* interacting with cornerstone tools
|
|
4
4
|
*/
|
|
@@ -9,20 +9,20 @@ import cornerstoneTools from "cornerstone-tools";
|
|
|
9
9
|
import { each, extend, filter, remove, cloneDeep } from "lodash";
|
|
10
10
|
|
|
11
11
|
// internal libraries
|
|
12
|
-
import { DEFAULT_TOOLS } from "./tools/
|
|
13
|
-
// import { SeedsTool } from "./tools/seedTool";
|
|
14
|
-
import { ContoursTool } from "./tools/contourTool";
|
|
15
|
-
import { EditMaskTool } from "./tools/editMaskTool";
|
|
16
|
-
import { DiameterTool } from "./tools/diameterTool";
|
|
12
|
+
import { DEFAULT_TOOLS } from "./tools/default";
|
|
13
|
+
// import { SeedsTool } from "./tools/custom/seedTool";
|
|
14
|
+
import { ContoursTool } from "./tools/custom/contourTool";
|
|
15
|
+
import { EditMaskTool } from "./tools/custom/editMaskTool";
|
|
16
|
+
import { DiameterTool } from "./tools/custom/diameterTool";
|
|
17
17
|
import { getImageIdFromSlice } from "./loaders/nrrdLoader";
|
|
18
18
|
import { getSeriesDataFromLarvitarManager } from "./loaders/commonLoader";
|
|
19
|
-
import { parseContours } from "./
|
|
20
|
-
import { isElement } from "./
|
|
19
|
+
import { parseContours } from "./imageContours";
|
|
20
|
+
import { isElement } from "./imageUtils";
|
|
21
21
|
|
|
22
22
|
/*
|
|
23
23
|
* This module provides the following functions to be exported:
|
|
24
24
|
* csToolsCreateStack(element)
|
|
25
|
-
* addDefaultTools()
|
|
25
|
+
* addDefaultTools(toolToActivate)
|
|
26
26
|
* clearMeasurements()
|
|
27
27
|
* addContoursTool(rawContours, maskName)
|
|
28
28
|
* addMaskEditingTool(seriesId,mask,setConfig,callback, targetViewport)
|
|
@@ -44,11 +44,11 @@ import { isElement } from "./image_utils";
|
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Add all default tools, as listed in tools
|
|
47
|
+
* Add all default tools, as listed in tools/default.js
|
|
48
48
|
* @function addDefaultTools
|
|
49
49
|
* @deprecated (OBSOLETE)
|
|
50
50
|
*/
|
|
51
|
-
export const addDefaultTools = function (toolToActivate
|
|
51
|
+
export const addDefaultTools = function (toolToActivate) {
|
|
52
52
|
// for each default tool
|
|
53
53
|
each(DEFAULT_TOOLS, tool => {
|
|
54
54
|
// check if already added
|
|
@@ -99,10 +99,6 @@ export const addDefaultTools = function (toolToActivate, cb) {
|
|
|
99
99
|
allowSkipping: false, // default true
|
|
100
100
|
invert: false
|
|
101
101
|
});
|
|
102
|
-
|
|
103
|
-
if (cb) {
|
|
104
|
-
cb();
|
|
105
|
-
}
|
|
106
102
|
};
|
|
107
103
|
|
|
108
104
|
/**
|
|
@@ -146,8 +142,8 @@ export const addContoursTool = function (rawContours, maskName) {
|
|
|
146
142
|
* Add mask editing tool
|
|
147
143
|
* @function addMaskEditingTool
|
|
148
144
|
* @param {Array} mask - The mask data.
|
|
149
|
-
* @param {String} targetViewport - The target hmtl element id.
|
|
150
145
|
* @param {Function} callback - The tool initialization callback
|
|
146
|
+
* @param {String} targetViewport - The target hmtl element id.
|
|
151
147
|
*/
|
|
152
148
|
export const addMaskEditingTool = function (mask, callback, targetViewport) {
|
|
153
149
|
let enabledElements = cornerstone.getEnabledElements();
|
|
@@ -257,10 +253,10 @@ export const addSeedsTool = function (preLoadSeeds, initViewport) {
|
|
|
257
253
|
};
|
|
258
254
|
|
|
259
255
|
/**
|
|
260
|
-
* Delete all measurements from tools state, for tools that have the "cleaneable" prop set to true in tools
|
|
256
|
+
* Delete all measurements from tools state, for tools that have the "cleaneable" prop set to true in tools/default.js
|
|
261
257
|
* @function clearMeasurements
|
|
262
258
|
*/
|
|
263
|
-
export const clearMeasurements = function (
|
|
259
|
+
export const clearMeasurements = function () {
|
|
264
260
|
let enabledElements = cornerstone.getEnabledElements();
|
|
265
261
|
let clenableTools = filter(DEFAULT_TOOLS, "cleanable");
|
|
266
262
|
|
|
@@ -272,17 +268,13 @@ export const clearMeasurements = function (cb) {
|
|
|
272
268
|
each(enabledElements, el => {
|
|
273
269
|
cornerstone.updateImage(el.element);
|
|
274
270
|
});
|
|
275
|
-
|
|
276
|
-
if (cb) {
|
|
277
|
-
cb();
|
|
278
|
-
}
|
|
279
271
|
};
|
|
280
272
|
|
|
281
273
|
/**
|
|
282
274
|
* Set Tool "active" on all elements (ie, rendered and manipulable) & refresh cornerstone elements
|
|
283
275
|
* @function setToolActive
|
|
284
276
|
* @param {String} toolName - The tool name.
|
|
285
|
-
* @param {Object} options - The custom options. @default from tools
|
|
277
|
+
* @param {Object} options - The custom options. @default from tools/default.js
|
|
286
278
|
* @param {String} activeViewport - The active viewport (if "all", viewports array will be used)
|
|
287
279
|
* @param {Array} viewports - The hmtl element id to be used for tool initialization.
|
|
288
280
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// external libraries
|
|
7
7
|
import cornerstoneWADOImageLoader from "cornerstone-wado-image-loader";
|
|
8
8
|
import { each } from "lodash";
|
|
9
|
-
import { updateLoadedStack } from "../
|
|
9
|
+
import { updateLoadedStack } from "../imageLoading";
|
|
10
10
|
|
|
11
11
|
// internal libraries
|
|
12
12
|
import { buildMultiFrameImage, clearMultiFrameCache } from "./multiframeLoader";
|
|
@@ -8,8 +8,8 @@ import cornerstoneFileImageLoader from "cornerstone-file-image-loader";
|
|
|
8
8
|
import { has } from "lodash";
|
|
9
9
|
|
|
10
10
|
// internal libraries
|
|
11
|
-
import { clearImageCache } from "../
|
|
12
|
-
import { clearCornerstoneElements } from "../
|
|
11
|
+
import { clearImageCache } from "../imageRendering";
|
|
12
|
+
import { clearCornerstoneElements } from "../imageTools";
|
|
13
13
|
|
|
14
14
|
// global variables
|
|
15
15
|
export var fileManager = {};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** @module loaders/multiframeLoader
|
|
2
|
+
* @desc This file is a custom wado loader for multiframe images
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
// external libraries
|
|
2
6
|
import cornerstoneWADOImageLoader from "cornerstone-wado-image-loader";
|
|
3
7
|
import { each, range } from "lodash";
|
|
@@ -8,7 +12,7 @@ import {
|
|
|
8
12
|
getLarvitarImageTracker,
|
|
9
13
|
getLarvitarManager
|
|
10
14
|
} from "./commonLoader";
|
|
11
|
-
import {
|
|
15
|
+
import { parseDataSet } from "../imageParsing";
|
|
12
16
|
|
|
13
17
|
// global module variables
|
|
14
18
|
let customImageLoaderCounter = 0;
|
|
@@ -84,7 +88,7 @@ export const buildMultiFrameImage = function (seriesId, serie) {
|
|
|
84
88
|
// EXTRACT MULTIFRAME METADATA (x52009230) Per-frame Functional Groups Sequence
|
|
85
89
|
let frameMetadata = { ...metadata };
|
|
86
90
|
|
|
87
|
-
|
|
91
|
+
parseDataSet(dataSet, frameMetadata, {
|
|
88
92
|
tags: ["x52009230"],
|
|
89
93
|
frameId: frameNumber
|
|
90
94
|
});
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
getNormalOrientation,
|
|
15
15
|
getPixelRepresentation,
|
|
16
16
|
getTypedArrayFromDataType
|
|
17
|
-
} from "../
|
|
17
|
+
} from "../imageUtils";
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
getImageFrame,
|
|
@@ -243,7 +243,11 @@ export const loadNrrdImage = function (imageId) {
|
|
|
243
243
|
* @param {String} seriesId The series id
|
|
244
244
|
* @return {String} image id
|
|
245
245
|
*/
|
|
246
|
-
export
|
|
246
|
+
export const getImageIdFromSlice = function (
|
|
247
|
+
sliceNumber,
|
|
248
|
+
orientation,
|
|
249
|
+
seriesId
|
|
250
|
+
) {
|
|
247
251
|
var prefix = "nrrdLoader://";
|
|
248
252
|
var serieImageTracker;
|
|
249
253
|
let imageTracker = getLarvitarImageTracker();
|
|
@@ -266,7 +270,7 @@ export function getImageIdFromSlice(sliceNumber, orientation, seriesId) {
|
|
|
266
270
|
var imageId = prefix.concat(imageIndex.toString());
|
|
267
271
|
|
|
268
272
|
return imageId;
|
|
269
|
-
}
|
|
273
|
+
};
|
|
270
274
|
|
|
271
275
|
/**
|
|
272
276
|
* Retrieve slice number for a the given orientation
|
|
@@ -277,7 +281,7 @@ export function getImageIdFromSlice(sliceNumber, orientation, seriesId) {
|
|
|
277
281
|
* @param {String} seriesId The series id
|
|
278
282
|
* @return {Integer} The image slice number
|
|
279
283
|
*/
|
|
280
|
-
export function
|
|
284
|
+
export const getSliceNumberFromImageId = function (imageId, orientation) {
|
|
281
285
|
let imageTracker = getLarvitarImageTracker();
|
|
282
286
|
var firstImageId = findKey(imageTracker, entry => {
|
|
283
287
|
return entry[1] == orientation;
|
|
@@ -289,7 +293,7 @@ export function getSliceNumberFromImageId(imageId, orientation) {
|
|
|
289
293
|
parseInt(imageNumber) - parseInt(firstImageId.split("//").pop());
|
|
290
294
|
|
|
291
295
|
return imageIndex;
|
|
292
|
-
}
|
|
296
|
+
};
|
|
293
297
|
|
|
294
298
|
/**
|
|
295
299
|
* Get series dimension for each view
|
|
@@ -297,7 +301,7 @@ export function getSliceNumberFromImageId(imageId, orientation) {
|
|
|
297
301
|
* @function getNrrdSerieDimensions
|
|
298
302
|
* @return {Object} Series dimension for each view
|
|
299
303
|
*/
|
|
300
|
-
export function
|
|
304
|
+
export const getNrrdSerieDimensions = function () {
|
|
301
305
|
let imageTracker = getLarvitarImageTracker();
|
|
302
306
|
var dim_axial = filter(imageTracker, img => {
|
|
303
307
|
return img[1] == "axial";
|
|
@@ -314,7 +318,7 @@ export function getNrrdSerieDimensions() {
|
|
|
314
318
|
coronal: [dim_sagittal.length, dim_axial.length, dim_coronal.length],
|
|
315
319
|
sagittal: [dim_coronal.length, dim_axial.length, dim_sagittal.length]
|
|
316
320
|
};
|
|
317
|
-
}
|
|
321
|
+
};
|
|
318
322
|
|
|
319
323
|
/* Internal functions */
|
|
320
324
|
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
/** @module imaging/tools/custom/contourTool
|
|
2
|
+
* @desc This file provides functionalities for
|
|
3
|
+
* rendering segmentation contours with a
|
|
4
|
+
* custom cornestone tool
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
// external libraries
|
|
2
8
|
import cornerstone from "cornerstone-core";
|
|
3
9
|
import csTools from "cornerstone-tools";
|
|
4
10
|
import { each, map } from "lodash";
|
|
5
11
|
|
|
6
12
|
// internal libraries
|
|
7
|
-
import { addToolStateSingleSlice } from "
|
|
13
|
+
import { addToolStateSingleSlice } from "../../imageTools";
|
|
8
14
|
|
|
9
15
|
// cornerstone tools imports
|
|
10
16
|
const external = csTools.external;
|
|
@@ -99,19 +105,16 @@ export class ContoursTool extends BaseAnnotationTool {
|
|
|
99
105
|
this._drawingMouseMoveCallback = this._drawingMouseMoveCallback.bind(this);
|
|
100
106
|
this._drawingMouseDragCallback = this._drawingMouseDragCallback.bind(this);
|
|
101
107
|
this._drawingMouseUpCallback = this._drawingMouseUpCallback.bind(this);
|
|
102
|
-
this._drawingMouseDoubleClickCallback =
|
|
103
|
-
this
|
|
104
|
-
);
|
|
108
|
+
this._drawingMouseDoubleClickCallback =
|
|
109
|
+
this._drawingMouseDoubleClickCallback.bind(this);
|
|
105
110
|
this._editMouseUpCallback = this._editMouseUpCallback.bind(this);
|
|
106
111
|
this._editMouseDragCallback = this._editMouseDragCallback.bind(this);
|
|
107
112
|
|
|
108
|
-
this._drawingTouchStartCallback =
|
|
109
|
-
this
|
|
110
|
-
);
|
|
113
|
+
this._drawingTouchStartCallback =
|
|
114
|
+
this._drawingTouchStartCallback.bind(this);
|
|
111
115
|
this._drawingTouchDragCallback = this._drawingTouchDragCallback.bind(this);
|
|
112
|
-
this._drawingDoubleTapClickCallback =
|
|
113
|
-
this
|
|
114
|
-
);
|
|
116
|
+
this._drawingDoubleTapClickCallback =
|
|
117
|
+
this._drawingDoubleTapClickCallback.bind(this);
|
|
115
118
|
this._editTouchDragCallback = this._editTouchDragCallback.bind(this);
|
|
116
119
|
|
|
117
120
|
this.throttledUpdateCachedStats = throttle(this.updateCachedStats, 110);
|
|
@@ -1340,11 +1343,12 @@ export class ContoursTool extends BaseAnnotationTool {
|
|
|
1340
1343
|
|
|
1341
1344
|
data.canComplete = false;
|
|
1342
1345
|
|
|
1343
|
-
const mouseAtOriginHandle =
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1346
|
+
const mouseAtOriginHandle =
|
|
1347
|
+
this._isDistanceSmallerThanCompleteSpacingCanvas(
|
|
1348
|
+
element,
|
|
1349
|
+
points[0],
|
|
1350
|
+
mousePoint
|
|
1351
|
+
);
|
|
1348
1352
|
|
|
1349
1353
|
if (
|
|
1350
1354
|
mouseAtOriginHandle &&
|
|
@@ -1398,11 +1402,12 @@ export class ContoursTool extends BaseAnnotationTool {
|
|
|
1398
1402
|
const mousePoint = config.mouseLocation.handles.start;
|
|
1399
1403
|
const points = data.handles.points;
|
|
1400
1404
|
|
|
1401
|
-
const mouseAtOriginHandle =
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1405
|
+
const mouseAtOriginHandle =
|
|
1406
|
+
this._isDistanceSmallerThanCompleteSpacingCanvas(
|
|
1407
|
+
element,
|
|
1408
|
+
points[0],
|
|
1409
|
+
mousePoint
|
|
1410
|
+
);
|
|
1406
1411
|
|
|
1407
1412
|
if (mouseAtOriginHandle) {
|
|
1408
1413
|
data.canComplete = true;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/** @module imaging/tools/custom/diameterTool
|
|
2
|
+
* @desc This file provides functionalities for
|
|
3
|
+
* a custom diameter cornestone tool
|
|
4
|
+
*/
|
|
2
5
|
|
|
6
|
+
// external libraries
|
|
7
|
+
import csTools from "cornerstone-tools";
|
|
3
8
|
const BidirectionalTool = csTools.BidirectionalTool;
|
|
4
|
-
|
|
5
|
-
import { addToolStateSingleSlice } from "../image_tools";
|
|
6
9
|
import { each } from "lodash";
|
|
7
10
|
|
|
11
|
+
// internal libraries
|
|
12
|
+
import { addToolStateSingleSlice } from "../../imageTools";
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* @public
|
|
10
16
|
* @class DiameterTool
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/** @module imaging/tools/custom/editMaskTool
|
|
2
|
+
* @desc This file provides functionalities for
|
|
3
|
+
* a custom mask cornestone tool
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// external libraries
|
|
1
7
|
import csTools from "cornerstone-tools";
|
|
2
8
|
const external = csTools.external;
|
|
3
9
|
const BaseBrushTool = csTools.importInternal("base/BaseBrushTool");
|
|
@@ -95,7 +101,7 @@ export class EditMaskTool extends BaseBrushTool {
|
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
preventCtrl() {
|
|
98
|
-
this.__proto__.__proto__._isCtrlDown = function() {
|
|
104
|
+
this.__proto__.__proto__._isCtrlDown = function () {
|
|
99
105
|
return false;
|
|
100
106
|
};
|
|
101
107
|
}
|
|
@@ -1,14 +1,21 @@
|
|
|
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
|
|
1
7
|
import cornerstoneTools from "cornerstone-tools";
|
|
8
|
+
const BaseTool = cornerstoneTools.importInternal("base/BaseTool");
|
|
9
|
+
const { rectangleRoiCursor } = cornerstoneTools.importInternal("tools/cursors");
|
|
10
|
+
|
|
11
|
+
// internal libraries
|
|
2
12
|
import {
|
|
3
13
|
fillInsideFreehand,
|
|
4
14
|
fillOutsideFreehand,
|
|
5
15
|
eraseOutsideFreehand,
|
|
6
16
|
eraseInsideFreehand
|
|
7
|
-
} from "
|
|
8
|
-
import polygonSegmentationMixin from "
|
|
9
|
-
|
|
10
|
-
const BaseTool = cornerstoneTools.importInternal("base/BaseTool");
|
|
11
|
-
const { rectangleRoiCursor } = cornerstoneTools.importInternal("tools/cursors");
|
|
17
|
+
} from "../strategies"; // cannot import strategies in other way 🤷
|
|
18
|
+
import polygonSegmentationMixin from "../polygonSegmentationMixin";
|
|
12
19
|
|
|
13
20
|
// Register custom mixin
|
|
14
21
|
cornerstoneTools.register(
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// import { each, cloneDeep } from "lodash";
|
|
4
4
|
|
|
5
5
|
// // internal libraries
|
|
6
|
-
// import { remapVoxel } from "
|
|
7
|
-
// import { addToolStateSingleSlice, setToolEnabled } from "
|
|
8
|
-
// import { getSliceNumberFromImageId } from "
|
|
6
|
+
// import { remapVoxel } from "../../imageUtils";
|
|
7
|
+
// import { addToolStateSingleSlice, setToolEnabled } from "../../imageTools";
|
|
8
|
+
// import { getSliceNumberFromImageId } from "../../loaders/nrrdLoader";
|
|
9
9
|
|
|
10
10
|
// // cornerstone tools imports
|
|
11
11
|
// const BaseAnnotationTool = csTools.importInternal("base/BaseAnnotationTool");
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/** @module imaging/tools/custom/thresholdBrushTool
|
|
2
|
+
* @desc This file provides functionalities for
|
|
3
|
+
* a brush tool with thresholds using a
|
|
4
|
+
* custom cornestone tool
|
|
5
|
+
*/
|
|
2
6
|
|
|
7
|
+
// external libraries
|
|
8
|
+
import cornerstoneTools from "cornerstone-tools";
|
|
3
9
|
const external = cornerstoneTools.external;
|
|
4
10
|
const BaseBrushTool = cornerstoneTools.importInternal("base/BaseBrushTool");
|
|
5
11
|
const segmentationUtils = cornerstoneTools.importInternal(
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/** @module imaging/tools/default
|
|
2
|
+
* @desc This file provides definitions
|
|
3
|
+
* for default tools
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// external libraries
|
|
7
|
+
|
|
1
8
|
/** @module tools/default */
|
|
2
9
|
|
|
3
10
|
/* DEFINE DEFAULT TOOLS
|
|
@@ -19,8 +26,8 @@
|
|
|
19
26
|
*/
|
|
20
27
|
|
|
21
28
|
import { filter, isArray } from "lodash";
|
|
22
|
-
import ThresholdsBrushTool from "./thresholdsBrushTool";
|
|
23
|
-
import PolylineScissorsTool from "./polylineScissorsTool";
|
|
29
|
+
import ThresholdsBrushTool from "./custom/thresholdsBrushTool";
|
|
30
|
+
import PolylineScissorsTool from "./custom/polylineScissorsTool";
|
|
24
31
|
|
|
25
32
|
/**
|
|
26
33
|
* These tools are added with `addDefaultTools()`
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { updateViewportData } from "../image_rendering";
|
|
1
|
+
/** @module imaging/tools/interaction
|
|
2
|
+
* @desc This file provides functionalities for
|
|
3
|
+
* tools interactions
|
|
4
|
+
*/
|
|
6
5
|
|
|
6
|
+
// external libraries
|
|
7
7
|
import { throttle } from "lodash";
|
|
8
8
|
import * as keyCodes from "keycode-js";
|
|
9
9
|
|
|
10
|
+
// internal libraries
|
|
11
|
+
import { DEFAULT_MOUSE_KEYS } from "./default";
|
|
12
|
+
import { setToolActive } from "./main";
|
|
13
|
+
import { isElement } from "../imageUtils";
|
|
14
|
+
import { larvitar_store } from "../imageStore";
|
|
15
|
+
import { updateViewportData } from "../imageRendering";
|
|
16
|
+
|
|
10
17
|
/**
|
|
11
18
|
* TOOLS INTERACTIONS TODOS:
|
|
12
19
|
* - enable touch controls
|
|
@@ -21,7 +28,7 @@ import * as keyCodes from "keycode-js";
|
|
|
21
28
|
* - "restore previous active tool" instead of passed "default" tool
|
|
22
29
|
* - manage left button (an idea could be to cycle over object keys for both buttons)
|
|
23
30
|
* - possibility to change modifier keys
|
|
24
|
-
* @param {Object} config - see tools
|
|
31
|
+
* @param {Object} config - see tools/default
|
|
25
32
|
* @param {Array} viewports - The hmtl element ids to be used for tool activation.
|
|
26
33
|
*/
|
|
27
34
|
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
/** @module imaging/tools/io
|
|
2
|
+
* @desc This file provides functionalities for
|
|
3
|
+
* tools input/output
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// external libraries
|
|
1
7
|
import cornerstone from "cornerstone-core";
|
|
2
8
|
import cornerstoneTools from "cornerstone-tools";
|
|
3
9
|
import { each, map, assign, invert } from "lodash";
|
|
4
10
|
import { unparse } from "papaparse";
|
|
5
11
|
|
|
6
|
-
|
|
12
|
+
// internal libraries
|
|
13
|
+
import { setToolEnabled } from "../imageTools";
|
|
7
14
|
|
|
8
15
|
// DEV
|
|
9
16
|
// import { saved_state_2 } from "./cstools_state_example.js";
|
|
@@ -13,7 +20,7 @@ import { setToolEnabled } from "../image_tools";
|
|
|
13
20
|
* Load annotation from json object
|
|
14
21
|
* @param {Object} jsonData - The previously saved tools state
|
|
15
22
|
*/
|
|
16
|
-
export const loadAnnotations = function(jsonData) {
|
|
23
|
+
export const loadAnnotations = function (jsonData) {
|
|
17
24
|
// DEV
|
|
18
25
|
// if (!jsonData) {
|
|
19
26
|
// jsonData = saved_state_2;
|
|
@@ -52,8 +59,9 @@ export const loadAnnotations = function(jsonData) {
|
|
|
52
59
|
* @param {bool} download - True to download json
|
|
53
60
|
* @param {string} filename - The json file name, @default state.json
|
|
54
61
|
*/
|
|
55
|
-
export const saveAnnotations = function(toDownload, filename = "state.json") {
|
|
56
|
-
let currentToolState =
|
|
62
|
+
export const saveAnnotations = function (toDownload, filename = "state.json") {
|
|
63
|
+
let currentToolState =
|
|
64
|
+
cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
|
57
65
|
if (toDownload) {
|
|
58
66
|
// Convert JSON Array to string.
|
|
59
67
|
var json_string = JSON.stringify(currentToolState);
|
|
@@ -67,11 +75,12 @@ export const saveAnnotations = function(toDownload, filename = "state.json") {
|
|
|
67
75
|
* Save annotation from current stack, download as csv file
|
|
68
76
|
* containing only useful informations for user
|
|
69
77
|
*/
|
|
70
|
-
export const exportAnnotations = function(
|
|
78
|
+
export const exportAnnotations = function (
|
|
71
79
|
fileManager,
|
|
72
80
|
filename = "annotations.csv"
|
|
73
81
|
) {
|
|
74
|
-
let currentToolState =
|
|
82
|
+
let currentToolState =
|
|
83
|
+
cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
|
75
84
|
let csvdata = generateCSV(fileManager, currentToolState);
|
|
76
85
|
let csvstring = unparse(csvdata);
|
|
77
86
|
download(csvstring, filename);
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
+
/** @module imaging/tools/main
|
|
2
|
+
* @desc This file provides functionalities
|
|
3
|
+
* for initializing tools and stacks
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
// external libraries
|
|
2
7
|
import cornerstone from "cornerstone-core";
|
|
3
8
|
import cornerstoneTools from "cornerstone-tools/dist/cornerstoneTools.js";
|
|
4
9
|
import cornerstoneMath from "cornerstone-math";
|
|
5
10
|
import Hammer from "hammerjs";
|
|
6
|
-
|
|
7
11
|
import { each, extend } from "lodash";
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
loadAnnotations,
|
|
12
|
-
exportAnnotations
|
|
13
|
-
} from "./tools.io";
|
|
13
|
+
// internal libraries
|
|
14
|
+
import { saveAnnotations, loadAnnotations, exportAnnotations } from "./io";
|
|
14
15
|
import {
|
|
15
16
|
DEFAULT_TOOLS,
|
|
16
17
|
DEFAULT_STYLE,
|
|
17
18
|
DEFAULT_SETTINGS,
|
|
18
19
|
dvTools
|
|
19
|
-
} from "./
|
|
20
|
-
import { larvitar_store } from "../
|
|
20
|
+
} from "./default";
|
|
21
|
+
import { larvitar_store } from "../imageStore";
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Initialize cornerstone tools with default configuration (extended with custom configuration)
|
|
24
25
|
* @function initializeCSTools
|
|
25
|
-
* @param {Object} settings - the settings object (see tools
|
|
26
|
-
* @param {Object} settings - the style object (see tools
|
|
26
|
+
* @param {Object} settings - the settings object (see tools/default.js)
|
|
27
|
+
* @param {Object} settings - the style object (see tools/default.js)
|
|
27
28
|
* @example larvitar.initializeCSTools({showSVGCursors:false}, {color: "0000FF"});
|
|
28
29
|
*/
|
|
29
30
|
const initializeCSTools = function (settings, style) {
|
|
@@ -137,7 +138,7 @@ const addTool = function (toolName, customConfig, targetElementId) {
|
|
|
137
138
|
};
|
|
138
139
|
|
|
139
140
|
/**
|
|
140
|
-
* Add all default tools, as listed in tools
|
|
141
|
+
* Add all default tools, as listed in tools/default.js
|
|
141
142
|
* @function addDefaultTools
|
|
142
143
|
*/
|
|
143
144
|
export const addDefaultTools = function (elementId) {
|
|
@@ -200,7 +201,7 @@ function tryUpdateImage(element) {
|
|
|
200
201
|
* Set Tool "active" on all elements (ie, rendered and manipulable) & refresh cornerstone elements
|
|
201
202
|
* @function setToolActive
|
|
202
203
|
* @param {String} toolName - The tool name.
|
|
203
|
-
* @param {Object} options - The custom options. @default from tools
|
|
204
|
+
* @param {Object} options - The custom options. @default from tools/default.js
|
|
204
205
|
* @param {Array} viewports - The hmtl element id to be used for tool initialization.
|
|
205
206
|
* @param {Boolean} doNotSetInStore - Flag to avoid setting in store (useful on tools initialization eg in addDefaultTools). NOTE: This is just a hack, we must rework tools/ui sync.
|
|
206
207
|
*/
|
|
@@ -327,7 +328,7 @@ const setToolPassive = function (toolName, viewports) {
|
|
|
327
328
|
/**
|
|
328
329
|
* Set cornerstone tools custom configuration (extend default configuration)
|
|
329
330
|
* @function setToolsStyle
|
|
330
|
-
* @param {Object} style - the style object (see tools
|
|
331
|
+
* @param {Object} style - the style object (see tools/defaults.js)
|
|
331
332
|
*/
|
|
332
333
|
const setToolsStyle = function (style) {
|
|
333
334
|
extend(DEFAULT_STYLE, style);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/** @module imaging/tools/polygonSegmentationMixin
|
|
2
|
+
* @desc This file ovverides `freehandSegmentationMixin`'s
|
|
3
|
+
* `renderToolData` method
|
|
4
|
+
*/
|
|
2
5
|
|
|
6
|
+
// external libraries
|
|
7
|
+
import cornerstoneTools from "cornerstone-tools";
|
|
3
8
|
const external = cornerstoneTools.external;
|
|
4
9
|
const draw = cornerstoneTools.importInternal("drawing/draw");
|
|
5
10
|
const drawJoinedLines = cornerstoneTools.importInternal(
|
|
@@ -147,9 +152,8 @@ function _applyStrategy(evt) {
|
|
|
147
152
|
const points = this.handles.points;
|
|
148
153
|
const { element } = evt.detail;
|
|
149
154
|
|
|
150
|
-
const { labelmap2D, labelmap3D, currentImageIdIndex } =
|
|
151
|
-
element
|
|
152
|
-
);
|
|
155
|
+
const { labelmap2D, labelmap3D, currentImageIdIndex } =
|
|
156
|
+
getters.labelmap2D(element);
|
|
153
157
|
|
|
154
158
|
const pixelData = labelmap2D.pixelData;
|
|
155
159
|
const previousPixeldata = pixelData.slice();
|