haesleinhuepf / napari-assistant

BSD 3-Clause "New" or "Revised" License
20 stars 5 forks source link

New default for image layer blending #18

Closed haesleinhuepf closed 2 years ago

haesleinhuepf commented 2 years ago

Instead of translucent we should use translucent_no_depth here: https://github.com/haesleinhuepf/napari-assistant/blob/fe4a40342ff232acddaca863209dbf0e94e20e7f/napari_assistant/_categories.py#L30

... as discussed in https://github.com/napari/napari/issues/4618

However, we would need to pin napari>=0.4.16 to make it work and 0.4.16 is not on conda yet.

psobolewskiPhD commented 2 years ago

I wonder if you can get the correct behavior by not setting translucent as your own default blending? Using None instead? Then only set blending when you want additive or specifically depth checking, etc. Then in 0.4.15 you will get the napari default: translucent and in 0.4.16 you will get translucent_no_depth The relevant code is here for single channel: https://github.com/napari/napari/blob/23bac0cc9a8f2967934c255481936f8b2d809421/napari/components/viewer_model.py#L740 And here for split channel: https://github.com/napari/napari/blob/23bac0cc9a8f2967934c255481936f8b2d809421/napari/layers/utils/stack_utils.py#L83 Edit: note that's the 0.4.16 code, so translucent has been changed to translucent_no_depth

Czaki commented 2 years ago

However, we would need to pin napari>=0.4.16 to make it work and 0.4.16 is not on conda yet.

you may check the napari version and provide a default value based on this.

psobolewskiPhD commented 2 years ago

Thinking more, I can't think of any issue with using translucent_no_depth in 0.4.15, so if you do want to specify your own default, I think that should work?

psobolewskiPhD commented 2 years ago

I wonder if you can get the correct behavior by not setting translucent as your own default blending? Using None instead?

I checked making this change locally and it works: In 0.4.16 blending is translucent_no_depth so the depth checking issue is resolved. In 0.4.15 blending is translucent and no change in behavior is observed. (using the workflow in the original napari issue from the OP) Not sure if it breaks something else, but it shouldn't? 🤣

haesleinhuepf commented 2 years ago

Hey guys @Czaki @psobolewskiPhD ,

if you want to give it a try to pass None or translucent_no_depth and see if it works with both napari version, your PR is very welcome! :-)

Thanks! Robert

psobolewskiPhD commented 2 years ago

@haesleinhuepf Since I started playing with it locally, I may as well make the PR. But, I notice that some of the Categories also hard-set blending to translucent: e.g. Measure Labels: https://github.com/haesleinhuepf/napari-assistant/blob/fe4a40342ff232acddaca863209dbf0e94e20e7f/napari_assistant/_categories.py#L153-L163

How should those be handled? Maybe that explicit setting of blending should be dropped, so also just use the Category class default (which will be None, which will then use the napari default)? Or is there specific need for depth checking there?

haesleinhuepf commented 2 years ago

The default was 'translucent', thus, this line in specific categories should not have any effect. You can try removing those ...

psobolewskiPhD commented 2 years ago

Right, but with the new default None to fix the issue, those lines will hard-set translucent again, which will cause the glitch in the napari issue for those specific categories. So I was wondering if the setting for these Categories was intentional/necessary. I guess not, so I will try removing and we'll see.

haesleinhuepf commented 2 years ago

those lines will hard-set translucent again

That's why I proposed:

You can try removing those ...

haesleinhuepf commented 2 years ago

solved in #19