Cornerstone first steps - loading images

1,671 views
Skip to first unread message

el...@studioinvento.it

unread,
Dec 16, 2015, 9:44:05 AM12/16/15
to cornerstone platform
Hi,

First of all thanks for the very nice work: I was looking for an Open Source dicom viewer to embed in a php web application that I am developing for a small group of surgeons, I found Cornerstone and I think it's really great!

As a first step I have downloaded the Cornerstone Demo (that should include the WADO Image Loader I guess) and I have included it in the root of my project.

I have loaded a test dicom image in a public directory:
http://www.gest-medica-new.demoinvento.it/App/Media/Dicom/paz_id_50/TestIM1.dcm

Then, following the url description found here https://github.com/chafey/cornerstoneWADOImageLoader, I have added in the mrstudy.json the block:

"seriesDescription": "Test files",
            "seriesNumber" : "9",
            "instanceList" : [
                {"imageId" : "wadouri:http://www.gest-medica-new.demoinvento.it/App/Media/Dicom/paz_id_50/TestIM1.dcm"}
            ]

In the loadStudy.js, I have modified line 73 as follows:

if (imageId.substr(0, 4) !== 'http' && imageId.substr(0, 4) !== 'wado' ) {

You can see the result here:

http://www.gest-medica-new.demoinvento.it/App/Cornerstone/

The last image that I tried to add is not loaded. Can you give some info about how I have to proceed to load the images with WADO?

Thanks in advance!

Elena

Chris Hafey

unread,
Dec 16, 2015, 10:31:07 AM12/16/15
to cornerstone platform
Check the developer tools built into your web browser, here is what I see on chrome:

GET http://cornerstonetech.org/images/ClearCanvas/wadouri:http://www.gest-medica-new.demoinvento.it/App/Media/Dicom/paz_id_50/TestIM1.dcm xhrRequest @ cornerstoneWADOImageLoader.js:3789loadImage @ cornerstoneWADOImageLoader.js:282loadImageFromImageLoader @ cornerstone.js:631loadAndCacheImage @ cornerstone.js:676(anonymous function) @ loadStudy.js:147(anonymous function) @ loadStudy.js:122j @ jquery.js:3099k.fireWith @ jquery.js:3211x @ jquery.js:8264(anonymous function) @ jquery.js:8605
www.gest-medica-new.demoinvento.it/:1 XMLHttpRequest cannot load http://cornerstonetech.org/images/ClearCanvas/wadouri:http://www.gest-medica-new.demoinvento.it/App/Media/Dicom/paz_id_50/TestIM1.dcm. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.gest-medica-new.demoinvento.it' is therefore not allowed access. The response had HTTP status code 404.
4loadStudy.js:187 

CornerstoneDemo builds the imageId's by combining the server root with what is in the study.json.  You will have to modify this logic since your test image is coming from a different server root

Chris

Elena Cenacchi

unread,
Dec 16, 2015, 11:29:32 AM12/16/15
to cornerston...@googlegroups.com
Hi Chris,

Thanks for your reply.
I can't replicate your error inspecting the page with Firefox tool (that I normally use). Firefox does not report any network error at all!

Anyhow, I have now checked also MS Edge tool, and there I see this GET error listed:

HTTP404: NOT FOUND
(XHR): GET - http://www.gest-medica-new.demoinvento.it/App/Cornerstone/lib/hammer.min.map

I have checked Chrome and there instead I can see the GET error you are referring to.

I thought the url was built inside the loadStudy.js, that I have modified accordingly. I will check better the code and let you know.

Elena


--
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/nLebuvcZxuA/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/39f36152-2cf7-4403-8364-c36664b11ca1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
**************************************
Dr. Elena Cenacchi

Studio Invento
Creative Solutions
Piazza Garibaldi 21
40059 Medicina (BO)
Italy

+39 051 850448
el...@studioinvento.it


Cenacchi Editrice snc
Editoria digitale
Via Medesano 1021
40059 Medicina (BO)
Italy

ecen...@cenacchieditrice.it

Elena Cenacchi

unread,
Dec 16, 2015, 1:09:55 PM12/16/15
to cornerston...@googlegroups.com
Hi Chris,

I have checked the code and can't find the error in the url.

In my understanding the image url is basically the imageId inside the study .js file (am I right?). I have put an alert for the imageId of my test image, if you load the url (clearing the cache before) you will see my imageId.
Note that the alert is placed after the if clause that prepend the cornerstonetech/images/... url to the imageId so I think I have already managed the logic of the url building.

I tried both the http... (current setting) and the wadouri:http...
How do I have to set the imageId to load an image from a directory?

Thanks for the help!

Elena





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

Chris Hafey

unread,
Dec 16, 2015, 1:17:16 PM12/16/15
to cornerstone platform
Here are the two locations where cornerstoneDemo creates the imageId by appending the value in the study.json to a server root:

https://github.com/chafey/cornerstoneDemo/blob/gh-pages/js/loadStudy.js#L74

Maybe you can just change the server root to your web server and remove the imageId references in your study.json to the images hosted by cornerstonetech.org
To unsubscribe from this group and all its topics, send an email to cornerstone-platform+unsub...@googlegroups.com.


-- 
**************************************
Dr. Elena Cenacchi

Studio Invento
Creative Solutions
Piazza Garibaldi 21
40059 Medicina (BO)
Italy

+39 051 850448
el...@studioinvento.it


Cenacchi Editrice snc
Editoria digitale
Via Medesano 1021
40059 Medicina (BO)
Italy

ecen...@cenacchieditrice.it

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

Elena Cenacchi

unread,
Dec 16, 2015, 1:47:00 PM12/16/15
to cornerston...@googlegroups.com
Sorry, I am certainly missing somethin here: it can't be that the part of code you refer to is executed since in both cases it's in an if clause:

if (imageId.substr(0, 4) !== 'http'  ) {
                       
                        imageId = "dicomweb://cornerstonetech.org/images/ClearCanvas/" + imageId;
                       
                    }

My imageId.substr(0,4) is equal to 'http'.

Just to be certain, I have placed in both locations an alert:
window.alert('before ' + imageId);

and obviously it is not executed, then I placed another alert just before the stack.imageIds.push(imageId); as follows:           

window.alert('after ' + imageId);
                   
And that code returns the alert with the correct imageId set as http.

Besides, by deleting the wadouri prefix in the imageId, the GET error in Chrome (not detected in Firefox and Edge) is disappeared...any other hints?

Elena




-- 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/nLebuvcZxuA/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/d6c705fd-bd09-4ba3-b796-d28699f66e82%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Chris Hafey

unread,
Dec 16, 2015, 3:28:49 PM12/16/15
to cornerstone platform
If the scheme is NOT http, then it will append the imageId to dicomweb://cornerstone...   Your imageId's in your json begin with wadouri, not http so they will be appeneded
-- 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/nLebuvcZxuA/unsubscribe. To unsubscribe from this group and all its topics, send an email to cornerstone-platform+unsub...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cornerstone-platform/d6c705fd-bd09-4ba3-b796-d28699f66e82%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Elena Cenacchi

unread,
Dec 17, 2015, 3:11:41 AM12/17/15
to cornerston...@googlegroups.com
Sorry Chris, but it seems you have not read my mails...or we are not understanding each other...
This is what I tried (please note that I don't know Cornerstone but I have a lot of experience with php/js and web programming in general).

1st trial -> imageID = wadouri:...
I HAVE CHANGED the .js file as reported in my first post (just scroll down and look at the beginning of our messages) as follows:


if (imageId.substr(0, 4) !== 'http' && imageId.substr(0, 4) !== 'wado' ) {

So the scheme WAS wadouri:http// as stated in the WADO guide that I linked in my first mail.
THIS DID NOT WORK (Firefox does not report any error but you noted that Chrome reports a GET error -> there must be something not working correctly with the wadouri: prefix ).

FROM: https://github.com/chafey/cornerstoneWADOImageLoader

"The image loader prefix is 'wadouri' (note that the prefix dicomweb is also supported but is deprecated and will eventually be removed). Here are some example imageId's:

absolute url:

wadouri:http://cornerstonetech.org/images/ClearCanvas/USEcho/IM00001
"


2nd trial -> imageID= http:// (no wadouri -> current setting)
I OBVIOUSLY don't need to change again the if clause that works exactly as the original one.

Now the scheme is http://, NOTHING IS PREPENDED to the image link.

I have added an alert as you can see by reloading my demo (clearing the cache) and the imageID after passing the loadStudy.js code is EXACTLY the same inserted in the mrstudy.json -> the direct link to the image -> YOU CAN SEE IT IN THE ALERT.


So, the question is: HOW DO I HAVE TO SET MY IMAGEID in the absolute url case, to have WADO loading my test image in the Cornerstone Demo?


Thanks

Elena



-- 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/nLebuvcZxuA/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/6a01fde6-c2a4-415d-a549-9ce9a10c3765%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Jason Hostetter

unread,
Dec 17, 2015, 1:43:47 PM12/17/15
to cornerstone platform
Hi Elena,

I have worked with this issue a little bit as well, and I believe the issue is that the imageId for your image must use either "dicomweb" or "wadouri" as the schema for the url, not a prefix for http. I.E., you should use


instead of


In the imageloader, the dicomweb: schema gets replaced by http: before the xhr request is made.

I hope this helps. I haven't read all the previous emails in depth, so apologies if you've tried this already. We're all mostly doing this in our free time after all :)

Regards,

Jason
To unsubscribe from this group and all its topics, send an email to cornerstone-platform+unsubscrib...@googlegroups.com.
-- 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/nLebuvcZxuA/unsubscribe. To unsubscribe from this group and all its topics, send an email to cornerstone-platform+unsub...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cornerstone-platform/6a01fde6-c2a4-415d-a549-9ce9a10c3765%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Chris Hafey

unread,
Dec 17, 2015, 3:54:32 PM12/17/15
to cornerstone platform
To unsubscribe from this group and all its topics, send an email to cornerstone-platform+unsubscrib...@googlegroups.com.
-- 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/nLebuvcZxuA/unsubscribe. To unsubscribe from this group and all its topics, send an email to cornerstone-platform+unsub...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cornerstone-platform/6a01fde6-c2a4-415d-a549-9ce9a10c3765%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

Chris Hafey

unread,
Dec 17, 2015, 4:02:54 PM12/17/15
to cornerstone platform
Hi Jason,

I actually removed the string replacement logic you are referring to in cornerstoneWADOImageLoader earlier this year, it now simply passes the contents of the imageId after the scheme directly to XHR when loading the image.  This was necessary to support loading images using relative URL's but still supports absolute URLs when needed.  Using relative URLs simplifies things greatly as you don't have to deal with CORS or mixing HTTP and HTTPS connections.

Chris
Reply all
Reply to author
Forward
0 new messages