Axial image with coronal and sagittal views

2,073 views
Skip to first unread message

Neil Panjwani

unread,
Jul 1, 2015, 3:48:11 AM7/1/15
to cornerston...@googlegroups.com
First of all, thank you for building such an amazing library. Very easy to get up and running and prototype a DICOM viewer.

I'm able to successfully load and display a stack of DICOM CT axial images with several tools, but I'm not sure how to display corresponding sagittal and coronal views. Are there any examples that exhibit this functionality? Would I have to grab the entire pixel data, transform it, and then redraw it? What's the best approach?

- Neil

Chris Hafey

unread,
Jul 1, 2015, 9:28:38 AM7/1/15
to cornerston...@googlegroups.com, pani...@gmail.com
Cornerstone does not currently have any MPR functionality so you would have to write that yourself.  Basic orthogonal MPR is pretty easy to implement, but you may run into browser stability issues with large datasets due to the lack of controls on memory management in JavaScript.  I do have a server side 3D rendering engine with MPR and Volume Rendering based on VTK that is looking for an owner/maintainer - let me know if you know anyone that might be interested (I won't open source it until I find an owner as it is still very Alpha and I don't have time to answer questions related to it!)

Chris

Stavros K

unread,
Jul 10, 2015, 5:01:15 AM7/10/15
to cornerston...@googlegroups.com
I am in the exact position as Neil. Where can i find some information on how to implement something like that?

Chris Hafey

unread,
Jul 10, 2015, 9:08:03 AM7/10/15
to cornerston...@googlegroups.com, stauro...@gmail.com
Creating sagittal and coronal views from axial slices is called Multiplanar Reconstruction (MPR).  If you google for that, you should find a ton of good information.  There are many open source projects which have implemented this to - the one I used in my server side renderer is VTK:


VTK has a ton of functionality and written in C++ so it might be hard to isolate and extract the MPR code. I seem to recall a HTML5/JS based MPR viewer but I forgot its name and can't seem to find it on google, maybe someone on here will remember.

If you really just need basic MPR, you can easily extract sagittal and coronal views if you think of the data set as a 3D array of pixels (X x Y x Z) with X = axial image width, Y = axial image height and Z = number of axial images:
Axial Views = X x Y
Sagittal Views = Y x Z
Coronal Views = X x Z

Σταύρος Καμπανάκης

unread,
Jul 13, 2015, 2:04:39 AM7/13/15
to Chris Hafey, cornerston...@googlegroups.com
I was thinking for a client based tranformation. I found a viewer that does it. Did you meant this one: https://github.com/rii-mango/Papaya/ . I will take your advice and the viewer above and see what i can do. Thanks for your time.

--
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/aMeL1ATh70U/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/d2bd5280-5887-4006-9cf5-092b89014f53%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nick Hermans

unread,
Jul 13, 2015, 4:04:16 AM7/13/15
to cornerston...@googlegroups.com
An example of MPR in javascript can be found in the xtk liberary github: https://github.com/xtk/X

demo page:

there is another project that uses MPR with pure javascript, no webGL involved, can't find it right now.

Nick Hermans

unread,
Jul 13, 2015, 4:12:30 AM7/13/15
to cornerston...@googlegroups.com
The Javascript example can be found here:



On Wednesday, July 1, 2015 at 9:48:11 AM UTC+2, Neil Panjwani wrote:

Chris Hafey

unread,
Jul 13, 2015, 8:28:48 AM7/13/15
to cornerston...@googlegroups.com, stauro...@gmail.com, cha...@gmail.com
Yes either papaya or xtk.  papaya appears to be focused on MPR only so it would be a good starting place if that is all you want.  XTK has way more functionality than papaya so go there if you think your needs will evolve (e.g. slabs, obliques, volume rendering, etc).  It would be really cool if someone could do an integration between XTK and cornerstone

Chris

Stavros K

unread,
Aug 6, 2015, 5:17:52 AM8/6/15
to cornerstone platform, stauro...@gmail.com
So i am trying to follow your advice about sagittal and coronal views. I have figured out how to put in an array the correct pixel values for each view by using the getStoredPixels api. First of all when i iterate through a lot of dcm files it crashes chrome. I guess this is because getStoredPixels returns storedpixels which is just an array. So my real question is in what type of array should i transform it so it is much lighter with RAM and so i can feed it back to the view? Should it be uint8array and how will i transform it?  

Σταύρος Καμπανάκης

