Compare commits
2
Commits
8afde176f3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
174c7a444f | ||
|
|
5ceacc441d |
+43
-32
@@ -585,13 +585,14 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l
|
|||||||
//});
|
//});
|
||||||
} else {
|
} else {
|
||||||
let url;
|
let url;
|
||||||
// This doesn't seem to have any benefit
|
// Cornerstone needs the whole url to load? (not relative)
|
||||||
//if (data_url.startsWith("http")) {
|
if (data_url.startsWith("http")) {
|
||||||
// url = data_url;
|
url = data_url;
|
||||||
//} else {
|
} else {
|
||||||
// url = window.location.href.replace(/\/\#\/?$/, '') + "/" + data_url
|
url = window.location.href.replace(/\/\#\/?$/, '').replace("index.html", "") + "/" + data_url
|
||||||
//}
|
}
|
||||||
url = data_url;
|
//url = data_url;
|
||||||
|
|
||||||
|
|
||||||
if (url.endsWith("dcm")) {
|
if (url.endsWith("dcm")) {
|
||||||
url = "wadouri:" + url;
|
url = "wadouri:" + url;
|
||||||
@@ -618,7 +619,11 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l
|
|||||||
|
|
||||||
//console.log("LOAD and cache, then", image);
|
//console.log("LOAD and cache, then", image);
|
||||||
loadCornerstoneMainImage(element, image, stack, db, load_as_stack);
|
loadCornerstoneMainImage(element, image, stack, db, load_as_stack);
|
||||||
checkAnonStatus(image.data)
|
|
||||||
|
// We can only check dicom data if it exists (e.g. not on jpegs)
|
||||||
|
if (image.data != undefined) {
|
||||||
|
checkAnonStatus(image.data)
|
||||||
|
}
|
||||||
|
|
||||||
let load_annotation_image = true;
|
let load_annotation_image = true;
|
||||||
if (load_annotation_image) {
|
if (load_annotation_image) {
|
||||||
@@ -1215,6 +1220,12 @@ export function loadStackIndex(new_index, dicom_element) {
|
|||||||
//c = cornerstone.getEnabledElement(dicom_element)
|
//c = cornerstone.getEnabledElement(dicom_element)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function loadImageById(imageId, dicom_element) {
|
||||||
|
cornerstone.loadImage(imageId).then(b => {
|
||||||
|
cornerstone.displayImage(dicom_element, b);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function urltoFile(url, filename, mimeType) {
|
function urltoFile(url, filename, mimeType) {
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
@@ -1277,34 +1288,34 @@ export function getNextAnnotationImage(element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function manualScrollDicom(n, dicom_element) {
|
function manualScrollDicom(n, dicom_element) {
|
||||||
// There must be a better way to do this...
|
// There must be a better way to do this...
|
||||||
//dicom_element = document.getElementById("dicom-image");
|
//dicom_element = document.getElementById("dicom-image");
|
||||||
let c = cornerstone.getEnabledElement(dicom_element);
|
let c = cornerstone.getEnabledElement(dicom_element);
|
||||||
|
|
||||||
let max = c.toolStateManager.toolState.stack.data[0].imageIds.length;
|
let max = c.toolStateManager.toolState.stack.data[0].imageIds.length;
|
||||||
|
|
||||||
if (max < 2) {
|
if (max < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let current_index =
|
let current_index =
|
||||||
c.toolStateManager.toolState.stack.data[0].currentImageIdIndex;
|
c.toolStateManager.toolState.stack.data[0].currentImageIdIndex;
|
||||||
|
|
||||||
let new_index = current_index + n
|
let new_index = current_index + n
|
||||||
|
|
||||||
let corrected_index = Math.min(Math.max(new_index, 0), max)
|
|
||||||
|
|
||||||
// TODO: if loop
|
let corrected_index = Math.min(Math.max(new_index, 0), max)
|
||||||
//if (new_index >= max) {
|
|
||||||
// corrected_index = new_index - max;
|
|
||||||
//} else if (new_index < 0) {
|
|
||||||
// corrected_index = new_index + max;
|
|
||||||
//}
|
|
||||||
|
|
||||||
c.toolStateManager.toolState.stack.data[0].currentImageIdIndex = corrected_index;
|
// TODO: if loop
|
||||||
let id = c.toolStateManager.toolState.stack.data[0].imageIds[corrected_index];
|
//if (new_index >= max) {
|
||||||
cornerstone.loadImage(id).then((b) => {
|
// corrected_index = new_index - max;
|
||||||
cornerstone.displayImage(dicom_element, b);
|
//} else if (new_index < 0) {
|
||||||
});
|
// corrected_index = new_index + max;
|
||||||
// c = cornerstone.getEnabledElement(dicom_element)
|
//}
|
||||||
|
|
||||||
|
c.toolStateManager.toolState.stack.data[0].currentImageIdIndex = corrected_index;
|
||||||
|
let id = c.toolStateManager.toolState.stack.data[0].imageIds[corrected_index];
|
||||||
|
cornerstone.loadImage(id).then((b) => {
|
||||||
|
cornerstone.displayImage(dicom_element, b);
|
||||||
|
});
|
||||||
|
// c = cornerstone.getEnabledElement(dicom_element)
|
||||||
}
|
}
|
||||||
+3
-1
@@ -24,11 +24,13 @@
|
|||||||
<main>
|
<main>
|
||||||
<h1>A dicom viewer</h1>
|
<h1>A dicom viewer</h1>
|
||||||
|
|
||||||
|
<div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/1.jpg","test_images/IMG1.dcm"]' data-annotations=""></div></div>
|
||||||
<!-- <div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/IMG1.dcm","test_images/IMG1.dcm"]' data-annotations='["{\"ArrowAnnotate\":{\"data\":[{\"visible\":true,\"active\":false,\"handles\":{\"start\":{\"x\":450.01249999999993,\"y\":592.8031510416666,\"highlight\":true,\"active\":false},\"end\":{\"x\":283.38750000000005,\"y\":343.976484375,\"highlight\":true,\"active\":false,\"moving\":false},\"textBox\":{\"active\":false,\"hasMoved\":false,\"movesIndependently\":false,\"drawnIndependently\":true,\"allowedOutsideImage\":true,\"hasBoundingBox\":true}},\"uuid\":\"51ca68b0-734c-4046-b3da-dd2886496fd5\",\"invalidated\":true}]}}", null]'></div></div> -->
|
<!-- <div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/IMG1.dcm","test_images/IMG1.dcm"]' data-annotations='["{\"ArrowAnnotate\":{\"data\":[{\"visible\":true,\"active\":false,\"handles\":{\"start\":{\"x\":450.01249999999993,\"y\":592.8031510416666,\"highlight\":true,\"active\":false},\"end\":{\"x\":283.38750000000005,\"y\":343.976484375,\"highlight\":true,\"active\":false,\"moving\":false},\"textBox\":{\"active\":false,\"hasMoved\":false,\"movesIndependently\":false,\"drawnIndependently\":true,\"allowedOutsideImage\":true,\"hasBoundingBox\":true}},\"uuid\":\"51ca68b0-734c-4046-b3da-dd2886496fd5\",\"invalidated\":true}]}}", null]'></div></div> -->
|
||||||
<div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/IMG1.dcm", "test_images/IMG2.dcm", "test_images/IMG3.dcm", "test_images/IMG4.dcm", "test_images/IMG5.dcm", "test_images/IMG6.dcm"]' data-annotations=''></div>
|
<!-- <div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/IMG1.dcm", "test_images/IMG2.dcm", "test_images/IMG3.dcm", "test_images/IMG4.dcm", "test_images/IMG5.dcm", "test_images/IMG6.dcm"]' data-annotations=''></div> -->
|
||||||
<!-- <div id="dicom-viewer2" class="dicom-viewer" style="height: 600px;" data-images='["test_images/IMG1.dcm", "test_images/IMG2.dcm", "test_images/IMG3.dcm", "test_images/IMG4.dcm", "test_images/IMG5.dcm", "test_images/IMG6.dcm"]' data-annotations=''></div> -->
|
<!-- <div id="dicom-viewer2" class="dicom-viewer" style="height: 600px;" data-images='["test_images/IMG1.dcm", "test_images/IMG2.dcm", "test_images/IMG3.dcm", "test_images/IMG4.dcm", "test_images/IMG5.dcm", "test_images/IMG6.dcm"]' data-annotations=''></div> -->
|
||||||
<!-- <div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/CXR.dcm"]' data-annotations=''></div></div> -->
|
<!-- <div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/CXR.dcm"]' data-annotations=''></div></div> -->
|
||||||
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
<footer></footer>
|
<footer></footer>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -79,4 +79,6 @@ function loadDicomViewer(images_to_load, annotations_to_load) {
|
|||||||
dicomViewer.loadCornerstone($(single_dicom2), null, images, annotations, load_as_stack);
|
dicomViewer.loadCornerstone($(single_dicom2), null, images, annotations, load_as_stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.dicomViewer = dicomViewer;
|
||||||
Reference in New Issue
Block a user