Commit 8d24891
Fix [0,0,0] "bullet hole" artefact in spherical barycentric resampling
barycentric_spherical_map() could leave a few target vertices unmapped,
collapsing their interpolated value to exactly [0, 0, 0]. Two causes:
1. Search neighbourhood too small. Only the `neighborhood` (=10) nearest
source-triangle centroids were searched per target point. Registration
(e.g. mris_register) can distort triangle areas by >200x on the sphere,
pushing a target point's true containing triangle past the nearest 10
centroids (observed rank 11-12), so it was never found. Default bumped to
30 (negligible cost) so the correct triangle is found and exact barycentric
weights are used.
2. Fallback guard tested the wrong mask. The "assign unmatched points to the
nearest face" fallback was guarded by `np.count_nonzero(remaining)`, where
`remaining` is the leftover mask from the final loop iteration, not "any
points still unassigned". When the last iteration matched nothing, the
fallback was skipped and those points kept face == -1 with zero weights.
Downstream, `source.faces[-1]` negative-indexes the last face and the zero
weights yield a sample of exactly [0, 0, 0]. Now guard on the actual
`intersecting_faces == -1` mask so the fallback always runs.
Effect: a vertex teleported to the origin, with its 1-ring neighbours stretched
up to ~32 mm. Reproduced deterministically on dHCP white-matter surfaces
resampled to a 245k-vertex canonical topology; 56/1121 subjects had >=1 such
hole in the left white surface alone. With the fix, output is unchanged for all
correctly-mapped vertices and the holes disappear.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c6cddec commit 8d24891
1 file changed
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| |||
0 commit comments