cornerstonejs / cornerstoneTools

A framework for tools built on top of Cornerstone.
https://tools.cornerstonejs.org/
MIT License
574 stars 456 forks source link

Overlay tool shows overlays at incorrect coordinates #902

Open bingwing opened 5 years ago

bingwing commented 5 years ago

hi, guys, @swederik @medihack @simonmd @jpambrun , thanks for the excellent work.

When i use the cornerstone in cornerstoneWADOImageLoader, there a few dicoms file shown black. image

image

image image

the core js code in the html:

cornerstoneWADOImageLoader.external.cornerstone = cornerstone; var dicomelement = document.getElementById("dicomImage");

function loadAndViewImage(dicombase64data, arealocation) {
    var element = document.getElementById(arealocation);

    try {
        cornerstone.loadImage(dicombase64data).then(
            function(image) {
                var viewport = cornerstone.getDefaultViewportForImage(
                    element,
                    image
                );
                console.log(viewport)
                cornerstone.displayImage(element, image, viewport);
                if (loaded === false) {
                    cornerstoneTools.mouseInput.enable(dicomelement);
                    cornerstoneTools.mouseWheelInput.enable(dicomelement);
                    cornerstoneTools.pan.activate(dicomelement, 2); // pan is the default tool for middle mouse button
                    loaded = true;
                }
            },
            function(err) {
                alert(err);
            }
        );
    } catch (err) {
        alert(err);
    }
}

cornerstone.enable(dicomelement);

Dicom files special, or i miss something?

Hope you can reply this thread, thank you very much!

swederik commented 5 years ago

It looks like that may be pixel data stored in Overlay tags: See http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.9.2.html

There is an open PR on Cornerstone Tools to support this:

https://github.com/cornerstonejs/cornerstoneTools/pull/860

If those images truly contain PHI (I see something that looks like a patient name), please remove it. You can black it out with paint and upload it again.

bingwing commented 5 years ago

Thanks, already black the PHI i think and upload again, what do we call the chart looks like in the first pic. And how can i show it correctly? do we have demos deal with this? looked up all the issues and didn't find any similar one.

georggrab commented 5 years ago

I've seen this before. Can you delete MinPixelValue and MaxPixelValue tags from your dicom file and try again? Alternatively, turning off strict mode in the WADO image loader config

jpambrun commented 5 years ago

@swederik assessment is correct. The first sample is likely a black image with a G6000 overlay. This is supported by the WL=1, WW=1 in the working viewer. In addition, the beige color overlay would otherwise be impossible on the grayscale MONOCHROME2 MR.

bingwing commented 5 years ago

Thanks, but i'm very new with dicom, is there a demo code or any reference could help me to solve this? @dannyrb @swederik @jpambrun

bingwing commented 5 years ago

I can see there provide overlayPlaneModule to parse overlay data.But the overlaydisplayTool seems to be have pending for a while here already. @dannyrb @swederik @kofifus @jpambrun , i was stucked deeply, is there any one could give me some advances? Thanks !

kofifus commented 5 years ago

I don't know why the overly tool is not merged, as far as I know there are no pending issues with it .. @dannyrb ?

dannyrb commented 5 years ago

@kofifus, I need to update that PR to not publish as a scoped package, and then it will be good for merge.

bingwing commented 5 years ago

Thanks! Very happy to hear this !! BTW, will it take long to do the merge , or where can i find a demo example code to experience in advance? @kofifus @dannyrb

bingwing commented 5 years ago

@kofifus @dannyrb Hint a issue when test the overlay tool, seems the overlays not get the right location as below pic shown.

issue1

issue2

Repro steps:

  1. check out feature/overlay-tool and compile to get the .js package
  2. import overlay tool to my project with code as other tool did like this: cornerstoneTools.init({ globalToolSyncEnabled: true }); const OverlayTool = cornerstoneTools.OverlayTool; cornerstoneTools.addTool(OverlayTool); cornerstoneTools.setToolEnabled("Overlay", {});

Did i miss something, hope someone could reply this thread. Thank you very much!

dannyrb commented 5 years ago

@bingwing if you can provide a minimal reproduction (repo or codesanbox), or anonymized files for testing, I would be able to take a closer look.

bingwing commented 5 years ago

@dannyrb @kofifus Sorry i can't find any anonymized files for sharing now, but after fork your codesanbox and testing[only the dicom file changed!], it also shown incorrectly. Screenshot as below.

image

should be like this image

Thanks !

bingwing commented 5 years ago

@dannyrb @kofifus Problem solved !!!

After debugging feature/overlay-tool, i wonder that, is the code in line 100 odd ?

The setTransform executed twice, after delete line 100, everything becomes good.

gitissue

Thank you for the excellent work again! Bing

dannyrb commented 5 years ago

@bingwing, thanks for the update! I'll shift this over to the tools repository and mark it as a bug report. Hoping to find some time here soon to merge the overlay tool. If you were able to provide example DICOMs to build a test case, that would be helpful 👍

kofifus commented 5 years ago

@bingwing - pls see this to explain why the transform is set twice https://github.com/cornerstonejs/cornerstoneTools/issues/780#issuecomment-476975576

perhaps @jdnarvaez can help here ?