load images and annotations from json arrays

This commit is contained in:
Ross
2021-08-20 09:12:24 +01:00
parent 6f2af7df21
commit 11c06cd538
3 changed files with 10 additions and 10 deletions
-4
View File
@@ -664,7 +664,3 @@ function urltoFile(url, filename, mimeType) {
return new File([buf], filename, { type: mimeType }); return new File([buf], filename, { type: mimeType });
}); });
} }
function saveAnnotations() {
}
+1 -1
View File
@@ -24,7 +24,7 @@
<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/IMG1.dcm,test_images/IMG2.dcm" data-annotations=''></div> <div id="dicom-viewer" class="dicom-viewer" style="height: 600px;" data-images='["test_images/IMG1.dcm","test_images/IMG1.dcm"]'></div>
</main> </main>
<footer></footer> <footer></footer>
+9 -5
View File
@@ -6,7 +6,7 @@ $(document).ready(function () {
loadDicomViewer(); loadDicomViewer();
}); });
function loadDicomViewer(images_to_load) { function loadDicomViewer(images_to_load, annotations_to_load) {
console.log("loadDicomViewer", images_to_load); console.log("loadDicomViewer", images_to_load);
let single_dicom = document.getElementById("dicom-viewer"); let single_dicom = document.getElementById("dicom-viewer");
if (single_dicom) { if (single_dicom) {
@@ -15,17 +15,21 @@ function loadDicomViewer(images_to_load) {
if (images_to_load != undefined) { if (images_to_load != undefined) {
images = images_to_load; images = images_to_load;
console.log("i1", images)
} else if (images.indexOf(",") > 0) { } else if (images.indexOf(",") > 0) {
images = images.split(","); images = JSON.parse(images);
} }
console.log(images); console.log(images);
let annotations = single_dicom.dataset.annotations; let annotations = single_dicom.dataset.annotations;
if (annotations != undefined && annotations.indexOf(",") > 0) { if (annotations != undefined) {
annotations = annotations; annotations = annotations_to_load;
} else if (annotations && annotations.indexOf(",") > 0) {
annotations = JSON.parse(annotations);
} else {
annotations = undefined;
} }
let load_as_stack; let load_as_stack;
if (images.length > 5) { if (images.length > 5) {
load_as_stack = true; load_as_stack = true;