I'm running into a problem with the stack prefetch tool. I'm trying to prefetch a stack of CT images and a stack of overlay images which represent radiation dose. Both stacks are jpegs and are of the same size; they are loaded with the cornerstoneWebImageLoader.
I have no problems at all when loading the CT stack alone. When I try to prefetch both stacks as below I find that that the loading stops prematurely. When I inspect the image cache in the browser, only 5 CT slices are loaded and all of the dose slices are loaded. I'm not sure why the rest of the CT slices are not loading. I have very similar loading code from a previous app which was working well and didn't have this issue, so I wonder if some of the updates have broken the way that I'm approaching prefetching. I'm currently using the master branch of cornerstoneTools.
var synchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.stackImageIndexSynchronizer);
cornerstone.loadImage(imageIds[0]).then(function(image) {
// Display this image
cornerstone.displayImage(element, image);
// Set the stack as tool state
cornerstoneTools.addStackStateManager(element, ['stack']);
cornerstoneTools.addToolState(element, 'stack', stack);
// Enable all tools we want to use with this element
cornerstoneTools.mouseInput.enable(element);
cornerstoneTools.mouseWheelInput.enable(element);
cornerstoneTools.keyboardInput.enable(element);
cornerstoneTools.stackScroll.activate(element, 1);
cornerstoneTools.stackScrollWheel.activate(element);
cornerstoneTools.stackScrollKeyboard.activate(element);
// Stack prefetching
cornerstoneTools.stackPrefetch.enable(element, 3);
synchronizer.add(element);
});
// Add stacks and prefetch overlays
// overlays is an array of overlay objects
// each object contains the following keys:
// stack, element, and name
for (var i = 0; i < overlays.length; i++) {
var ov = overlays[i];
cornerstone.loadImage(ov.stack.imageIds[0]).then(function(image) {
cornerstoneTools.addStackStateManager(ov.element, ['stack']);
cornerstoneTools.addToolState(ov.element, 'stack', ov.stack);
cornerstoneTools.stackPrefetch.enable(ov.element, 3);
synchronizer.add(ov.element);
});
}