Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion analytical_correct.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import parameters as params

import argparse
import warnings


def V(n):
Expand Down Expand Up @@ -103,8 +104,10 @@ def adjust_phi_angle(p):
rxy = ele_pos - proj_rxyz_rz
x = np.cross(p, dp_loc)
cos_phi = np.dot(rxy, x.T) / np.dot(np.linalg.norm(rxy, axis=1).reshape(len(rxy),1), np.linalg.norm(x, axis=1).reshape(1, len(x)))
if abs(cos_phi).max() - 1 > 1e-10:
warnings.warn("cos_phi out of [-1 - 1e-10, 1 + 1e-10]", RuntimeWarning)
cos_phi = np.nan_to_num(cos_phi)
phi_temp = np.arccos(cos_phi)
phi_temp = np.arccos(np.maximum(-1, np.minimum(1, cos_phi)))
phi = phi_temp
range_test = np.dot(rxy, p.T)
for i in range(len(r_ele)):
Expand Down Expand Up @@ -187,6 +190,12 @@ def compute_phi(s12, s23, s34, I):
I = 1.
n = np.arange(1, 100)

# test for NaN bug
src_pos = [-3.850000e+00, 6.668396e+00, 0.05]
snk_pos = [-3.850000e+00, 6.668396e+00, -0.05]
s12, s23, s34 = conductivity(params.sigma_skull20)
assert not np.isnan(compute_phi(s12, s23, s34, I)).any()

for dipole in params.dipole_list:
print('Now computing for dipole: ', dipole['name'])
src_pos = dipole['src_pos']
Expand Down
2 changes: 1 addition & 1 deletion figure3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const='Sri98_no_bn1',
default='Sri98',
dest='sri98',
help='a path to the result directory')
help='use Analytical_Sri98_no_bn1*.npz files')

args = parser.parse_args()

Expand Down
2 changes: 1 addition & 1 deletion figure4.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
const='Sri98_no_bn1',
default='Sri98',
dest='sri98',
help='a path to the result directory')
help='use Analytical_Sri98_no_bn1*.npz files')

args = parser.parse_args()

Expand Down