Skip to content

Measure missing-slice spacing deviations in mm - #465

Merged
CPBridge merged 1 commit into
ImagingDataCommons:masterfrom
CedricConday:bugfix/missing-positions-tolerance-units
Oct 6, 2026
Merged

CPBridge merged 1 commit into
ImagingDataCommons:masterfrom
CedricConday:bugfix/missing-positions-tolerance-units

Conversation

@CedricConday

Copy link
Copy Markdown
Contributor

Fixes #464.

In the allow_missing_positions branch of get_volume_positions, the deviation of each slice from its nearest integer multiple of the spacing was compared in units of the spacing, so atol (documented in mm) accepted a larger physical error the wider the spacing, and rtol scaled with the slice index rather than with the spacing as it does in the regularly-spaced branch.

The branch now converts the rounded multiples back to mm (round(multiple) * spacing + min), measures the deviation there, and compares it with atol + rtol * |spacing|, which is the same rule np.isclose(spacings, spacing, rtol, atol) applies in the regular branch. The debug log reports the maximum deviation in mm, as its message says. Nothing changes for callers whose slices sit within tolerance under both readings; positions that were only accepted because the spacing was wide are now rejected, as atol documents.

Test: test_get_volume_positions_missing_tolerance_units checks that a 0.5 mm displacement is rejected with atol=0.1 at 1, 5, 10 and 20 mm spacing, and that a 0.05 mm displacement is accepted at all four. tests/test_spatial.py passes (128 tests) and flake8 is clean on both files; mypy's pre-existing errors in spatial.py are untouched.

The allow_missing_positions branch of get_volume_positions compared
distances expressed as multiples of the slice spacing, so 'atol', which
is documented in mm, accepted a larger physical deviation the wider the
spacing, and 'rtol' was relative to a slice's index rather than to the
spacing as it is in the regularly-spaced branch.

Convert the rounded multiples back to mm and compare there, so both
branches read the tolerances the same way and the logged deviation is
in the unit it claims.
@CPBridge

CPBridge commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

@CedricConday Thanks for catching this and the PR!

@CPBridge
CPBridge merged commit 74ffe07 into ImagingDataCommons:master Oct 6, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_volume_positions: with allow_missing_positions the tolerances are applied in slices, not mm

2 participants