larvitar 1.3.2 → 1.3.5
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 +6 -6
- package/imaging/imageParsing.js +14 -4
- package/imaging/tools/segmentation.js +27 -11
- package/imaging/tools/segmentations.md +1 -1
- package/index.js +16 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
# Larvitar
|
|
6
6
|
|
|
7
|
-
## Dicom Image Toolkit for
|
|
7
|
+
## Dicom Image Toolkit for CornerstoneJS
|
|
8
8
|
|
|
9
|
-
### Current version: 1.3.
|
|
9
|
+
### Current version: 1.3.5
|
|
10
10
|
|
|
11
|
-
### Latest Stable version: 1.3.
|
|
11
|
+
### Latest Stable version: 1.3.5
|
|
12
12
|
|
|
13
|
-
### Latest Published Release: 1.3.
|
|
13
|
+
### Latest Published Release: 1.3.5
|
|
14
14
|
|
|
15
|
-
This library provides common DICOM functionalities to be used in web-applications: it's wrapper that simplifies the use of
|
|
15
|
+
This library provides common DICOM functionalities to be used in web-applications: it's wrapper that simplifies the use of cornerstone-js environment.
|
|
16
16
|
Orthogonal multiplanar reformat is included as well as custom loader/exporter for nrrd files and [Vuex](https://vuex.vuejs.org/) custom integration.
|
|
17
17
|
|
|
18
18
|
- `index` main file
|
|
@@ -22,7 +22,7 @@ Orthogonal multiplanar reformat is included as well as custom loader/exporter fo
|
|
|
22
22
|
- `imageIo` import a dicom image in .nrrd format and build contiguous array for exporting data as volume
|
|
23
23
|
- `imageLayers` provide support for multi-layer cornerstone fusion renderer
|
|
24
24
|
- `imageLoading` initialize loader and custom loaders
|
|
25
|
-
- `imageParsing` parse dicom files and return a
|
|
25
|
+
- `imageParsing` parse dicom files and return a cornerstone data structure ready to be used for rendering
|
|
26
26
|
- `imagePresets` provides default image CT presets and set functionality
|
|
27
27
|
- `imageRendering` provides rendering functionalities
|
|
28
28
|
- `imageReslice` provides reslice functionalities
|
package/imaging/imageParsing.js
CHANGED
|
@@ -78,11 +78,10 @@ export const readFile = function (entry) {
|
|
|
78
78
|
* @instance
|
|
79
79
|
* @function parseDataSet
|
|
80
80
|
* @param {Object} dataSet - dicom parser dataSet object
|
|
81
|
-
* @param {
|
|
81
|
+
* @param {Object} metadata - Initialized metadata object
|
|
82
82
|
* @param {Array} customFilter - Optional filter: {tags:[], frameId: 0}
|
|
83
83
|
*/
|
|
84
|
-
// This function iterates through dataSet recursively and
|
|
85
|
-
// to the output array passed into it
|
|
84
|
+
// This function iterates through dataSet recursively and store tag values into metadata object
|
|
86
85
|
export const parseDataSet = function (dataSet, metadata, customFilter) {
|
|
87
86
|
// customFilter= {tags:[], frameId:xxx}
|
|
88
87
|
// the dataSet.elements object contains properties for each element parsed. The name of the property
|
|
@@ -113,7 +112,18 @@ export const parseDataSet = function (dataSet, metadata, customFilter) {
|
|
|
113
112
|
}
|
|
114
113
|
} else {
|
|
115
114
|
let tagValue = parseTag(dataSet, propertyName, element);
|
|
116
|
-
|
|
115
|
+
|
|
116
|
+
// identify duplicated tags (keep the first occurency and store the others in another tag eg x00280010_uuid)
|
|
117
|
+
if (metadata[propertyName] !== undefined) {
|
|
118
|
+
console.debug(
|
|
119
|
+
`Identified duplicated tag "${propertyName}", values are:`,
|
|
120
|
+
metadata[propertyName],
|
|
121
|
+
tagValue
|
|
122
|
+
);
|
|
123
|
+
metadata[propertyName + "_" + uuidv4()] = tagValue;
|
|
124
|
+
} else {
|
|
125
|
+
metadata[propertyName] = tagValue;
|
|
126
|
+
}
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
} catch (err) {
|
|
@@ -18,6 +18,7 @@ import { updateStackToolState } from "../imageTools";
|
|
|
18
18
|
|
|
19
19
|
// custom code
|
|
20
20
|
import { setLabelmap3DForElement } from "./setLabelMap3D";
|
|
21
|
+
import { each } from "hammerjs";
|
|
21
22
|
// override function
|
|
22
23
|
setters.labelmap3DForElement = setLabelmap3DForElement;
|
|
23
24
|
|
|
@@ -419,22 +420,37 @@ export function clearSegmentationState() {
|
|
|
419
420
|
|
|
420
421
|
/**
|
|
421
422
|
* Enable brushing
|
|
422
|
-
*
|
|
423
|
-
*
|
|
423
|
+
* NOTE: if options contains `thresholds`, ThresholdsBrush is activated, otherwise BrushTool is activated.
|
|
424
|
+
* Anyway, the activated tool name is returned
|
|
425
|
+
* @param {Object} options - An object containing configuration values (eg radius, thresholds, etc...)
|
|
424
426
|
*/
|
|
425
|
-
export function enableBrushTool(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
427
|
+
export function enableBrushTool(viewports, options) {
|
|
428
|
+
console.log("enable", options);
|
|
429
|
+
setBrushProps(options);
|
|
430
|
+
const brushType = "thresholds" in options ? "ThresholdsBrush" : "Brush";
|
|
431
|
+
setToolActive(brushType, viewports);
|
|
432
|
+
return brushType;
|
|
429
433
|
}
|
|
430
434
|
|
|
431
435
|
/**
|
|
432
436
|
* Disable brushing
|
|
433
|
-
*
|
|
437
|
+
* This function disables both brush tools, if found active on `viewports`
|
|
438
|
+
* @param {String} toolToActivate - The name of the tool to activate after removing the brush @optional
|
|
434
439
|
*/
|
|
435
|
-
export function disableBrushTool(toolToActivate) {
|
|
436
|
-
|
|
437
|
-
|
|
440
|
+
export function disableBrushTool(viewports, toolToActivate) {
|
|
441
|
+
each(viewports, viewport => {
|
|
442
|
+
const el = document.getElementById(viewport);
|
|
443
|
+
if (cornerstoneTools.isToolActiveForElement(el, "ThresholdsBrush")) {
|
|
444
|
+
setToolDisabled("ThresholdsBrush", [viewport]);
|
|
445
|
+
}
|
|
446
|
+
if (cornerstoneTools.isToolActiveForElement(el, "Brush")) {
|
|
447
|
+
setToolDisabled("Brush", [viewport]);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
if (toolToActivate) {
|
|
452
|
+
setToolActive(toolToActivate);
|
|
453
|
+
}
|
|
438
454
|
}
|
|
439
455
|
|
|
440
456
|
/**
|
|
@@ -480,7 +496,7 @@ export function redoLastStroke(elementId) {
|
|
|
480
496
|
|
|
481
497
|
/**
|
|
482
498
|
* Delete mask from state
|
|
483
|
-
* @param {Number} labelId - The labelmap id to
|
|
499
|
+
* @param {Number} labelId - The labelmap id to delete
|
|
484
500
|
*/
|
|
485
501
|
export function deleteMask(labelId) {
|
|
486
502
|
let masks = values(segModule.state.series)[0].labelmaps3D;
|
|
@@ -29,7 +29,7 @@ TODO
|
|
|
29
29
|
|
|
30
30
|
# Larvitar segmentation API
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
To enable brush tools, user can call directly the `setToolActive` / `setToolDisabled` api, in this case he has to handle brush type (thresholds or not), props (radius etc) and tool switching. Otherwise, Larvitar implements the utility functions `enableBrushTool` and `disableBrushTool` that internally handle brush type and props with a single call.
|
|
33
33
|
|
|
34
34
|
# Customization
|
|
35
35
|
|
package/index.js
CHANGED
|
@@ -138,13 +138,20 @@ import {
|
|
|
138
138
|
import {
|
|
139
139
|
initSegmentationModule,
|
|
140
140
|
addSegmentationMask,
|
|
141
|
+
clearSegmentationState,
|
|
142
|
+
deleteMask,
|
|
141
143
|
setActiveLabelmap,
|
|
142
144
|
setActiveSegment,
|
|
145
|
+
enableBrushTool,
|
|
146
|
+
disableBrushTool,
|
|
143
147
|
undoLastStroke,
|
|
144
148
|
redoLastStroke,
|
|
145
149
|
setBrushProps,
|
|
150
|
+
toggleContourMode,
|
|
151
|
+
toggleVisibility,
|
|
146
152
|
hexToRgb,
|
|
147
|
-
rgbToHex
|
|
153
|
+
rgbToHex,
|
|
154
|
+
getActiveLabelmapBuffer
|
|
148
155
|
} from "./imaging/tools/segmentation";
|
|
149
156
|
|
|
150
157
|
import {
|
|
@@ -369,5 +376,12 @@ export {
|
|
|
369
376
|
redoLastStroke,
|
|
370
377
|
setBrushProps,
|
|
371
378
|
hexToRgb,
|
|
372
|
-
rgbToHex
|
|
379
|
+
rgbToHex,
|
|
380
|
+
clearSegmentationState,
|
|
381
|
+
deleteMask,
|
|
382
|
+
enableBrushTool,
|
|
383
|
+
disableBrushTool,
|
|
384
|
+
toggleContourMode,
|
|
385
|
+
toggleVisibility,
|
|
386
|
+
getActiveLabelmapBuffer
|
|
373
387
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"medical",
|
|
7
7
|
"cornerstone"
|
|
8
8
|
],
|
|
9
|
-
"version": "1.3.
|
|
9
|
+
"version": "1.3.5",
|
|
10
10
|
"description": "javascript library for parsing, loading, rendering and interacting with DICOM images",
|
|
11
11
|
"repository": {
|
|
12
12
|
"url": "https://github.com/dvisionlab/Larvitar.git",
|
|
@@ -54,4 +54,4 @@
|
|
|
54
54
|
"module": "dist/larvitar.js",
|
|
55
55
|
"browser": "dist/larvitar.js",
|
|
56
56
|
"type": "module"
|
|
57
|
-
}
|
|
57
|
+
}
|