wwwc with many images (or the stack problem)

167 views
Skip to first unread message

Carlo Perassi

unread,
Sep 22, 2015, 12:01:29 PM9/22/15
to cornerstone platform
Hi,
cornerstone comes with a lot of good examples and I like it. :)

Using
as a model, I'm writing a four image page. When the four wwwc are not synced and the four images are not the same one, it's fine. When they are synced and the four images are not the same one, wwwc is very slow.
I'm not sure about the reason of this behaviour. I suppose I didn't write a correct "stack" or the like. I understand that stack is a way to manage array of images  but I didn't understand it very well (I know there is CornerDemo but it is a large example to study). Do you have a small stack example? All the examples of cornerstone (except the large "demo") are for a fixed number of images... the code is AFAIK always a cut/paste/change of the form something(element_number, function) but when I try to compact the example in an array (for example, the 3 images example of

for example, repeating the following block for four images is fine (data comes from ajax, for example)

cornerstone.loadImage(dicomPrefix + data[0]).then(function (image) {
  cornerstone
.displayImage(dcms[0], image);
  _myPrivateSetup
(dcmsDom[0], dcms[0]);
});


/* the same block repeated for [1], [2] etc... */

but when I try to put the four block in a trivial foreach like

for (var i = 0; i < data.length; i++) {
  cornerstone
.loadImage(dicomPrefix + data[i]).then(function (image) {
    cornerstone
.displayImage(dcms[i], image);
    toolsSetup
(dcmsDom[i], dcms[i]);
 
});
}


it stops with

Uncaught displayImage: parameter element cannot be undefined

Thanks.

Erik Ziegler

unread,
Sep 22, 2015, 2:09:50 PM9/22/15
to cornerstone platform
Great! Glad to hear you could learn from the examples.

Yes windowing multiple images at the same time can be slow because Cornerstone is currently drawing with HTML5 Canvas. WebGL support is nearly complete though so this should not be a problem for much longer. For now there's not much you can do about that though, sorry. Feel free to checkout the "webgl" branch on cornerstone core (https://github.com/chafey/cornerstone/tree/webgl) and follow the example at example/webgl/index.html to see how you can use Cornerstone with WebGL. There are still some bugs, though.

For the second point, try placing a breakpoint at the displayImage call and checking the value of dcms. It seems that whatever is in dcms[i] is undefined. I wonder if this is because it is executed asynchronously? The error you are getting is quite literal: whatever value you are passing for 'element' is undefined at the time displayImage is called. The exact line is here: https://github.com/chafey/cornerstone/blob/master/src/displayImage.js#L14

Hope that helps,

Erik

Carlo Perassi

unread,
Sep 23, 2015, 3:17:50 AM9/23/15
to cornerstone platform
Thanks Erik
a) I've found an acceptable (and, for the moment, accepted) user experience workaround so I don't have to try the webgl branch
b) I've already used a breakpoint but it was a sly bug now fixed. :)

Neil Panjwani

unread,
Sep 29, 2015, 2:47:53 PM9/29/15
to cornerstone platform
May I ask what your workaround was? I'm also running into a big slowdown when adjusting ww/wc with synced stacks of images.

Carlo Perassi

unread,
Sep 29, 2015, 2:51:17 PM9/29/15
to Neil Panjwani, cornerstone platform
after having tried, I can say that the workaround doesn't work :)
the idea was to use wwwc on a single image then manually spread its
ww/wc to the other images but it is slow too so they are all
independent ATM
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "cornerstone platform" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cornerstone-platform/F0r98qyDFdo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cornerstone-plat...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cornerstone-platform/fda29110-1b61-403e-b6b9-dd0372cc8f4e%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Carlo Perassi - http://perassi.me/

Chris Hafey

unread,
Sep 29, 2015, 5:54:35 PM9/29/15
to cornerstone platform, pani...@gmail.com
CornerstoneCore is currently not optimized for updating multiple enabled elements simultaneously, here are the related backlog entries:
  • Consider having multiple renderCanvas or one per enabled element
  • Sharing of LUT's between multiple viewports for linked ww/wc use case
The webgl renderer is pretty fast and may solve the issue (if you can use it).  If anyone wants to try and tackle these features, I am more than happy to point you in the right direction!
Reply all
Reply to author
Forward
0 new messages