Skip to content

Feature/c5/pr over truncated domain y watertight falsealarm conti01 rebased#7

Open
tai271828 wants to merge 4 commits into
gzavo:devfrom
tai271828:feature/c5/pr-over-truncated-domain-Y-watertight-falsealarm-conti01-rebased
Open

Feature/c5/pr over truncated domain y watertight falsealarm conti01 rebased#7
tai271828 wants to merge 4 commits into
gzavo:devfrom
tai271828:feature/c5/pr-over-truncated-domain-Y-watertight-falsealarm-conti01-rebased

Conversation

@tai271828

@tai271828 tai271828 commented Apr 30, 2026

Copy link
Copy Markdown

The domain along the Y-axis could occasionally be over-truncated. This pull request detects the condition and fixes it by padding the Y dimension of the voxel domain with an additional voxel layer.

Resolves: #6

Some bonus minor (style/refactoring) commits are shipped in this pull request too. See the inline comments.

Verification

The refactoring keeps the same business logic based on the below
reasons:

PEP 8: "For sequences, (strings, lists, tuples), use the fact that empty
sequences are false"
PEP 428: make paths stay portable across OSes.
PEP 498: "F-strings provide a concise, readable way to include the value
of Python expressions inside strings."
The domain along the Y-axis could occasionally be over-truncated. This commit
detects the condition and fixes it by padding the Y dimension of the voxel
domain with an additional voxel layer.

Resolves: gzavo#6
Comment thread preprocessor/main.py
isInRange = True
for i in range(3):
isInRange = (isInRange and inRange(value3D[i], rangeValue3D[i], distance) )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial update: removing trailing spaces by linter automatically.

Comment thread preprocessor/main.py
haveStent = True


stent_folder = confData.get("stent_folder", "")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is not just more pythonic, but also prevents from the error caused by missing stentGeomFile on purpose. Sometimes we don't want to input stent files.

Comment thread preprocessor/slice.py
# Fix the issue of water tight false alarm due to over-truncated domain along Y
LHS_inequality = (vox_scale*ds[1]) % 1
RHS_inequality = ds[1]/ds[0]*((vox_scale*ds[0]) % 1)
if LHS_inequality > RHS_inequality:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core part of the change from this PR. See issue #6 for the elaboration of this inequality.

Comment thread preprocessor/slice.py
print(f"Warning: Truncation bug detected (See Issue: #6): Inequality LHS {LHS_inequality} is larger than RHS {RHS_inequality}. It means potential truncation bug!!")
final_scaled_bound_y = scale[1] * ds[1]
print(f"Current scaled bound along Y is {final_scaled_bound_y}, while domain[1] is {domain[1]}")
if final_scaled_bound_y > domain[1]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only apply the fix for Issue #6 when necessary so we can keep backward-compatibility.

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.

1 participant