Display 3D points as spheres in 2D rendering mode

Hi,
I need to put points at the centre of 3-dimensional spherical objects and adapt the size of the points to match the size of the objects. I set Points.n_dimensional to True. I add a point at the centre of a spherical object, adapt its size, and then I want to verify that I was indeed at the centre of the object and that I do not have an offset in the third dimension (along Z axis). For that I scroll through the volume (all of this is done in 2D rendering mode). The displayed point diameter decreases faster with the z-distance from the point centre than expected for a sphere. Would it be possible to modify this behaviour (or add an option to select the behaviour of 3D points display in 2D rendering mode)? Note that when displayed in 3D rendering mode, the points are rendered as spheres.

Another non-ideal behaviour for my purpose is how the points are displayed when I zoom a lot. Up to a certain zoom level, the point is zoomed exactly as the underlying structure. However above this zoom level, the point is not further magnified, whereas the underlying structure still is. For my purpose, it would be useful if the point would keep getting magnified. Would it be possible to also make an option to switch between the existing behaviour and the other one?

Thanks
Benoit

edit:
I noticed that the size of the points in the third dimension is not affected by the point size slider. I added a few points and edited their size. the 3rd dimension size remains always equal to 10:

array([[10., 10., 10.],
[10., 10., 10.],
[10., 33., 33.],
[10., 61., 61.],
[10., 61., 61.]]))

Right now this behaviour is controlled within vispy the rendering engine that napari is using. I’ve noticed the behavior too and am not quite sure what controls it or if it can be turned off. We can investigate.

Yes, unfortunately right now our points are always displayed as circles in 2D and spheres in 3D. This is also controlled in vispy, but we should probably change too.

Hmm I wonder what is going on here, this surprises me unless there is something funny going on with the layer scale/ points size that is not anisotropic in the way you expect.

Ah ok, this is what’s going on then. The expectation is that the point size should scale in z too probably.

A long time ago we had a couple of issues and work in progress PRs to improve our handling of point scale in 3D with anisotropy, see Specifying nD point sizes · Issue #480 · napari/napari · GitHub and https://github.com/napari/napari/pull/552. These seem to be about the API more than the GUI behaviour, but we might want to take a look at them again as we decide how to improve this stuff.

Hope some of the info helps. Let’s keep this convo going as it sounds like we have some improvements we could be making. It might be nice to turn this into a few github issues - one for the zoom points issue, one for the 3D rendering as spheres, and one for the z-scaling with the slider.

Thanks a lot for the explanations! I need to understand a bit better how the key binding work for some other aspect of my project and when I have I will see if I can resize the third dimension in the viewer. I’ll report here

1 Like