brisvag / blik

Python tool for visualising and interacting with cryo-ET and subtomogram averaging data.
https://brisvag.github.io/blik/
GNU General Public License v3.0
23 stars 8 forks source link

reducing coordinate opacity makes black dots on the image layer #143

Open McHaillet opened 11 months ago

McHaillet commented 11 months ago

Here, a short video of the issue (recorded directly after I opened Blik):

Screencast from 02-08-23 16:49:56.webm

brisvag commented 11 months ago

Confirm I can't reproduce on my machine. Can you paste the output of napari --info?

McHaillet commented 11 months ago

Voila:

napari: 0.4.18
Platform: Linux-5.14.0-1050-oem-x86_64-with-glibc2.35
System: Ubuntu 22.04.2 LTS
Python: 3.10.12 (main, Jul  5 2023, 18:54:27) [GCC 11.2.0]
Qt: 5.15.2
PyQt5: 5.15.9
NumPy: 1.25.1
SciPy: 1.11.1
Dask: 2023.7.1
VisPy: 0.12.2
magicgui: 0.7.2
superqt: unknown
in-n-out: 0.1.8
app-model: 0.2.0
npe2: 0.7.2

OpenGL:
  - GL version:  4.6.0 NVIDIA 535.86.10
  - MAX_TEXTURE_SIZE: 32768

Screens:
  - screen 1: resolution 1920x1080, scale 1.0
  - screen 2: resolution 1920x1080, scale 1.0

Settings path:
  - /home/marten/.config/napari/blik_env_4f55b458f76e0e18212ea2a8e7f36b42c679bdf4/settings.yaml
Plugins:
  - blik: 0.4.1.dev18+ga13c049 (22 contributions)
  - napari: 0.4.18 (77 contributions)
  - napari-console: 0.0.8 (0 contributions)
  - napari-label-interpolator: 0.1.0 (2 contributions)
  - napari-properties-plotter: 0.2.2 (2 contributions)
  - napari-properties-viewer: 0.0.2 (2 contributions)
  - napari-svg: 0.1.10 (2 contributions)
brisvag commented 11 months ago

This sounds like a napari issue... If you run this in ipython, do you see the same issue instead of a half-transparent point?

import napari
import numpy as np
v = napari.Viewer()
v.add_image(np.random.rand(100, 100))
v.add_points(np.array([50, 50]), opacity=0.4)

I see this, for reference: image

McHaillet commented 11 months ago

Seems like here it does work. Would it help to run napari with --debug mode or something? Maybe I could get some additional info there

Screenshot from 2023-08-04 10-59-14

brisvag commented 11 months ago

For now we just need to find a minimal reproducer; I think it's an openGL issue, so it's unlikely to come out of napari code specifically, I'll probably have to dig into vispy.

Try this:

import napari
import numpy as np
v = napari.Viewer()
v.add_image(np.random.rand(100, 100))
v.add_points(np.array([50, 50]), opacity=0.4, shading='spherical')

and if it's still fine, change the point colors to 'teal'?

McHaillet commented 11 months ago

This also works fine, as well as changing colors to teal.

brisvag commented 11 months ago

Nasty bug :P some other things to try:

McHaillet commented 11 months ago

will try it tomorrow morning!

McHaillet commented 11 months ago

I tried those things but don't get the issue. Also tried making it 3D and using the out_of_slice_display (as below), but also does not reproduce it.

v.add_image(np.random.rand(10, 100, 100))
v.add_points(np.array([5, 50, 50]), opacity=0.4, shading='spherical', out_of_slice_display=True)
brisvag commented 11 months ago

Ok, I actually got it to reproduce. In my case, it's indeed because of the layer order. Basically, if you have the image above the points and make the points transparent, the thing you see behind the points is the canvas (black). This is actually kind of unsolvable because of how opengl blending works (unless we break other things). Here's a comment mentioning this exact issue (and approrpiately, it was me who said "let's cross that bridge when we get to it" xD).

So for you the solution should be: move the points layer above the images. Does that work?

McHaillet commented 10 months ago

It's a been while, sorry for that.

That indeed solves the problem haha Maybe you could switch the default order of the layers in Blik to prevent the issue?

brisvag commented 10 months ago

I already have a little trick like that in fact (sorting layers before adding them), the problem is, it doesn'y work xD napari gives the files to readers one by one instead of as a list... Not sure there's a solution to that other than writing my own entry point script.