unread,
Aug 6, 2015, 8:29:12 AM8/6/15
to cornerstone platform, Σταύρος Καμπανάκης
The getStoredPIxels api works perfect. I had a memory leak, i fixed it and everything is ok. But my question still stands. Now that i have an array of all the pixel of, for example the saggital view, how should i advance so i can project them. Does it needs to be transformed into an ArrayBuffer and then into an Uint8array?

Chris Hafey

unread,
Aug 6, 2015, 8:57:06 AM8/6/15
to cornerstone platform, stauro...@gmail.com

Σταύρος Καμπανάκης

unread,
Aug 12, 2015, 8:53:20 AM8/12/15
to Chris Hafey, cornerstone platform
It seems that i ended up in a dead end. I have 512 dicoms of combined 265MB with width 512 and height 505 pixels. When i try to store every array of pixels(that comes through getStoredPixels) in my own array so i can later iterate this array and extract the pixels for saggital and coronal, Chrome justs crashes. The RAM gets full (4GB of RAM). I append it everytime with index or .push(). It's the same thing everytime. 
Do you think that this is because of the big array and this is normal because of the volume of images that i try to process or do i have a memory leak from my array. It's the first time that i have to deal with images and pixels so i really don't know what to look at. Thanks for your help and i am sorry for asking that many questions.

Leonardo M. Ramé

unread,
Aug 12, 2015, 9:22:34 AM8/12/15
to cornerstone platform, cha...@gmail.com
This should be processed server side.

I don't know if dicomParser can work with NodeJs, if yes, you can create an http request handler and return each frame separately.

Chris Hafey

unread,
Aug 12, 2015, 9:57:18 AM8/12/15
to cornerstone platform, cha...@gmail.com
Hi Stavros,

If your data set is 256MB and your browser is taking up 4GB, you either have a memory leak or not re-using buffers and using memory faster than the GC can keep up.  Can you share your code so we can help look for issues and help?  You should also be using a 64 bit OS and 64 bit browser as a 32 bit OS/browser will limit you to 2GB which isn't that much (chrome in particular uses a ton of memory to begin with)

Chris

Chris Hafey

unread,
Aug 12, 2015, 9:58:18 AM8/12/15
to cornerstone platform, cha...@gmail.com
dicomParser works great on the server side in node.js!  It doesn't support (yet) but this is something that will be added down the road in v2.

Chris

Σταύρος Καμπανάκης

unread,
Aug 12, 2015, 11:39:51 AM8/12/15
to Chris Hafey, cornerstone platform
The goal is to be implemented in client side (if it's possible!) but thanks for the suggestion Leonardo. I use a 64bit linux distro with 64bit Google Chrome for the development. My laptop it uses in idle about 1GB of 3,8 available so when i run it and it peaks at about 85% it crashes. About my code

file cornerstoneFileImageLoader.js

function LoadImage(imageid)
....
....
imagePromise.then(function(image) {
                imgHeight = image.height;
                imgWidth = image.width;
                deferred.resolve(image);
            }, function() {
                deferred.reject();
            });
//my own function
            parsePixel(imageId);

Everytime the LoadImage runs the function parsePixel runs

var parsePixelCounter = 0;
var allPixels = []; //global outside of any function maybe the garbage collection does not catch it.
function parsePixel(imageId){
    var numpixels = imgWidth * imgHeight;

// It takes the dicom number out of the string
    if (imageId.length > 13) {
        var dcmId = imageId.slice(12, imageId.length).toString();
        parsePixelCounter += 1 ;
    } else {
        var dcmId = imageId.slice(-1);
        parsePixelCounter += 1;
    }
    allPixels[allPixels.length] = cornerstone.getStoredPixels(globalElement, 0, 0, imgWidth, imgHeight);
//globalElement is a global variable from the html
if (numb_of_dcm === parsePixelCounter){

....
....
Then starts the pixel iteration but the problem is in the allPixels array.

--
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/aMeL1ATh70U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cornerstone-plat...@googlegroups.com.

Chris Hafey

unread,
Aug 12, 2015, 12:18:43 PM8/12/15
to cornerstone platform, cha...@gmail.com
Any chance you can put this code on github?  You may want to reduce cornerstone's cache size or use loadImage() instead of loadAndCacheImage() to keep memory use down
To unsubscribe from this group and all its topics, send an email to cornerstone-platform+unsub...@googlegroups.com.

richmond xavier gnanhi

unread,
Oct 26, 2017, 9:06:33 PM10/26/17
to cornerstone platform
I am interested in your new project based on vtk, how much could it cost? In box please 
Reply all
Reply to author
Forward
0 new messages