Fix DVH calculation on boundary voxels and add regression test for final-bin volume#390
Open
SaharYaz wants to merge 2 commits into
Open
Fix DVH calculation on boundary voxels and add regression test for final-bin volume#390SaharYaz wants to merge 2 commits into
SaharYaz wants to merge 2 commits into
Conversation
Add a unit test constructing a 1×1×1 dose grid slightly above an integer histogram boundary with a matching square contour. The test verifies that: - the histogram has 54 bins - the final bin contains the full voxel volume (1 mm³ = 0.001 cc) Without mask tolerance, the calculation collapses to a one-bin, zero-volume histogram, causing the test to fail.
* Expand polygons by a tiny radius before calling Path.contains_points so voxels on contour boundaries are treated as inside. * Fall back to PixelSpacing when LUT diffs are empty, allowing volume calculation on single-pixel grids.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a regression test that exposed an error in DVH histogram calculation when voxel centers lie exactly on structure boundaries. The fix adjusts the mask calculation and ensures correct handling of the final bin.
Changes
test_histogram_preserves_final_binto verify that a 1×1×1 dose grid slightly above an integer boundary yields:dvhcalcto:Path.contains_pointsso boundary voxels are treated as inside.PixelSpacingwhen LUT diffs are empty, enabling correct volume calculation on single-pixel grids.Motivation
Without the fix, the regression test failed because the histogram collapsed to a single zero-volume bin. With this patch, the histogram correctly preserves the final bin volume.
Impact
Closes #389