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