Modify fov computation, particullary the decimal precision on the voxel size - #850
Conversation
dkuegler
left a comment
There was a problem hiding this comment.
Looks fine to me. I guess it also does not matter if you round first and then multiply with img_size.
|
I wonder why there is a discrepancy between our own conforming step and the conforming check later. Both should be based on the same code and therefore give the same result ? |
The ceil() that turns field-of-view into a voxel count could round up on floating-point noise: storing the zoom as float32 leaves a relative residual (~1e-8) that, scaled by the voxel count, pushed an exact fit just over the integer (e.g. 320.0000048 -> 321). This is machine precision, not a voxel-size tolerance, and its absolute size grows with the image, so the previous fixed-tolerance guard (*10000/int/10000, ~1e-4) was both conceptually wrong and fragile for large images. Snap counts that are integer within a relative 1e-6 to the nearest integer, and ceil only genuine partial voxels.
Why this happens
I considered forcing the header after conforming to be exactly .8 on all axes, but that would overwrite the real sizes and loose that information. Headers should stay accurate to what was actually done to the data. The fix in this PR rounds voxel sizes to the same precision ( I will add two changes:
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts how conformed_vox_img_size() computes the field-of-view (FOV)–derived image size during conforming, aiming to avoid failures caused by floating-point precision noise in voxel sizes (notably with orig.mgz during recon-surf’s conform stage).
Changes:
- Derives a shared
decimalsrounding precision fromvox_epsand uses it to round voxel sizes/zooms consistently. - Updates FOV-based target size computation to “snap” near-integer voxel counts instead of always
ceil-ing after decimal truncation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
the surface pipeline fails during the conform stage when processing orig.mgz. It seems to be related to the FOV calculation and the decimal precision of the voxel size
old recon-surf
recon-surf.log
after fixing decimal points
recon-surf.log