-
Notifications
You must be signed in to change notification settings - Fork 35
Add body envelope multi table #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Can-Zhao
merged 12 commits into
NVIDIA-Medtech:main
from
Can-Zhao:add-body-envelope-multi-table
Jul 20, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0086654
add_body_envelope: add step-8 table detection to remove the CT table
Can-Zhao b17113c
add_body_envelope: rename body_hu -> air_hu (it's the air mask, CT < …
Can-Zhao 6904008
add_body_envelope: address review — np.asarray wrap (consistent w/ st…
Can-Zhao 3f85f69
ruff format
Can-Zhao b7d27d3
Merge branch 'NVIDIA-Medtech:main' into main
Can-Zhao 18b645f
add_body_envelope: remove ALL table-sized air-in-body components in s…
Can-Zhao 4c1a9ec
add_body_envelope: document lung-segmentation requirement
Can-Zhao 828dd07
add_body_envelope: add seg_has_lung flag to gate step-8 table removal
Can-Zhao e3948a6
add_body_envelope: drop redundant .. important:: note (covered by seg…
Can-Zhao 53cb3b7
add_body_envelope: gate whole step-8 on seg_has_lung; move scipy.ndim…
Can-Zhao bac2948
add_body_envelope: simplify seg_has_lung docstring wording
Can-Zhao 15532ab
ruff format: collapse a pre-split log string in infer_image_from_mask…
Can-Zhao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scipy.ndimage.labeluses 6-connectivity (face-adjacent only) by default in 3D, becausestructure=Noneresolves togenerate_binary_structure(rank, 1). The originalget_largest_connected_component_mask(connectivity=None)calledskimage.measure.label(connectivity=None), which in 3D defaults to full 26-connectivity (all face + edge + corner neighbors). If a table blob is connected only diagonally — which can happen at typical CT voxel resolutions where the air pocket narrows to a single-voxel diagonal bridge — 6-connectivity will split it into separate components. Each piece could then fall belowtable_frac_threshand escape removal.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that means you need to tune table_frac_thresh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite — tuning the threshold doesn't fully solve it. The problem is that a single physical table blob can be split into an unpredictable number of pieces (2, 3, or more depending on scan resolution and patient geometry). You don't know the split factor in advance, so there's no safe threshold to tune to.
Worse, lowering
table_frac_threshto catch split pieces risks false positives: bowel gas, stomach air, or other small legitimate air-in-body pockets could exceed a lower threshold and get incorrectly removed.The direct fix is to match the original 26-connectivity behavior:
This makes
ndimage.labeluse face+edge+corner neighbors (same asskimage.measure.label(connectivity=None)in the original code), so a diagonally-bridged table stays as one component and the existingtable_frac_threshlogic works as intended.Tip: You can customize Greptile's behavior for this repo with
.greptile/rules.mdand.greptile/config.json.