improve webpage atlas uploads

This commit is contained in:
Ross
2024-04-29 10:42:41 +01:00
parent fa613ae116
commit 490d1956af
2 changed files with 68 additions and 41 deletions
+66 -40
View File
@@ -17,6 +17,14 @@
<p>Only valid dicom files will be uploaded. </p>
<p>It is possible to upload multiple files by selecting the parent (containing) folder. Folders within will then be searched recursively for any valid dicom files.</p>
<p>Files to be uploaded will be displayed below. </p>
<p>DICOM tags will be checked to see if valid accession or hospital numbers are present but no annonymisation will be performed.</p>
<p>By default a basic OCR will also be performed to check for burned in details on images, the is resource intensive and can be disabled if you know the content you are uploading does not feature any patient details.</p>
</details>
<details>
<summary>Settings</summary>
<input type="checkbox" id="check-annonymisation-ocr" checked><label for="check-annonymisation-ocr">Check for annonymisation (OCR)</label>
<input type="checkbox" id="show-thumbnails"><label for="Show thumbnails">Show thumbnails</label>
<input type="checkbox" id="show-viewer"><label for="Show Viewer">Show viewer</label>
</details>
</div>
@@ -251,6 +259,7 @@
}
}
async function loadDicomViewerTest(callback) {
$("#single-dicom-viewer").hide();
console.log("load")
$("#single-dicom-viewer").empty()
//images = []
@@ -328,25 +337,39 @@
let url = URL.createObjectURL(file)
console.log(url)
imageId = `wadouri:${url}`;
images.push(imageId);
if ($("#show-viewer").is(":checked")) {
images.push(imageId);
}
window.to_upload.push(file);
const element = $(`<div class='temp-thumb' src=${imageId}></div>`).get(0)
item.appendChild(element);
cornerstone.enable(element);
cornerstone.loadAndCacheImage(imageId).then(function (image) {
cornerstone.displayImage(element, image);
if (!$("#check-annonymisation-ocr").is(":checked") && !$("#show-thumbnails").is(":checked")) {
$(element).addClass("temp-thumb-large");
cornerstone.resize(element)
setTimeout(function () {
ocr($(element).find("canvas").get(0).toDataURL(), element);
$(element).removeClass("temp-thumb-large");
cornerstone.resize(element)
}, 500);
} else {
const element = $(`<div class='temp-thumb' src=${imageId}></div>`).get(0)
item.appendChild(element);
cornerstone.enable(element);
cornerstone.loadAndCacheImage(imageId).then(function (image) {
cornerstone.displayImage(element, image);
if ($("#check-annonymisation-ocr").is(":checked")) {
$(element).addClass("temp-thumb-large");
cornerstone.resize(element)
setTimeout(function () {
ocr($(element).find("canvas").get(0).toDataURL(), element);
$(element).removeClass("temp-thumb-large");
cornerstone.resize(element)
});
if (!$("#show-thumbnails").is(":checked")) {
cornerstone.disable(element);
element.remove();
}
}, 500);
}
});
}
}
}
@@ -358,7 +381,10 @@
});
$("#loading").hide()
window.dispatchEvent(event);
if ($("#show-viewer").is(":checked")) {
window.dispatchEvent(event);
$("#single-dicom-viewer").show();
}
@@ -379,32 +405,32 @@
uploading_el.removeClass("image-ident-loading");
console.log("found text", l);
if (l.includes("accession") || l.includes("number") || l.search(
/(ref|rk9|rh8|ra9|rbz)\d+/g) > -1) {
console.log("Match found ", input);
$(input).addClass("image-ident-warning");
uploading_el.addClass("image-ident-warning");
$("uploadButton").prop("disabled", true);
toastr.warning(`File does not appear to be annonymised<br/>Image data burned in<br/>${element}`, 'Anonymisation warning', {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-full-width",
"preventDuplicates": false,
"onclick": null,
"showDuration": "0",
"hideDuration": "0",
"timeOut": 0,
"extendedTimeOut": 0,
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut",
});
} else {
$(input).addClass("image-ident-ok");
/(ref|rk9|rh8|ra9|rbz)\d+/g) > -1) {
console.log("Match found ", input);
$(input).addClass("image-ident-warning");
uploading_el.addClass("image-ident-warning");
$("uploadButton").prop("disabled", true);
toastr.warning(`File does not appear to be annonymised<br/>Image data burned in<br/>${element}`, 'Anonymisation warning', {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-full-width",
"preventDuplicates": false,
"onclick": null,
"showDuration": "0",
"hideDuration": "0",
"timeOut": 0,
"extendedTimeOut": 0,
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut",
});
} else {
$(input).addClass("image-ident-ok");
}
}
})
}
+2 -1
View File
@@ -54,7 +54,8 @@
<script src="{% static 'js/tex-mml-chtml.js' %}"></script>
<script src="{% static 'js/dexie.js' %}"></script>
<script src="{% static 'js/html5sortable.min.js' %}"></script>
<script src="{% static 'tesseract.min.js' %}"></script>
{% comment %} <script src="{% static 'tesseract.min.js' %}"></script> {% endcomment %}
<script src='https://cdn.jsdelivr.net/npm/tesseract.js@5/dist/tesseract.min.js'></script>
<script src="{% static 'js/toastr.min.js' %}"></script>
<script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
<script src="{% static 'js/sorttable.js' %}"></script>