Skip to content

Commit 397c682

Browse files
Skip bad geometry regions in virtual fit (OpenwaterHealth#147)
Instead of dividing by zero and generating nonsense, skip these regions.
1 parent d7776db commit 397c682

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/openlifu/virtual_fit.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,17 @@ def virtual_fit( # pylint: disable=E1121
157157

158158

159159
# Transducer axial axis: Parallel to plane_normal, but points towards rather than away from the origin.
160-
transducer_z = - np.sign(np.dot(plane_normal,point)) * plane_normal / np.linalg.norm(plane_normal)
160+
plane_normal_norm = np.linalg.norm(plane_normal)
161+
if plane_normal_norm < 1e-10:
162+
continue # Bad geometry at this location, so it's not a virtual fit candidate
163+
transducer_z = - np.sign(np.dot(plane_normal,point)) * plane_normal / plane_normal_norm
161164

162165
# Transducer elevational axis: Phi-hat, but then with its component along transducer_z eliminated. This orients the transducer "up" if this were forehead, for example.
163166
transducer_y = phi_hat - np.dot(phi_hat, transducer_z) * transducer_z
164-
transducer_y = transducer_y / np.linalg.norm(transducer_y)
167+
transducer_y_norm = np.linalg.norm(transducer_y)
168+
if transducer_y_norm < 1e-10:
169+
continue # Bad geometry at this location, so it's not a virtual fit candidate
170+
transducer_y = transducer_y / transducer_y_norm
165171

166172
# Transducer lateral axis, here simply the only remaining choice to keep it a left handed coordinate system
167173
# (ASL is left-handed, so the transducer axes must be left-handed to make for an orientation-preserving transducer transform)

0 commit comments

Comments
 (0)