Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WS improved #368

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

## Dicom Image Toolkit for CornerstoneJS

### Current version: 2.5.6
### Current version: 2.5.7

### Latest Published Release: 2.5.6
### Latest Published Release: 2.5.7

This library provides common DICOM functionalities to be used in web-applications: it's wrapper that simplifies the use of cornerstone-js environment.

Expand Down
2 changes: 1 addition & 1 deletion dist/larvitar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/larvitar.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/documentation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ <h3> </h3>
<h1 id="larvitar">Larvitar</h1>
<p><a href="https://github.com/dvisionlab/Larvitar"><img src="https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&amp;prefix=%E2%89%A5&amp;suffix=%25&amp;query=$.typeCoverage.atLeast&amp;uri=https%3A%2F%2Fraw.githubusercontent.com%2Fplantain-00%2Ftype-coverage%2Fmaster%2Fpackage.json" alt="type-coverage"></a></p>
<h2 id="dicom-image-toolkit-for-cornerstonejs">Dicom Image Toolkit for CornerstoneJS</h2>
<h3 id="current-version%3A-2.5.6">Current version: 2.5.6</h3>
<h3 id="latest-published-release%3A-2.5.6">Latest Published Release: 2.5.6</h3>
<h3 id="current-version%3A-2.5.7">Current version: 2.5.7</h3>
<h3 id="latest-published-release%3A-2.5.7">Latest Published Release: 2.5.7</h3>
<p>This library provides common DICOM functionalities to be used in web-applications: it's wrapper that simplifies the use of cornerstone-js environment.</p>
<h2 id="features%3A">Features:</h2>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/larvitar.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/examples/watershedSegmentationTool.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
</button>
</div>
<div id="viewer" class="col-8 h-100" style="background-color: black">
<canvas id="outputContainer"></canvas>
<p id="info " style="position: absolute; color: white">
<b>ctrl+mouse wheel to change brush radius</b><br /><b
>click to activate watershed segmentation of features with greyscale
Expand Down Expand Up @@ -262,7 +263,7 @@
</pre>
</div>
</div>
<script src="../../dist/larvitar.js"></script>
<script src="./larvitar.js"></script>
<script src="../../node_modules/cornerstone-core/dist/cornerstone.js"></script>
<script src="../../node_modules/cornerstone-wado-image-loader/dist/cornerstoneWADOImageLoader.bundle.min.js"></script>
<script src="../../node_modules/dicom-parser/dist/dicomParser.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function calculateThresholds(
const meanNorm = mapToRange(mean, minThreshold, maxThreshold);
const stdDevNorm = mapToRange(stddev, minThreshold, maxThreshold);

let xFactor = 1.7;
let xFactor = 1;
xFactor = xFactor;
let lowerThreshold = meanNorm - xFactor * stdDevNorm;
let upperThreshold = meanNorm + xFactor * stdDevNorm;
Expand Down
28 changes: 23 additions & 5 deletions imaging/tools/custom/watershedSegmentationTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export default class WSToggleTool extends BaseBrushTool {
multiImage: false,
startIndex: null,
endIndex: null,
masksNumber: 10
masksNumber: 10,
thresholdFactor: 0
};
constructor(props = {}) {
const defaultProps = {
Expand All @@ -80,7 +81,8 @@ export default class WSToggleTool extends BaseBrushTool {
multiImage: false,
startIndex: null,
endIndex: null,
masksNumber: 10
masksNumber: 10,
thresholdFactor: 0
},
mixins: ["renderBrushMixin"]
};
Expand Down Expand Up @@ -319,7 +321,12 @@ export default class WSToggleTool extends BaseBrushTool {
lowerThreshold,
upperThreshold
).then(result => {
this.maskArrayCurrentImage = result;
this._labelPicker(circleArray, image, result);
let filteredMarkersArray = result.map(value =>
value === this.pickedLabel ? value : 0
);

this.maskArrayCurrentImage = filteredMarkersArray;
labelmap2D.pixelData = this.maskArrayCurrentImage as number[];
external.cornerstone.updateImage(evt.detail.element);
(DEFAULT_TOOLS["WSToggle"] as WSToolConfig).configuration.onload =
Expand Down Expand Up @@ -648,6 +655,9 @@ export default class WSToggleTool extends BaseBrushTool {
// Combine the binary masks using bitwise_and
cv.bitwise_and(lowerBinary, upperBinary, gray);

//const element = document.getElementById("outputContainer");
// Display the result using cv.imshow
//cv.imshow(element, gray);
// get background
let M = cv.Mat.ones(3, 3, cv.CV_8U);
cv.erode(gray, gray, M);
Expand All @@ -656,8 +666,15 @@ export default class WSToggleTool extends BaseBrushTool {
// distance transform
cv.distanceTransform(opening, distTrans, cv.DIST_L2, 5);
cv.normalize(distTrans, distTrans, 1, 0, cv.NORM_INF);
// get foreground
cv.threshold(distTrans, Fg, 0, 255, cv.THRESH_BINARY);
// get foreground-> configurable factor (0 for lungs, 0.4 for mediastinum)
cv.threshold(
distTrans,
Fg,
this.configuration.thresholdFactor * 1,
255,
cv.THRESH_BINARY
);
//cv.imshow(element, Fg);
Fg.convertTo(Fg, cv.CV_8U, 1, 0);
cv.subtract(Bg, Fg, unknown);
// get connected components markers
Expand All @@ -675,6 +692,7 @@ export default class WSToggleTool extends BaseBrushTool {

cv.cvtColor(src, src, cv.COLOR_RGBA2RGB, 0);
cv.watershed(src, markers);

//postProcess(markers: cv.Mat,gray: cv.Mat,markersArray: number[]) //OPTIONAL

shiftAndZeroOut(markersArray, 100);
Expand Down
1 change: 1 addition & 0 deletions imaging/tools/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type WSConfig = {
endIndex: number | null;
masksNumber: number;
onload?: boolean;
thresholdFactor: number;
};
export type WSToolConfig = {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"medical",
"cornerstone"
],
"version": "2.5.6",
"version": "2.5.7",
"description": "typescript library for parsing, loading, rendering and interacting with DICOM images",
"repository": {
"url": "https://github.com/dvisionlab/Larvitar.git",
Expand Down