From 6f96f79303c8e0c47ea181eabbd190e513c0fd94 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 7 Oct 2024 09:20:09 +0100 Subject: [PATCH] fix some more loading errors --- anatomy/static/js/dicomViewer.js | 4 ++++ atlas/templates/atlas/series_viewer.html | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/anatomy/static/js/dicomViewer.js b/anatomy/static/js/dicomViewer.js index 95460979..fddcffb2 100644 --- a/anatomy/static/js/dicomViewer.js +++ b/anatomy/static/js/dicomViewer.js @@ -1084,6 +1084,10 @@ function onNewImage(e) { } function checkAnonStatus(dataSet) { + // dataSet will be undefined if the image is not a dicom + if (dataSet == undefined) { + return; + } let accession_number = dataSet.string('x00080050').toLowerCase(); let patient_id = dataSet.string('x00100020').toLowerCase(); diff --git a/atlas/templates/atlas/series_viewer.html b/atlas/templates/atlas/series_viewer.html index d42721f6..0317ed89 100755 --- a/atlas/templates/atlas/series_viewer.html +++ b/atlas/templates/atlas/series_viewer.html @@ -288,8 +288,13 @@ console.log("loading stack index") dicomViewer.loadStackIndex(current_image_id_index, dicom_element); } else { - console.log("loading next annotation image") - dicomViewer.getNextAnnotationImage(dicom_element); + try { + dicomViewer.loadImageById(current_image_id_index, dicom_element); + } catch (e) { + console.log("loading image by id failed") + console.log("loading next annotation image") + dicomViewer.getNextAnnotationImage(dicom_element); + } } } @@ -307,7 +312,10 @@ description: $('#id_description').val(), series: {{ series.pk }}, //annotation_json: JSON.stringify(c.toolStateManager.saveToolState()), - current_image_id_index: c.toolStateManager.toolState.stack.data[0].currentImageIdIndex, + // This is the stack number + //current_image_id_index: c.toolStateManager.toolState.stack.data[0].currentImageIdIndex, + // but we want to use the current image id (so if the stack is reordered it still attaches to the correct image) + current_image_id_index: c.toolStateManager.toolState.stack.data[0].imageIds[c.toolStateManager.toolState.stack.data[0].currentImageIdIndex], annotation_json: JSON.stringify(cornerstoneTools.globalImageIdSpecificToolStateManager .saveToolState()), viewport_json: JSON.stringify(c.viewport),