Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Tool: DICOM Overlays (C.9 Overlays) #780

Closed
kofifus opened this issue May 18, 2018 · 33 comments
Closed

New Tool: DICOM Overlays (C.9 Overlays) #780

kofifus opened this issue May 18, 2018 · 33 comments
Assignees

Comments

@kofifus
Copy link
Contributor

kofifus commented May 18, 2018

Hi,

Does cornerstone supports displaying DICOM overlays ? (C.9 Overlays - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html)

It doesn't show in my tests.

Thank you!

@kofifus
Copy link
Contributor Author

kofifus commented May 29, 2018

bump

@swederik
Copy link
Member

It doesn't display them automatically, no. You can extract them from the DICOM object with dicomParser (or from .data after loading via the WADO Image Loader) and then create a Layer to display them on top of the image.

I'd be happy to have a tool or example to do this, if you get it working!

@kofifus
Copy link
Contributor Author

kofifus commented May 29, 2018

Thanks swederik !

Any more information on how to "create a Layer to display them on top of the image" ?

@khadakeb
Copy link

To display DICOM overlays, you can refer example provided at:
https://github.com/cornerstonejs/cornerstone/tree/master/example/layers
To check above example in action:
https://rawgit.com/cornerstonejs/cornerstone/master/example/layers/index.html

@jamesg1
Copy link

jamesg1 commented Nov 7, 2018

I've been interested in trying out cornerstone more for displaying one or more layers on top of images from the dicom web loader. Is it possible to have these overlay layer(s) constructed on the fly per index of the series (say from pixel/shape manipulation of another image) and shown as you scroll through the series? I would want to keep the overlay layers in sync with the base image (viewport). The examples I've seen so far have a specific overlay layer created first.

@jdnarvaez
Copy link
Contributor

What I ended up doing is modifying my image loader to include the parsed dataset in the image object along with the pixel data, then added a render listener so that when the image is rendered I can extract the overlay data and render it on top.

@kofifus
Copy link
Contributor Author

kofifus commented Jan 30, 2019

jdnarvaez - can you provide a sample please ? I am really trying to make progresss with this .. thx!

@jdnarvaez
Copy link
Contributor

jdnarvaez commented Jan 30, 2019

@kofifus this should get you started: https://gist.github.com/jdnarvaez/3368ac3e4f7f4eb14bc5f453f8a1ed1b

the imageRendered method is what would be called from an image_rendered listener added to the element

also I store the parsed data set on the image as $presentationStateDataSet so that it can be referenced and the data extracted

@dannyrb
Copy link
Member

dannyrb commented Jan 30, 2019

Thanks for the code, @jdnarvaez 👍
I think this is a good 3rd party tool candidate, or something you'd be more likely to see in an imageLoader, but probably isn't a good candidate for core.

I'm going to "transfer" this issue to tools.

@dannyrb dannyrb transferred this issue from cornerstonejs/cornerstone Jan 30, 2019
@kofifus
Copy link
Contributor Author

kofifus commented Jan 30, 2019

Thanks for the code, @jdnarvaez 👍 👍 very helpful

@dannyrb, IMO this is very core - DICOM overlays are not an added tool but an integral part of the image and cornerstone should be able to show them (ideally with toggle/opacity) even without the tools package ...

@dannyrb
Copy link
Member

dannyrb commented Jan 30, 2019

@kofifus, you may be right. I don't have the qualifications to determine that one way or another. From my perspective, the tech side, we do most of our tag parsing and usage in loaders/tools. I don't think core ever uses get on a metaDataProvider.

Are DICOM overlays "rendering", or do they impact rendering? Is there a consistent visual result we expect if DICOM overlays are implemented?

@swederik, care to weigh in?

@kofifus
Copy link
Contributor Author

kofifus commented Jan 30, 2019

The overlays are described by the dicom standard here - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html

"An Overlay Plane describes graphics or bit-mapped text that is associated with an Image. It may also describe a Region of Interest in an Image.
Each Overlay Plane is one bit deep. Sixteen separate Overlay Planes may be associated with an Image."

