larvitar 2.4.3 → 2.4.4
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/tools/custom/LengthPlotTool.d.ts +6 -3
- package/dist/larvitar.js +129 -48
- package/dist/larvitar.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
## Dicom Image Toolkit for CornerstoneJS
|
|
10
10
|
|
|
11
|
-
### Current version: 2.4.
|
|
11
|
+
### Current version: 2.4.4
|
|
12
12
|
|
|
13
|
-
### Latest Published Release: 2.4.
|
|
13
|
+
### Latest Published Release: 2.4.4
|
|
14
14
|
|
|
15
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
|
|
|
@@ -18,6 +18,8 @@ interface Handles {
|
|
|
18
18
|
start: HandlePosition;
|
|
19
19
|
end: HandlePosition;
|
|
20
20
|
offset: number;
|
|
21
|
+
fixedoffset: number;
|
|
22
|
+
color: string;
|
|
21
23
|
textBox?: {
|
|
22
24
|
active: boolean;
|
|
23
25
|
hasMoved: boolean;
|
|
@@ -70,9 +72,9 @@ interface PlotlyData {
|
|
|
70
72
|
export default class LengthPlotTool extends BaseAnnotationTool {
|
|
71
73
|
name: string;
|
|
72
74
|
eventData?: EventData;
|
|
73
|
-
datahandles?: Handles;
|
|
74
|
-
abovehandles?: Handles;
|
|
75
|
-
belowhandles?: Handles;
|
|
75
|
+
datahandles?: Handles | null;
|
|
76
|
+
abovehandles?: Handles | null;
|
|
77
|
+
belowhandles?: Handles | null;
|
|
76
78
|
plotlydata: Array<PlotlyData>;
|
|
77
79
|
measuring: boolean;
|
|
78
80
|
throttledUpdateCachedStats: any;
|
|
@@ -135,6 +137,7 @@ export default class LengthPlotTool extends BaseAnnotationTool {
|
|
|
135
137
|
hasBoundingBox: boolean;
|
|
136
138
|
};
|
|
137
139
|
offset: number;
|
|
140
|
+
fixedoffset: number;
|
|
138
141
|
};
|
|
139
142
|
} | undefined;
|
|
140
143
|
/**
|
package/dist/larvitar.js
CHANGED
|
@@ -163690,10 +163690,10 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163690
163690
|
offset: 0
|
|
163691
163691
|
};
|
|
163692
163692
|
this.eventData;
|
|
163693
|
-
this.datahandles;
|
|
163693
|
+
this.datahandles = null;
|
|
163694
163694
|
this.click = 0;
|
|
163695
|
-
this.abovehandles;
|
|
163696
|
-
this.belowhandles;
|
|
163695
|
+
this.abovehandles = null;
|
|
163696
|
+
this.belowhandles = null;
|
|
163697
163697
|
this.borderRight;
|
|
163698
163698
|
this.borderLeft = 0;
|
|
163699
163699
|
this.evt;
|
|
@@ -163701,6 +163701,7 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163701
163701
|
this.wheelactive = false;
|
|
163702
163702
|
this.currentTarget = null;
|
|
163703
163703
|
this.fixedOffset = 0;
|
|
163704
|
+
this.theta = null;
|
|
163704
163705
|
this.plotlydata = [];
|
|
163705
163706
|
this.measuring = false;
|
|
163706
163707
|
this.handleMouseUp = this.handleMouseUp.bind(this);
|
|
@@ -163717,7 +163718,10 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163717
163718
|
handleMouseUp() {
|
|
163718
163719
|
var _a, _b;
|
|
163719
163720
|
const toolData = getToolState(this.currentTarget, this.name);
|
|
163720
|
-
this.
|
|
163721
|
+
if (this.measuring === true) {
|
|
163722
|
+
toolData.data[toolData.data.length - 1].handles.fixedoffset =
|
|
163723
|
+
toolData.data[toolData.data.length - 1].handles.offset;
|
|
163724
|
+
}
|
|
163721
163725
|
this.click = +1;
|
|
163722
163726
|
this.measuring =
|
|
163723
163727
|
((_a = this.datahandles) === null || _a === void 0 ? void 0 : _a.end.x) === ((_b = this.datahandles) === null || _b === void 0 ? void 0 : _b.start.x) && this.click === 1
|
|
@@ -163730,10 +163734,13 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163730
163734
|
let color = "green";
|
|
163731
163735
|
return { points, pixelValues, color };
|
|
163732
163736
|
};
|
|
163737
|
+
const result = handleData(this.datahandles);
|
|
163733
163738
|
const aboveResults = handleData(this.abovehandles);
|
|
163734
|
-
aboveResults.color =
|
|
163739
|
+
aboveResults.color = this.abovehandles.color;
|
|
163740
|
+
aboveResults.points = result.points;
|
|
163735
163741
|
const belowResults = handleData(this.belowhandles);
|
|
163736
|
-
belowResults.color =
|
|
163742
|
+
belowResults.color = this.belowhandles.color;
|
|
163743
|
+
belowResults.points = result.points;
|
|
163737
163744
|
const data = [handleData(this.datahandles), aboveResults, belowResults];
|
|
163738
163745
|
if (this.measuring === false) {
|
|
163739
163746
|
this.createPlot(...data);
|
|
@@ -163751,12 +163758,17 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163751
163758
|
if (toolData) {
|
|
163752
163759
|
const index = toolData.data.findIndex(obj => obj.active === true);
|
|
163753
163760
|
const indexTracing = toolData.data.findIndex(obj => obj.handles.end.moving === true);
|
|
163754
|
-
if (toolData.data.length != 0 &&
|
|
163755
|
-
|
|
163756
|
-
|
|
163761
|
+
if ((toolData.data.length != 0 &&
|
|
163762
|
+
index != undefined &&
|
|
163763
|
+
index != -1 &&
|
|
163764
|
+
toolData.data[index] != undefined &&
|
|
163765
|
+
evt.buttons === 1) ||
|
|
163766
|
+
(indexTracing != undefined &&
|
|
163767
|
+
indexTracing != -1 &&
|
|
163768
|
+
toolData.data[index] != undefined)) {
|
|
163757
163769
|
const { deltaY } = evt;
|
|
163758
163770
|
toolData.data[index].handles.offset += deltaY > 0 ? 1 : -1;
|
|
163759
|
-
evt.preventDefault();
|
|
163771
|
+
evt.preventDefault();
|
|
163760
163772
|
this.renderToolData(evt);
|
|
163761
163773
|
cornerstone_core_1.default.updateImage(this.eventData.element);
|
|
163762
163774
|
}
|
|
@@ -163776,6 +163788,12 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163776
163788
|
eventData.element.removeEventListener("mouseup", () => this.handleMouseUp());
|
|
163777
163789
|
eventData.element.removeEventListener("wheel", evt => this.changeOffset(evt));
|
|
163778
163790
|
}
|
|
163791
|
+
if (this.datahandles != null) {
|
|
163792
|
+
this.datahandles = null;
|
|
163793
|
+
this.abovehandles = null;
|
|
163794
|
+
this.belowhandles = null;
|
|
163795
|
+
this.theta = null;
|
|
163796
|
+
}
|
|
163779
163797
|
eventData.element.addEventListener("mouseup", () => this.handleMouseUp());
|
|
163780
163798
|
eventData.element.addEventListener("wheel", evt => this.changeOffset(evt));
|
|
163781
163799
|
this.measuring = true;
|
|
@@ -163812,7 +163830,8 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163812
163830
|
allowedOutsideImage: true,
|
|
163813
163831
|
hasBoundingBox: true
|
|
163814
163832
|
},
|
|
163815
|
-
offset: 0
|
|
163833
|
+
offset: 0,
|
|
163834
|
+
fixedoffset: 0
|
|
163816
163835
|
}
|
|
163817
163836
|
};
|
|
163818
163837
|
}
|
|
@@ -163904,29 +163923,61 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163904
163923
|
if (this.measuring === false &&
|
|
163905
163924
|
this.wheelactive === true &&
|
|
163906
163925
|
data.active === true) {
|
|
163907
|
-
|
|
163926
|
+
data.handles.fixedoffset = data.handles.offset;
|
|
163908
163927
|
}
|
|
163909
163928
|
data.handles.offset =
|
|
163910
163929
|
(this.measuring === true && data.handles.end.moving === true) ||
|
|
163911
163930
|
this.wheelactive === true
|
|
163912
163931
|
? data.handles.offset
|
|
163913
|
-
:
|
|
163932
|
+
: data.handles.fixedoffset;
|
|
163914
163933
|
//data.handles.end.y = data.handles.start.y;
|
|
163915
163934
|
drawLine(context, element, data.handles.start, data.handles.end, lineOptions);
|
|
163935
|
+
let theta = Math.atan2(data.handles.end.y - data.handles.start.y, data.handles.end.x - data.handles.start.x);
|
|
163936
|
+
let abovelineOptions = { color: "red", lineWidth: 3 };
|
|
163937
|
+
let belowlineOptions = { color: "blue", lineWidth: 3 };
|
|
163938
|
+
if (data.handles.end.x - data.handles.start.x != 0) {
|
|
163939
|
+
this.theta = this.theta === null ? theta : this.theta;
|
|
163940
|
+
if (radiansToDegrees(this.theta) > 90 &&
|
|
163941
|
+
radiansToDegrees(this.theta) < 275) {
|
|
163942
|
+
abovelineOptions.color = "blue";
|
|
163943
|
+
belowlineOptions.color = "red";
|
|
163944
|
+
}
|
|
163945
|
+
}
|
|
163916
163946
|
const aboveHandles = {
|
|
163917
|
-
start: {
|
|
163918
|
-
|
|
163919
|
-
|
|
163947
|
+
start: {
|
|
163948
|
+
x: start.x + data.handles.offset * Math.sin(theta),
|
|
163949
|
+
y: start.y - data.handles.offset * Math.cos(theta)
|
|
163950
|
+
},
|
|
163951
|
+
end: {
|
|
163952
|
+
x: end.x + data.handles.offset * Math.sin(theta),
|
|
163953
|
+
y: end.y - data.handles.offset * Math.cos(theta)
|
|
163954
|
+
},
|
|
163955
|
+
offset: data.handles.offset,
|
|
163956
|
+
fixedoffset: data.handles.fixedoffset,
|
|
163957
|
+
color: abovelineOptions.color
|
|
163920
163958
|
};
|
|
163921
163959
|
const belowHandles = {
|
|
163922
|
-
start: {
|
|
163923
|
-
|
|
163924
|
-
|
|
163960
|
+
start: {
|
|
163961
|
+
x: start.x - data.handles.offset * Math.sin(theta),
|
|
163962
|
+
y: start.y + data.handles.offset * Math.cos(theta)
|
|
163963
|
+
},
|
|
163964
|
+
end: {
|
|
163965
|
+
x: end.x - data.handles.offset * Math.sin(theta),
|
|
163966
|
+
y: end.y + data.handles.offset * Math.cos(theta)
|
|
163967
|
+
},
|
|
163968
|
+
offset: data.handles.offset,
|
|
163969
|
+
fixedoffset: data.handles.fixedoffset,
|
|
163970
|
+
color: belowlineOptions.color
|
|
163925
163971
|
};
|
|
163926
|
-
|
|
163927
|
-
|
|
163928
|
-
|
|
163929
|
-
|
|
163972
|
+
if (radiansToDegrees(this.theta) > 90 &&
|
|
163973
|
+
radiansToDegrees(this.theta) < 275) {
|
|
163974
|
+
drawLine(context, element, belowHandles.start, belowHandles.end, belowlineOptions);
|
|
163975
|
+
drawLine(context, element, aboveHandles.start, aboveHandles.end, abovelineOptions);
|
|
163976
|
+
}
|
|
163977
|
+
else {
|
|
163978
|
+
drawLine(context, element, aboveHandles.start, aboveHandles.end, abovelineOptions);
|
|
163979
|
+
drawLine(context, element, belowHandles.start, belowHandles.end, belowlineOptions);
|
|
163980
|
+
}
|
|
163930
163981
|
const handleOptions = {
|
|
163931
163982
|
color,
|
|
163932
163983
|
handleRadius: 6,
|
|
@@ -163939,20 +163990,39 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163939
163990
|
this.datahandles = data.handles;
|
|
163940
163991
|
this.abovehandles = aboveHandles;
|
|
163941
163992
|
this.belowhandles = belowHandles;
|
|
163942
|
-
|
|
163943
|
-
|
|
163944
|
-
|
|
163945
|
-
|
|
163946
|
-
|
|
163947
|
-
|
|
163948
|
-
|
|
163949
|
-
|
|
163950
|
-
|
|
163951
|
-
|
|
163952
|
-
|
|
163953
|
-
|
|
163954
|
-
|
|
163955
|
-
|
|
163993
|
+
if (radiansToDegrees(this.theta) > 90 &&
|
|
163994
|
+
radiansToDegrees(this.theta) < 275) {
|
|
163995
|
+
drawHandles(context, this.evt.detail, belowHandles, {
|
|
163996
|
+
color: belowlineOptions.color,
|
|
163997
|
+
handleRadius: 3,
|
|
163998
|
+
drawHandlesIfActive: drawHandlesOnHover,
|
|
163999
|
+
hideHandlesIfMoving,
|
|
164000
|
+
fill: belowlineOptions.color
|
|
164001
|
+
});
|
|
164002
|
+
drawHandles(context, this.evt.detail, aboveHandles, {
|
|
164003
|
+
color: abovelineOptions.color,
|
|
164004
|
+
handleRadius: 3,
|
|
164005
|
+
drawHandlesIfActive: drawHandlesOnHover,
|
|
164006
|
+
hideHandlesIfMoving,
|
|
164007
|
+
fill: abovelineOptions.color
|
|
164008
|
+
});
|
|
164009
|
+
}
|
|
164010
|
+
else {
|
|
164011
|
+
drawHandles(context, this.evt.detail, aboveHandles, {
|
|
164012
|
+
color: abovelineOptions.color,
|
|
164013
|
+
handleRadius: 3,
|
|
164014
|
+
drawHandlesIfActive: drawHandlesOnHover,
|
|
164015
|
+
hideHandlesIfMoving,
|
|
164016
|
+
fill: abovelineOptions.color
|
|
164017
|
+
});
|
|
164018
|
+
drawHandles(context, this.evt.detail, belowHandles, {
|
|
164019
|
+
color: belowlineOptions.color,
|
|
164020
|
+
handleRadius: 3,
|
|
164021
|
+
drawHandlesIfActive: drawHandlesOnHover,
|
|
164022
|
+
hideHandlesIfMoving,
|
|
164023
|
+
fill: belowlineOptions.color
|
|
164024
|
+
});
|
|
164025
|
+
}
|
|
163956
164026
|
}
|
|
163957
164027
|
});
|
|
163958
164028
|
}
|
|
@@ -163970,11 +164040,12 @@ class LengthPlotTool extends BaseAnnotationTool {
|
|
|
163970
164040
|
getPointsAlongLine(startHandle, endHandle, colPixelSpacing) {
|
|
163971
164041
|
let points = [];
|
|
163972
164042
|
const addPoints = (start, end, step) => {
|
|
163973
|
-
const
|
|
163974
|
-
const numPoints = Math.floor(end.x) -
|
|
164043
|
+
const startPoint = Math.floor(Math.sqrt(Math.pow(start.x, 2) + Math.pow(start.y, 2))) + 1;
|
|
164044
|
+
const numPoints = Math.floor(Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2)) +
|
|
164045
|
+
1);
|
|
163975
164046
|
points = new Array(numPoints + 1);
|
|
163976
164047
|
for (let i = 0; i <= numPoints; i++) {
|
|
163977
|
-
points[i] = (
|
|
164048
|
+
points[i] = (startPoint + i) * step;
|
|
163978
164049
|
}
|
|
163979
164050
|
};
|
|
163980
164051
|
if (endHandle.x > startHandle.x) {
|
|
@@ -164076,6 +164147,14 @@ function clearToolData(element, toolName) {
|
|
|
164076
164147
|
});
|
|
164077
164148
|
}
|
|
164078
164149
|
}
|
|
164150
|
+
// Function to convert radians to degrees
|
|
164151
|
+
function radiansToDegrees(radians) {
|
|
164152
|
+
let angle = radians * (180 / Math.PI);
|
|
164153
|
+
if (angle < 0) {
|
|
164154
|
+
angle += 360; // Add 360 to negative angles to bring them into the 0-360 range
|
|
164155
|
+
}
|
|
164156
|
+
return angle;
|
|
164157
|
+
}
|
|
164079
164158
|
//to set custom offset do this: DEFAULT_TOOLS["LengthPlot"].offset=parseInt(document.getElementById("offset").value,10)
|
|
164080
164159
|
//create plot in viewport in layeout doable like this:
|
|
164081
164160
|
//const currentDiv = eventData.element //viewport element
|
|
@@ -165310,13 +165389,6 @@ class WSToggleTool extends BaseBrushTool {
|
|
|
165310
165389
|
endIndex: null,
|
|
165311
165390
|
masksNumber: 10
|
|
165312
165391
|
};
|
|
165313
|
-
if (typeof cv !== "undefined" && cv !== null) {
|
|
165314
|
-
console.log("OpenCV has been successfully imported.");
|
|
165315
|
-
// You can use OpenCV functions here
|
|
165316
|
-
}
|
|
165317
|
-
else {
|
|
165318
|
-
console.error('OpenCV has not been imported. Watershed Segmentation Tool will not work. Please import src="https://docs.opencv.org/4.5.4/opencv.js" in your HTML');
|
|
165319
|
-
}
|
|
165320
165392
|
this._handleMouseMove = this._handleMouseMove.bind(this);
|
|
165321
165393
|
document.addEventListener("mousemove", this._handleMouseMove);
|
|
165322
165394
|
setSegmentationConfig({
|
|
@@ -167305,6 +167377,15 @@ function tryUpdateImage(element) {
|
|
|
167305
167377
|
*/
|
|
167306
167378
|
const setToolActive = function (toolName, options, viewports, doNotSetInStore) {
|
|
167307
167379
|
var _a, _b;
|
|
167380
|
+
if (toolName === "WSToggle") {
|
|
167381
|
+
if (typeof cv !== "undefined" && cv !== null) {
|
|
167382
|
+
console.log("OpenCV has been successfully imported.");
|
|
167383
|
+
// You can use OpenCV functions here
|
|
167384
|
+
}
|
|
167385
|
+
else {
|
|
167386
|
+
console.error('OpenCV has not been imported. Watershed Segmentation Tool will not work. Please import src="https://docs.opencv.org/4.5.4/opencv.js" in your HTML');
|
|
167387
|
+
}
|
|
167388
|
+
}
|
|
167308
167389
|
let defaultOpt = Object.assign({}, (_a = default_1.DEFAULT_TOOLS[toolName]) === null || _a === void 0 ? void 0 : _a.options); // deep copy obj because otherwise cornerstone tools will modify it
|
|
167309
167390
|
(0, lodash_1.extend)(defaultOpt, options);
|
|
167310
167391
|
if (viewports && viewports.length > 0) {
|
|
@@ -169113,7 +169194,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"x00000000":{"tag":"x00000000","vr":"
|
|
|
169113
169194
|
/***/ ((module) => {
|
|
169114
169195
|
|
|
169115
169196
|
"use strict";
|
|
169116
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"larvitar","keywords":["DICOM","imaging","medical","cornerstone"],"version":"2.4.
|
|
169197
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"larvitar","keywords":["DICOM","imaging","medical","cornerstone"],"version":"2.4.4","description":"typescript library for parsing, loading, rendering and interacting with DICOM images","repository":{"url":"https://github.com/dvisionlab/Larvitar.git","type":"git"},"main":"dist/larvitar.js","types":"dist/index.d.ts","files":["dist","imaging/**/*.d.ts"],"scripts":{"coverage":"typescript-coverage-report","generate-docs":"node_modules/.bin/jsdoc -c jsdoc.json","build":"webpack --config ./bundler/webpack.prod.js && cp ./dist/larvitar.js ./docs/examples/larvitar.js","dev":"webpack --progress --config ./bundler/webpack.dev.js && cp ./dist/larvitar.js ./docs/examples/larvitar.js","dev-wip":"webpack serve --config ./bundler/webpack.dev-wip.js"},"author":"Simone Manini <simone.manini@dvisionlab.com> (https://www.dvisionlab.com)","contributors":["Mattia Ronzoni <mattia.ronzoni@dvisionlab.com> (https://www.dvisionlab.com)","Sara Zanchi <sara.zanchi@dvisionlab.com> (https://www.dvisionlab.com)","Ale Re <ale.re@dvisionlab.com> (https://www.dvisionlab.com)","Laura Borghesi Re <laura.borghesi@dvisionlab.com> (https://www.dvisionlab.com)"],"license":"MIT","dependencies":{"@rollup/plugin-commonjs":"^17.1.0","cornerstone-core":"^2.6.1","cornerstone-file-image-loader":"^0.3.0","cornerstone-tools":"^6.0.7","cornerstone-wado-image-loader":"^4.13.2","cornerstone-web-image-loader":"^2.1.1","crypto-js":"^4.1.1","dicom-character-set":"^1.0.3","dicom-parser":"^1.8.13","docdash":"^1.2.0","hammerjs":"^2.0.8","jpeg-lossless-decoder-js":"^2.0.7","keycode-js":"^3.1.0","lodash":"^4.17.15","pako":"^1.0.10","papaparse":"^5.3.0","pdfjs-dist":"^3.8.162","plotly.js-dist-min":"^2.27.1","uuid":"^8.3.2"},"devDependencies":{"@babel/core":"^7.21.8","@types/cornerstone-core":"^2.3.0","@types/crypto-js":"^4.1.1","@types/hammerjs":"^2.0.41","@types/lodash":"^4.14.192","@types/papaparse":"^5.3.7","@types/pdfjs-dist":"^2.10.378","@types/plotly.js":"^2.12.30","@types/plotly.js-dist-min":"^2.3.4","@types/uuid":"^9.0.1","babel-loader":"^9.1.2","clean-webpack-plugin":"^4.0.0","copy-webpack-plugin":"^11.0.0","fs":"^0.0.1-security","html-loader":"^4.2.0","html-webpack-plugin":"^5.5.0","ip":"^1.1.8","jsdoc":"^3.6.4","portfinder-sync":"^0.0.2","ts-loader":"^9.4.2","typescript":"^5.0.2","typescript-coverage-report":"^0.7.0","webpack":"^5.76.3","webpack-bundle-analyzer":"^4.8.0","webpack-cli":"^5.0.1","webpack-dev-server":"^4.13.1"}}');
|
|
169117
169198
|
|
|
169118
169199
|
/***/ })
|
|
169119
169200
|
|