Skip to content

Commit 2a7ac4a

Browse files
committed
slicer-fill: per-vessel diameter boundary (stop stray fat children at bends)
The vessel slicer-fill swept a solid core along a single straight PCA axis per component, with each ring's radius = MEDIAN perpendicular distance clamped to a single global RMAX (~34 mm, aorta scale). At a strong bend the straight axis cannot follow the tube: both arms fall in one axial bin, the bin centroid lands between them (outside the limb), and the median perp-distance balloons — and the global RMAX let a finger artery swell to aorta caliber. Those are the "stray fat children branching off outside the limbs". Fix = per-vessel diameter boundary: - per-bin radius now reads a LOW percentile (PCTL=0.30, near-wall) instead of the median, so a bend bin sharing two arms no longer reports ~half-the-gap. - every ring is clamped to this vessel's OWN caliber (robust median of bin radii) × CAP=2.0, then RMAX. A capillary stays a capillary through its bends; the aorta still reaches RMAX. Validated on a synthetic 1 mm L-bent vessel: max ring 2.6× true radius (was up to 20× under the global cap). Bake-pipeline change — takes effect on next body re-bake. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RhpwkHGgia2TuDFvdnuQdE
1 parent ef6916e commit 2a7ac4a

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

crates/osint-bake/tools/fill_body_soa.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
RMAX = 0.020 # ABSOLUTE diameter boundary: max cross-section radius in normalized
3636
# [-1,1] body units (~34 mm dia — covers the aorta; clamps balloons).
3737
RMIN = 0.0008 # floor so capillaries still get a visible core
38+
CAP = 2.0 # PER-VESSEL diameter boundary: a ring may not exceed this vessel's own
39+
# caliber × CAP. RMAX alone lets a finger artery balloon to aorta size at
40+
# a bend; this keeps a capillary a capillary through its bends.
41+
PCTL = 0.30 # per-bin radius percentile (NOT the median): at a strong bend two arms
42+
# share one axial bin and the median perp-distance is ~half the gap (a
43+
# balloon); the low percentile picks the near wall = the true radius.
3844
CELL = 0.015 # connected-component grid cell (~13 mm). A continuous vessel keeps
3945
# adjacent cells occupied (26-neighbour reach ~26 mm bridges sampling
4046
# gaps); blobs farther apart (hands ~300 mm, thigh→toe >100 mm) split.
@@ -112,7 +118,9 @@ def fill_one(pts, crow, fpx, fnx, frow, ftri, base):
112118
for p, t in zip(pts, ts):
113119
b = min(BINS-1, int((t - tmin)/span*BINS))
114120
binned[b].append(p)
115-
rings = []
121+
# pass 1: per-bin centroid + a LOW-percentile perpendicular radius (resists the bend
122+
# failure mode where two arms share one axial bin and the median balloons).
123+
raw = []
116124
for bp in binned:
117125
if len(bp) < 1:
118126
continue
@@ -125,10 +133,17 @@ def fill_one(pts, crow, fpx, fnx, frow, ftri, base):
125133
perp2 = (dx*dx + dy*dy + dz*dz) - axial*axial
126134
dists.append(math.sqrt(perp2) if perp2 > 0.0 else 0.0)
127135
dists.sort()
128-
rad = min(RMAX, max(RMIN, dists[len(dists)//2] * CORE))
129-
rings.append((cen, rad))
130-
if len(rings) < 2:
136+
raw.append((cen, dists[int(len(dists)*PCTL)] * CORE))
137+
if len(raw) < 2:
131138
return 0
139+
# pass 2: PER-VESSEL diameter boundary. Clamp every ring to this vessel's OWN caliber
140+
# (robust median of the bin radii) × CAP, then the absolute RMAX. A capillary stays a
141+
# capillary through its bends; the aorta still reaches RMAX. This is what stops the
142+
# "stray fat children" — a ballooned bend bin can no longer exceed the vessel's caliber.
143+
rr = sorted(r for (_, r) in raw if r > RMIN)
144+
caliber = rr[len(rr)//2] if rr else RMIN
145+
cap = min(RMAX, caliber * CAP)
146+
rings = [(cen, min(cap, max(RMIN, r))) for (cen, r) in raw]
132147
ring_start = []
133148
for (cen, rad) in rings:
134149
ring_start.append(base + len(fpx)//3)

0 commit comments

Comments
 (0)