add_body_envelope: add step-8 table detection to remove the CT table - #41
Conversation
The find-air-invert steps can leak the air-density CT table into the body (air trapped between patient and table is a separate component from the exterior air, so it reads as "not air" -> body). Step 8 detects it as the largest connected component of body voxels that are actually air (CT < hu_threshold) and drops it when that component is >= table_frac_thresh (default 0.05) of the body. Since the seg labels the lungs, no legitimate air region is table-sized (a table is ~16-28% of body vs <0.3% clean). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…hu_threshold) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR adds a step-8 "table detection" safety net to
Confidence Score: 5/5Safe to merge — the change is a targeted safety net that only fires when a large air-density connected component is found inside the body mask, and it correctly scopes removal to unlabeled body voxels so organ labels are never touched. The detection logic is well-bounded: it operates on No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "ruff format" | Re-trigger Greptile |
…eps 1&4) + log when table safety net fires Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The find-air-invert steps can leak the air-density CT table into the body (air trapped between patient and table is a separate component from the exterior air, so it reads as "not air" -> body). Step 8 detects it as the largest connected component of body voxels that are actually air (CT < hu_threshold) and drops it when that component is >= table_frac_thresh (default 0.05) of the body. Since the seg labels the lungs, no legitimate air region is table-sized (a table is ~16-28% of body vs <0.3% clean).