Fix vessel structure generation at tissue boundaries #433
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.
Please check the following before creating the pull request (PR):
List any specific code review questions
None - straightforward loop restructuring to fix boundary condition check.
List any special testing requirements
None beyond existing test suite.
Additional context (e.g. papers, documentation, blog posts, ...)
The issue manifests when vessel start coordinates exactly equal tissue dimensions (e.g., y=16mm for a 16mm volume). Before fix, only ~11% of expected vessel volume was generated. After fix, vessels at boundaries generate correctly at ~100% of expected volume.
Provide issue / feature request fixed by this PR
Fixes #<ISSUE_NUMBER_TO_BE_FILLED>
Problem
Vessels starting exactly at tissue boundaries fail to generate proper tube structures. Instead of creating a full vessel (~271 voxels), only a degenerate stub is created (~30 voxels).
Root Cause
calculate_vessel_samples()checked bounds before loop entry:When
position[i] == volume_dimensions[i](e.g., voxel 32 for 16mm at 0.5mm spacing), the condition32 < 32fails immediately, preventing vessel generation.Changes
VesselStructure.py
test_vesseltree.py
test_vessel_starting_at_boundary()regression testVerification
Before: Boundary vessel = 30 voxels (11% of expected)
After: Boundary vessel = 276 voxels (102% of expected, within random variation)
All existing tests pass. CodeQL security scan: 0 alerts.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.