Refactor setUpDicomLegacy and loadJsonToolStateOnCurrentImage functions for improved annotation handling
This commit is contained in:
@@ -318,8 +318,8 @@ function prepAnswerData() {
|
||||
$("#id_marked_answers").val(JSON.stringify(window.marked_answers));
|
||||
}
|
||||
|
||||
function loadJsonToolStateOnCurrentImage(json) {
|
||||
let el = document.getElementById("dicom-image");
|
||||
function loadJsonToolStateOnCurrentImage(element, json) {
|
||||
let el = element;
|
||||
|
||||
const toolStateManager = cornerstoneTools.globalImageIdSpecificToolStateManager;
|
||||
|
||||
@@ -370,7 +370,7 @@ async function setUpDicomLegacy(element) {
|
||||
|
||||
const images = element.dataset.url.split(",");
|
||||
|
||||
const annotations = element.dataset.annotations.split(",");
|
||||
const annotation = element.dataset.annotations;
|
||||
|
||||
//console.log("Dicom - load imageId: ", imageIds);
|
||||
//for (let index = 0; index < imageIds.length; index++) {
|
||||
@@ -382,16 +382,12 @@ async function setUpDicomLegacy(element) {
|
||||
let imageIds = [];
|
||||
for (let i = 0; i < images.length; i++) {
|
||||
let data_url = images[i];
|
||||
|
||||
let annotation = annotations[i];
|
||||
// check stack type
|
||||
if (data_url.startsWith("data:image")) {
|
||||
let imageId = "base64://" + data_url.split(",")[1];
|
||||
loadAnnotation(imageId, annotation);
|
||||
|
||||
imageIds.push(imageId);
|
||||
} else if (data_url.startsWith("base64://") || data_url.startsWith("wadouri:")) {
|
||||
loadAnnotation(data_url, annotation);
|
||||
|
||||
imageIds.push(data_url);
|
||||
|
||||
@@ -430,7 +426,6 @@ async function setUpDicomLegacy(element) {
|
||||
url = "wadouri:" + url;
|
||||
}
|
||||
|
||||
loadAnnotation(url, annotation);
|
||||
imageIds.push(url);
|
||||
|
||||
|
||||
@@ -487,7 +482,7 @@ async function setUpDicomLegacy(element) {
|
||||
}
|
||||
|
||||
if (element.dataset.annotations) {
|
||||
loadJsonToolStateOnCurrentImage(element.dataset.annotations)
|
||||
loadJsonToolStateOnCurrentImage(element, element.dataset.annotations)
|
||||
}
|
||||
|
||||
cornerstone.resize(element);
|
||||
|
||||
Reference in New Issue
Block a user