def find_init_pts(init_coords, dist=25, min_angle=10): n_p = init_coords.shape[0] As = np.zeros(n_p) for k in range(n_p): p0 = init_coords[k, :] p1, p2 = find_neighbors(p0, init_coords, 2) if (norm(p1 - p0) < dist) and (norm(p2 - p0) < dist): As[k] = angle(p1 - p0, p2 - p0) elif (sum(p1 == p0) == 3) or (sum(p2 == p0) == 3): As[k] = 400 else: As[k] = 500 As[np.where(np.isnan(As))] = np.inf if np.abs(As - 90).min() < min_angle: p0 = init_coords[np.abs(As - 90).argmin(), :] p1, p2 = find_neighbors(p0, init_coords, 2) return [p0, p1, p2] else: return -1
def find_init_pts(init_coords, dist=25, min_angle=10): n_p = init_coords.shape[0] As = np.zeros(n_p) for k in range(n_p): p0 = init_coords[k, :] p1, p2 = find_neighbors(p0, init_coords, 2) if (norm(p1 - p0) < dist) and (norm(p2 - p0) < dist): As[k] = angle(p1 - p0, p2 - p0) elif (sum(p1 == p0) == 3) or (sum(p2 == p0) == 3): As[k] = 400 else: As[k] = 500 As[np.where(np.isnan(As))]=np.inf if np.abs(As - 90).min() < min_angle: p0 = init_coords[np.abs(As - 90).argmin(), :] p1, p2 = find_neighbors(p0, init_coords, 2) return [p0, p1, p2] else: return -1
def find_init_angles(all_elecs, mindist=10, maxdist=25): ''' Takes the set of all electrodes and some constraint parameters. Returns angle for each electrode's best match as Nx1 vector''' n = all_elecs.shape[0] angles = np.zeros(n) dists = np.zeros((n, 2)) actual_points = np.zeros((n, 3, 3)) for k in xrange(n): p0 = all_elecs[k, :] p1, p2 = find_neighbors(p0, all_elecs, 2) if ((mindist < norm(p1 - p0) < maxdist) and (mindist < norm(p2 - p0) < maxdist)): angles[k] = angle(p1 - p0, p2 - p0) dists[k] = norm(p1 - p0), norm(p2 - p0) actual_points[k] = (p0, p1, p2) else: angles[k] = np.inf dists[k] = (np.inf, np.inf) actual_points[k] = (p0, p1, p2) return angles, dists, actual_points
def find_init_angles(all_elecs, mindist=10, maxdist=25): ''' Takes the set of all electrodes and some constraint parameters. Returns angle for each electrode's best match as Nx1 vector''' n = all_elecs.shape[0] angles = np.zeros(n) dists = np.zeros((n,2)) actual_points = np.zeros((n,3,3)) for k in xrange(n): p0 = all_elecs[k,:] p1, p2 = find_neighbors(p0, all_elecs, 2) if ((mindist < norm(p1-p0) < maxdist) and (mindist < norm(p2-p0) < maxdist)): angles[k] = angle(p1-p0, p2-p0) dists[k] = norm(p1-p0), norm(p2-p0) actual_points[k] = (p0,p1,p2) else: angles[k] = np.inf dists[k] = (np.inf, np.inf) actual_points[k] = (p0,p1,p2) return angles, dists, actual_points