Skip to content

Commit 1a53ba3

Browse files
authored
Fix neuron orientation bug
If the original neuron orientation is parallel to the desired neuron orientation, the code didn't work properly. The issue is fixed.
1 parent 7b11566 commit 1a53ba3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Model_Generation/TMS_package/E-Field_Coupling/couple_script.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ function couple_script(paramfile)
4545
theta = acos(v1*v2'); % Angle between v1 and v2
4646
axis_rot = cross(v1,v2)/norm(cross(v1,v2)); % axis around which v1 should turn to align with v2
4747

48+
% in case v1 and v2 are parallel use an orthagonal vector
49+
if any(isnan(axis_rot))
50+
axis_rot = null(v1);
51+
axis_rot = axis_rot(:,1)';
52+
end
53+
4854
% A skew symmetric representation of the normalized axis
4955
axis_skewed = [0 -axis_rot(3) axis_rot(2); axis_rot(3) 0 -axis_rot(1); -axis_rot(2) axis_rot(1) 0];
5056

0 commit comments

Comments
 (0)