enable image annotations
This commit is contained in:
+1
-1
@@ -180,7 +180,7 @@
|
|||||||
<script src="lib/cornerstone.js"></script>
|
<script src="lib/cornerstone.js"></script>
|
||||||
<script src="lib/dicomParser.min.js"></script>
|
<script src="lib/dicomParser.min.js"></script>
|
||||||
<script src="lib/cornerstoneMath.min.js"></script>
|
<script src="lib/cornerstoneMath.min.js"></script>
|
||||||
<script src="lib/cornerstoneTools.js"></script>
|
<script src="lib/cornerstoneTools.min.js"></script>
|
||||||
<script src="lib/cornerstoneWebImageLoader.min.js"></script>
|
<script src="lib/cornerstoneWebImageLoader.min.js"></script>
|
||||||
<script src="lib/cornerstoneWADOImageLoader.js"></script>
|
<script src="lib/cornerstoneWADOImageLoader.js"></script>
|
||||||
<script src="lib/cornerstone-base64-image-loader.umd.js"></script>
|
<script src="lib/cornerstone-base64-image-loader.umd.js"></script>
|
||||||
|
|||||||
+30
-2
@@ -508,14 +508,30 @@ export function openMainImage(current_question, t, source) {
|
|||||||
* Load image
|
* Load image
|
||||||
* @param {*} images - list of images
|
* @param {*} images - list of images
|
||||||
*/
|
*/
|
||||||
async function load(images) {
|
function loadAnnotation(imageId, annotation) {
|
||||||
|
const toolStateManager = cornerstoneTools.globalImageIdSpecificToolStateManager;
|
||||||
|
|
||||||
|
if (annotation.length < 1) { return }
|
||||||
|
|
||||||
|
let tool_state_no_id = JSON.parse(annotation);
|
||||||
|
|
||||||
|
let tool_state = {};
|
||||||
|
tool_state[imageId] = tool_state_no_id;
|
||||||
|
|
||||||
|
toolStateManager.restoreToolState(tool_state);
|
||||||
|
}
|
||||||
|
async function load(images, annotations) {
|
||||||
const imageIds = [];
|
const imageIds = [];
|
||||||
for (let i = 0; i < images.length; i++) {
|
for (let i = 0; i < images.length; i++) {
|
||||||
const data_url = images[i];
|
const data_url = images[i];
|
||||||
|
const annotation = annotations[i];
|
||||||
|
|
||||||
// check stack type
|
// check stack type
|
||||||
if (data_url.startsWith("data:image")) {
|
if (data_url.startsWith("data:image")) {
|
||||||
const imageId = "base64://" + data_url.split(",")[1];
|
const imageId = "base64://" + data_url.split(",")[1];
|
||||||
|
|
||||||
|
loadAnnotation(imageId, annotation);
|
||||||
|
|
||||||
imageIds.push(imageId);
|
imageIds.push(imageId);
|
||||||
} else if (data_url.startsWith("data:application/dicom")) {
|
} else if (data_url.startsWith("data:application/dicom")) {
|
||||||
// stack = stack.split(";")[1];
|
// stack = stack.split(";")[1];
|
||||||
@@ -525,6 +541,9 @@ export function openMainImage(current_question, t, source) {
|
|||||||
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
|
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
|
||||||
dfile
|
dfile
|
||||||
);
|
);
|
||||||
|
|
||||||
|
loadAnnotation(imageId, annotation);
|
||||||
|
|
||||||
imageIds.push(imageId);
|
imageIds.push(imageId);
|
||||||
// cornerstone.loadImage(imageId).then(function(image) {
|
// cornerstone.loadImage(imageId).then(function(image) {
|
||||||
// tempFunction(image);
|
// tempFunction(image);
|
||||||
@@ -574,12 +593,21 @@ export function openMainImage(current_question, t, source) {
|
|||||||
let images = current_question.images[figure_to_load.split("-")[1]];
|
let images = current_question.images[figure_to_load.split("-")[1]];
|
||||||
// images = current_question.images
|
// images = current_question.images
|
||||||
|
|
||||||
|
|
||||||
// Make sure we have an array
|
// Make sure we have an array
|
||||||
if (!Array.isArray(images)) {
|
if (!Array.isArray(images)) {
|
||||||
images = [images];
|
images = [images];
|
||||||
}
|
}
|
||||||
|
|
||||||
load(images);
|
let annotations = [];
|
||||||
|
if (current_question.annotations) {
|
||||||
|
annotations = current_question.annotations[figure_to_load.split("-")[1]];
|
||||||
|
if (!Array.isArray(annotations)) {
|
||||||
|
annotations = [annotations];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
load(images, annotations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user