"How an Overlay Plane is rendered is undefined; specifically there is no mechanism to specify with what color or intensity an Overlay Plane is to be displayed, except when rendered under the control of a Softcopy Presentation State SOP Instance."

Usually you want to:

  • toggle a particular layer on or off
  • determine the opacity of the layer
  • color them (less commonly useful I think)

So I think that core should have functions like - ToggleOverlay(index), SetOverlayOpacity(index), setOverlayColor(index)

Then a Tool can be made to use those functions in some graphical way, as there is usually only one layer there can maybe be a single toggle tick and opacity slider etc ...

(The standard also specify ROI overlays which are a bit of a different story ...)

But if its not desirable for core to read tags then maybe it does not belong in core - not sure ..

@kofifus
Copy link
Contributor Author

kofifus commented Jan 31, 2019

Ok I came up with something

See PRs - cornerstonejs/cornerstoneWADOImageLoader#239
and - cornerstonejs/cornerstone#347

Basically wadouri metaDataProvider now accepts the type 'overlays' and reads and returns an array of overlays if existing in the dataset

then in core drawImageSync, if the image has overlays they are added to the canvas.

Each overlay has a 'fillStyle' and 'hidden' properties that can be changed to toggle overlays or color them.

I have tested with single overlays, I don't have images containing multiple overlays or ROI. Perhaps someone can donate some examples.

Much of the code is a rewrite of @jdnarvaez solution above thanks!

Let me know what you think ..

@dannyrb
Copy link
Member

dannyrb commented Jan 31, 2019

@kofifus, thanks for taking the time to PR these concepts! I think the cornerstoneWADOImageLoader enhancement makes sense, and is implemented well. It does make me wonder if we should pull out the metaDataProvider into it's own repository, but that's just a side thought.

If you have any helpful, anonymized, images to test this functionality with, could you pass them along? I'm curious to see what these overlays are used for in practice. I'm also curious how a viewer like Radiant or Osirix handles overlays.

I'm less sure about the cornerstone-core changes. I value your time, and was curious of the answer myself, so I reached out to @swederik and a few others outside of GitHub. The consensus seems to be that the rendering logic for overlays should live in a tool.

If we don't expose granular enough APIs to accomplish this, or if you need assistance creating a 3rd Party Tool, I would be more than happy to help. If you disagree, and it's okay if you do, we can continue to discuss.

@jdnarvaez
Copy link
Contributor

@kofifus I have updated the gist with the tag file. as far as examples, I suggest using the IHE test case for overlays.

@jdnarvaez
Copy link
Contributor

ovly_p01.zip

@jdnarvaez
Copy link
Contributor

FWIW, that contains both the dicom file and the presentation state, as some overlays are read from the PR and one layer of the overlays is read from the embedded pixel data.

@kofifus
Copy link
Contributor Author

kofifus commented Jan 31, 2019

sure @dannyrb

Can you point out an existing tool that this is similar to and I can use as a skeleton ? I may give it a go ..
If the maintainers think a tool is better then we should try that but its more involved so I need more assistance or maybe someone else can take it from here ?

On a side note, regarding your metadata repository comment, personally I don't like the multiple repositories trend, I feel Javascript offers more than enough mechanisms for encapsulation (ie modules) as is and multiple repositories just create an unnecessary overhead.

Also, we should probably look at adding an equivalent to the new wadouri processing of type 'overlayPlaneModule' to imageLoader\wadors\metaData\metaDataProvider.js, I am not sure what is the purpose of wadors and how to do that, maybe someone else can chip in ...

@jdnarvaez - in https://gist.github.com/jdnarvaez/3368ac3e4f7f4eb14bc5f453f8a1ed1b#file-overlays-js-L7

I don't follow that for loop .. the way I read the standard there can be up to 16 layers in even Group Numbers 6000-601E (not ee) ?

@kofifus
Copy link
Contributor Author

kofifus commented Feb 4, 2019

