webknossos icon indicating copy to clipboard operation
webknossos copied to clipboard

Nodes are shown in wrong slice when moving back and forth with low clipping distance

Open fm3 opened this issue 4 years ago • 4 comments

Context

I am annotating a dataset for alignment corrections. For this it is important to set nodes in the precise z coordinate of specific image tiles. For this I turn the clipping distance very low. I then move back and forth a lot by using the scroll wheel or d/f.

Expected Behavior

Nodes with z=10 should be visible exactly when position’s z is shown as 10 in the toolbar.

Current Behavior

Sometimes the node is shown in the neighboring slice and not in slice 10.

Steps to Reproduce the bug

  • Open https://webknossos.brain.mpg.de/annotations/Explorational/610a44ee0100008d118a58ad#1386,19353,2326,0,15.863,10
  • Set clipping distance to 1 (what’s the unit here? Related issue #5566 )
  • Select a node
  • move around with d/f
  • depending on the move direction the node is visible in different slices

Your Environment for bug

Firefox Linux

Related issue

I suspect this is closely related to #5233 and the old PR https://github.com/scalableminds/webknossos/pull/5201, which is mentioned there

fm3 avatar Aug 05 '21 11:08 fm3

I think, we should try to fix #5233 (see my newest comment) first. I assume, this issue here will be either solved automatically or should be easier to grasp.

philippotto avatar Aug 31 '21 14:08 philippotto

I implemented the approach I suggested in #5233 (PR: #5801). I still think that the change should soften the problem which is described in the current issue here. However, the actual problem is probably as follows:

  • The clipping distance goes in both directions (so, if the clipping distance is large enough you can see nodes before and after the current slice). This is by design and should probably not change (even if we changed it, the actual problem wouldn't be solved either).
  • Due to the floating point position, a fixed clipping distance cannot ensure that only nodes of the current slice are rendered. For example, if I'm at z=0.5, the clipping distance would need to be 0.5 to only see the node in the current slice. If I'm at z=0.6, it would need to be 0.4 in one direction and 0.6 in the other --> doesn't work.

For this particular use case ("I only want to see nodes in the current slice"), I would consequently suggest to:

  • have a dedicated option à la "Only show nodes in the current slice"
  • or implement the related issue #5766

For now, I suggest to wait a bit to see how #5801 will improve things (hopefully). Afterwards, we can decide how to proceed.

philippotto avatar Nov 01 '21 13:11 philippotto

I just noticed #4366 is a duplicate of this issue. closing it now, but to preserve the info, I’m quoting from the description there:

My scenario is quite rare I guess: my dataset is downsampled with z=1, I’m looking at mag 64-64-1, going through slice by slice. The clipping distance is lower than the z resolution, I want to see my nodes only in the slice where I created them. I frequently get into the situation that I see my nodes only in the slice next to the one they were created in, and not in their real one. My hypothesis is that the camera position is a float, and in this situation the camera is just slightly below the correct slice, leading to showing the slice below, but the clipping distance determines that the nodes from above be shown.

-------------X------- slice (not shown) with node (shown)
             | small distance
····················· camera
             |
             |
             |
             |
             |
---------------------next slice without node (shown)

If this is in fact the reason, this might be fixed by showing the slice closest to the camera rather than the slice next below the camera. I may be mistaken though, and of course I’m not sure what other side-effects this would have (it’s still important that nodes are created at the slice that was visible during the click)

fm3 avatar Oct 20 '22 16:10 fm3

I think, your hypothesis is spot-on. It probably boils down to the following conflict:

  • node positions can be fractional (soon to be integers?)
  • the camera position is fractional
    • thus, the clipping distance considers the (fractional) distance between camera and nodes
    • the camera position is floored (!) in the position input box
    • the rendered plane is looked up by flooring (!) the current position

We could change the two floor-operations to round, but I'm also hesitant about the consequences.

I frequently get into the situation that I see my nodes only in the slice next to the one they were created in, and not in their real one.

Two thoughts:

  • if you center a node with "S", the camera position should be integer again so that pressing f/d should deliver the desired experience for you (under the assumption that the node position is integer)
  • quoting myself from above:

For this particular use case ("I only want to see nodes in the current slice"), I would consequently suggest to:

  • have a dedicated option à la "Only show nodes in the current slice"
  • or implement the related issue https://github.com/scalableminds/webknossos/issues/5766

philippotto avatar Oct 21 '22 08:10 philippotto