Why slice-view can not be updated/changed with one-by-one image dimension with a small pixel-spacing?

Operating system: windows
Slicer version: 4.11.2210226
Expected behavior: slice view updated one slice by one slice
Actual behavior: only after two slices.

Hi all,
First of all, while I increase the pixel-spacing by 1000, there is no such an issue. That is, say my original data’s pixel-spacing 0.763922um, then it is increased to 1000 times, 763.922um, while I set one-slice by one-slice, the slice-view gets updated well and correctly.

The issue is: with 0.763922um/pixel, the slice-view gets only updated every two-slices.
My checking code through Python-Interactor is as follows after loading my data:

import numpy as np
import slicer
sliceNodeID = 'vtkMRMLSliceNodeRed'
DimsNumber = 100
sliceNode = slicer.mrmlScene.GetNodeByID(sliceNodeID)
lm = slicer.app.layoutManager()
sliceLogic = lm.sliceWidget(sliceNode.GetLayoutName()).sliceLogic()
sliceSpacing = sliceLogic.GetLowestVolumeSliceSpacing()
sliceOffsetResolution = sliceSpacing[0]
sliceOffsetMin = sliceBounds[4]
sliceOffsetMax = sliceBounds[5]

so now I set DimsNumber = 100

sliceLogic.SetSliceOffset(sliceOffsetMin+ (DimsNumber)*sliceOffsetResolution ) 

this will be working well to see updated slice-view of “Red”.

but then ==> while DimsNumber = 100+1
sliceLogic.SetSliceOffset(sliceOffsetMin+ (DimsNumber)*sliceOffsetResolution )
the RED-slice-view gets NO updates (the position value of the red-view NO change either.)

Now then ==> while DimsNumber = 100+2

sliceLogic.SetSliceOffset(sliceOffsetMin+ (DimsNumber)*sliceOffsetResolution ) 

the slice-view gets changed/updated correctly.

So what’s the factor playing a role in this issue? Somewhere there is an extra processing like being-round?

PS: I just finished testing inside the night-version 3D-Slicer-5.0.1, there is the same issue as described above.

I don’t know why for sure in this case, but it’s not uncommon to have trouble working with small scans and multiplying the spacings so that the numbers are around 1 gives better numerical stability than using very small numbers that may lead to floating point errors.

Thanks a lot for your reply there Steve. I believe with pretty much high possibility the issue is being caused by keeping significant numbers of small float values. I hope the Slicer-Group may take some effort to dig it out.

Yes, it’s come up before and there’s been some work at generalizing the infrastructure but still there are some places where it’s safest to just rescale the data and just pretend it says um when the interface says mm. I’m sure this will come up more as people try microscopy workflows and maybe we’ll find some resources to work on a more general solution.

Hi Steve, one potentially easiest way to correct this issue may be like:
Displaying the value there with 5 or 6 decimals for the position in each sliding-bar of slice-views there.

Right now default it is only 4 decimals in mm (covering only 0.1um), so while we take default units in mm, after showing 5 decimals, it will directly show 0.00001mm to directly cover 0.01um

That might be the issue, but there could be others too.

This is some support for setting the units to something other than mm, but I would be careful because I’m not sure it gets a lot of use. Maybe others can comment.


1 Like

Thanks a lot, I will try based on the link you provided there to see how it goes. Based on some previous experience on units settings, something does not work smooth there. anyway I will try more.

By adjusting Units settings in Application settings you can modify the number of displayed digits (just modify the Precision value of Length).

However, this increased display precision might not solve all issues and you may want to rescale your data for better numerical stability. If you rescale your data then you may switch units for correct display of physical values. However, units support is incomplete (see missing tasks here), so depending on what operations you need to do, it may be confusing that sometimes you still see mm instead of the length unit that you have set.