I removed the cornerstone PR (cornerstonejs/cornerstone#347)

and created an overlays tool - #788

The tool is very simple having only enable and disable

Hope this helps :)

@dannyrb dannyrb added Change: Feature 💻 Change that expands the API Version 3 📦 and removed 3rd Party Tool labels Feb 6, 2019
@dannyrb dannyrb changed the title DICOM overlays New Tool: DICOM Overlays (C.9 Overlays) Feb 6, 2019
@dannyrb
Copy link
Member

dannyrb commented Feb 8, 2019

I've created a feature branch for us to iterate on the cornerstone-tools portion of this tool:

  • feature/overlay-tool

When new code is merged, a release is cut and tagged on NPM for @cornerstonejs/tools@feature-overlay-tool

I have a CodeSandbox up that is using the cornerstoneWADOImageLoader and cornerstoneTools branches that pertain to this feature:

https://codesandbox.io/s/1qj7j8op0l

@dannyrb
Copy link
Member

dannyrb commented Feb 11, 2019

@kofifus, here's an update:

  • The image loader now stores the information in overlayPlaneModule
  • The tool retrieves the data from the overlayPlaneModule and finds 2 overlays in our test DICOM
  • When disabled, the image shows 2-lines of text. When enabled, the image shows no new lines of text

Here is what I am able to see in a desktop viewer:

image

I haven't found a viewer yet that shows all 6-lines, but I only have a few installed locally.

@kofifus
Copy link
Contributor Author

kofifus commented Feb 11, 2019

Can you send me a link to download the dicom image pls ?

@dannyrb
Copy link
Member

dannyrb commented Feb 11, 2019

It's a bit higher up in this thread. JD shared it: #780 (comment)

@dannyrb
Copy link
Member

dannyrb commented Feb 11, 2019

Updated Sandbox: https://codesandbox.io/s/1qj7j8op0l

This is the PR that fixed things up: #826

image

If I do a DICOM dump of the file, using dicom-parser, I don't see any other overlays hiding around:

image

I see a similar result in my local tag dumper. I'm wondering if the "6 lines of text" for the image isn't entirely accurate?

@jdnarvaez
Copy link
Contributor

The code i provided should read all six layers as we render all six in our viewer. I’ll try to have a look at this this week

@kofifus
Copy link
Contributor Author

kofifus commented Feb 11, 2019

Possibly the missing 2 layers are in the presentation state (see #780 (comment)) which cornerstone does not support ?

@jdnarvaez
Copy link
Contributor

Yep, that’s the case.

@kofifus
Copy link
Contributor Author

kofifus commented Feb 11, 2019

cool, I believe this can be closed :)

@kofifus kofifus closed this as completed Feb 11, 2019
@dannyrb
Copy link
Member

dannyrb commented Mar 4, 2019

@all-contributors please add @jdnarvaez for sharing his code for Overlays

@allcontributors
Copy link
Contributor

@dannyrb

I've put up a pull request to add @jdnarvaez! 🎉

@kofifus
Copy link
Contributor Author

kofifus commented Mar 27, 2019

@jdnarvaez - in https://gist.github.com/jdnarvaez/3368ac3e4f7f4eb14bc5f453f8a1ed1b#file-graphicoverlays-js-L38 you again call setTransform after calling just above, can you pls explain what is the purpose of the second call ? Thanks!

@kofifus kofifus reopened this Mar 27, 2019
@jdnarvaez
Copy link
Contributor

@kofifus the transform is first set to the coordinates of the current canvas, then it it is saved, then it is set to 1:1 scaling, then reset to the previous scaling. This allows us to draw the overlays in a uniform coordinate system, so that any transformations or scaling by the user are also applied to the overlays

