InsightSoftwareConsortium / itkwidgets

An elegant Python interface for visualization on the web platform to interactively generate insights into multidimensional images, point sets, and geometry.
https://itkwidgets.readthedocs.io/
Apache License 2.0
576 stars 83 forks source link

Dark halo around label maps when `image` is not specified. #682

Closed denbonte closed 11 months ago

denbonte commented 11 months ago

Dear Developers,

Thank you for all the work you put into the extension: I started using itkwidgets recently and find it really impressive!

I'm running into a problem that I did not see mentioned in any of the open issues, nor on the documentation or somewhere else. Since the images I'm trying to visualize (a CT scan and segmentation mask pair) are pretty sizy (and I ideally would like not to downsample them), I'm spawning a widget that is rendering the segmentation mask only.

Upon first loading/rendering (the "rough" rendering), the visualization looks beautiful!

image

After a few seconds, however, a dark halo gets rendered around the label map:

image

Is there any way I can stop this from happening? Note that, if I were to load the image as well, such halo would not be present. This is running in Google Colab using itkwidgets[all]==1.0a36 and: the very simple snippet

viewer = view(label_image=output_image)

I tried messing with most of the parameters (e.g., gradient_opacity, blend_mode, the shadows in the rendering) - but nothing worked.

Thank you in advance for your help!

fedorov commented 11 months ago

@bnmajor any idea about this? We are planning to demo itkWidgets as part of MHub session at the MICCAI IDC tutorial, and it would be nice if it looks good.

fedorov commented 11 months ago

@denbonte can you please share the link to the notebook to reproduce this?

aylward commented 11 months ago

Two solutions:

1) The menu-drive solution In the menu, select label 0 (using the pull-down menu in the lower left - circled in red in the image below) and the change the opacity of that label to 0 (move the slider to the left - also circled in red in the image below). This will cause the 0 label (which is "black" and therefore creating a shadow) to become completely transparent.

2) The programmatic solution v = view(label_image=data_im) v.set_label_image_weights([0,1]) -- that assigns a weight for 0 to the first label (label 0) and a weight of 1 to all subsequent labels.

Hope this helps, Stephen

Before Before

After Fixed

denbonte commented 11 months ago

Dear @aylward,

By following your advice, I fixed the "halo" problem (I saw you also opened an issue about it - amazing, so people won't run into this in the future!)

However, by using:

set_label_image_weights([0,1])

I completely lost the default color scheme (and I haven't been able to get it back)!

image

Do you know if this is an easy fix, or... ?


Also, I wanted to report: it turns out Colab is actually pretty fast with rendering when the cell is run on its own (so without running all the cells together) - so we are definitely going to have it 🙃

image

FYI, you can find the notebook we prepared for the MICCAI tutorial session at the MHubAI/examples repository, here. We're still working on it, so this is not the final version - but any difference with what we have right now should be very minor!

Thanks again for your help!

aylward commented 11 months ago

Hi,

I tried creating a simple demo with nested labels, labels with random noise, and other variations to duplicate this, but no luck. I'll have to run your demo later tonight to look at the mask more closely...or perhaps you can send me the "merged_mask.nrrd" file?

Also, try changing [0,1] to [0,10]. This will render "very" opaque objects, but it might help (I'm suspecting some kind of partial volume or interpolation artifact is to blame - however, I am seeing the colormap in the 2D views going wonky - so there might be a bug).

Thanks, Stephen

On Thu, Oct 5, 2023 at 5:12 PM Dennis Bontempi @.***> wrote:

Dear @aylward https://github.com/aylward,

By following your advice, I fixed the "halo" problem (I saw you also opened an issue about it - amazing, so people won't run into this in the future!)

However, by using:

set_label_image_weights([0,1])

I completely lost the default color scheme (and I haven't been able to get it back)! [image: image] https://user-images.githubusercontent.com/31729248/273040247-749a96d3-64e1-4fbd-a769-16458a88085b.png

Do you know if this is an easy fix, or... ?

Also, I wanted to report: it turns out Colab is actually pretty fast with rendering when the cell is run on its own (so without running all the cells together) - so we are definitely going to have it 🙃 [image: image] https://user-images.githubusercontent.com/31729248/273040339-7b7d3af5-4390-441d-b11a-2a0cfce18b74.png

FYI, you can find the notebook we prepared for the MICCAI tutorial session at the MHubAI/examples repository, here https://github.com/MHubAI/examples/blob/main/notebooks/MICCAI23_tutorial.ipynb. We're still working on it, so this is not the final version - but any difference with what we have right now should be very minor!

Thanks again for your help!

— Reply to this email directly, view it on GitHub https://github.com/InsightSoftwareConsortium/itkwidgets/issues/682#issuecomment-1749652094, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACEJLZJJBA5LI3XWB5HJ6LX54PFPAVCNFSM6AAAAAA5QDW3LKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGY2TEMBZGQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Stephen R. Aylward, Ph.D. Chair, MONAI Advisory Board Senior Director, Strategic Initiatives, Kitware