@kofifus kofifus closed this as completed Mar 27, 2019
swederik added a commit that referenced this issue Jan 28, 2020
…ne layers on top of the image (#860) - Thanks @kofifus, @jdnarvaez

* feat(OverlayTool): Support for rendering overlay layers on top of the image data

See DICOM: http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html

re #780

* Add OverlayTool exports

* Add overlay tool to examples

* Make sure enabledElement is defined

* Capitalize data-tool; better tool toggling

* lowercase first letter 👍

* Use @cornerstonejs org scope

* dry run; finding tag and publishing feature/hotfix branches as tagged releases

* Change workflow priority

* filtering is regex

* Fix bash syntax error

* invoke script w/ bash

* Playing w/ bash syntax in circleCI's environment

* Public scoped packages

* Publish a tagged package

* Make sure we're not stealing a version number that can be used for master

* Better RegExp to set version

* Tidying up comments and formatting

* Try using an alternative package version

* Update OverlayTool.js

* Update OverlayTool.js

* Fix prettier build error

* Protect against `null` viewport pixelSpacing

* Remove unnecessary changes

* Fix unnecessary changes

* Fixes for rendering overlays

Co-authored-by: Kofifus <mikagenic@gmail.com>
Co-authored-by: Erik Ziegler <erik.sweed@gmail.com>
@luvargas1
Copy link

Should the cornestone magnify tool work on overlay data?

sedghi pushed a commit to sedghi/cornerstone3D-beta that referenced this issue Jan 13, 2023
…rlays (cornerstonejs#240)

* DICOM Overlays

Adds 'overlayPlaneModule' type returning an array of DICOM overlays.
This array is then added the 'overlays' propertry of the image.

This is then read by the overlays tool see - [cornerstonejs/cornerstoneTools#788](cornerstonejs/cornerstoneTools#809)

see issue [cornerstonejs/cornerstoneTools#780](cornerstonejs/cornerstoneTools#780)
see DICOM overlays standard - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html

* DICOM Overlays

Adds 'overlayPlaneModule' type returning an array of DICOM overlays.
This array is then added the 'overlays' propertry of the image.

This is then read by the overlays tool see - [cornerstonejs/cornerstoneTools#788](cornerstonejs/cornerstoneTools#809)

see issue [cornerstonejs/cornerstoneTools#780](cornerstonejs/cornerstoneTools#780)
see DICOM overlays standard - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html
sedghi pushed a commit to cornerstonejs/cornerstone3D that referenced this issue Jan 30, 2023
…rlays (#240)

* DICOM Overlays

Adds 'overlayPlaneModule' type returning an array of DICOM overlays.
This array is then added the 'overlays' propertry of the image.

This is then read by the overlays tool see - [cornerstonejs/cornerstoneTools#788](cornerstonejs/cornerstoneTools#809)

see issue [cornerstonejs/cornerstoneTools#780](cornerstonejs/cornerstoneTools#780)
see DICOM overlays standard - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html

* DICOM Overlays

Adds 'overlayPlaneModule' type returning an array of DICOM overlays.
This array is then added the 'overlays' propertry of the image.

This is then read by the overlays tool see - [cornerstonejs/cornerstoneTools#788](cornerstonejs/cornerstoneTools#809)

see issue [cornerstonejs/cornerstoneTools#780](cornerstonejs/cornerstoneTools#780)
see DICOM overlays standard - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html
sedghi pushed a commit to cornerstonejs/cornerstone3D that referenced this issue Jan 30, 2023
…rlays (#240)

* DICOM Overlays

Adds 'overlayPlaneModule' type returning an array of DICOM overlays.
This array is then added the 'overlays' propertry of the image.

This is then read by the overlays tool see - [cornerstonejs/cornerstoneTools#788](cornerstonejs/cornerstoneTools#809)

see issue [cornerstonejs/cornerstoneTools#780](cornerstonejs/cornerstoneTools#780)
see DICOM overlays standard - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html

* DICOM Overlays

Adds 'overlayPlaneModule' type returning an array of DICOM overlays.
This array is then added the 'overlays' propertry of the image.

This is then read by the overlays tool see - [cornerstonejs/cornerstoneTools#788](cornerstonejs/cornerstoneTools#809)

see issue [cornerstonejs/cornerstoneTools#780](cornerstonejs/cornerstoneTools#780)
see DICOM overlays standard - http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_C.9.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants