Beispiel #1
0
def find_closest_points_on_cylinder(elc1, elc2, threshold, output_fol,
                                    error_radius):
    (electrodes, names, hemis, threshold) = utils.load(
        op.join(output_fol, '{}_electrodes.pkl'.format(int(threshold))))
    elc_ind1, elc_ind2 = names.index(elc1), names.index(elc2)
    _, cylinder, _ = fect.points_in_cylinder(electrodes[elc_ind1],
                                             electrodes[elc_ind2], electrodes,
                                             error_radius)
    points_inside_cylinder, too_close_points, dists, dists_to_cylinder = \
        fect.find_group_between_pair(elc_ind1, elc_ind2, electrodes, error_radius, min_distance)
    fect.find_closest_points_on_cylinder(electrodes, points_inside_cylinder,
                                         cylinder)
Beispiel #2
0
def test4(ct_data):
    voxel1 = np.array([102, 99, 131])
    voxel2 = np.array([104, 102, 131])
    points = np.array(
        list(product(*[range(voxel1[k], voxel2[k] + 1) for k in range(3)])))
    inds, _, _ = fect.points_in_cylinder(voxel1,
                                         voxel2,
                                         points,
                                         1,
                                         metric='cityblock')
    path = points[inds]
    diffs = [pt2 - pt1 for pt1, pt2 in zip(path[:-1], path[1:])]
    path = path[[np.all(d >= 0) for d in diffs]]
    path_ct_data = [ct_data[tuple(p)] for p in path]
    print(path)
Beispiel #3
0
def calc_dist_on_cylinder(elc1, elc2, threshold, output_fol, error_radius):
    (electrodes, names, hemis, threshold) = utils.load(
        op.join(output_fol, '{}_electrodes.pkl'.format(int(threshold))))
    elc_ind1, elc_ind2 = names.index(elc1), names.index(elc2)
    groups, noise = utils.load(
        op.join(output_fol, '{}_groups.pkl'.format(int(threshold))))
    groups_mask = [(elc_ind1 in g) for g in groups]
    if sum(groups_mask) == 1:
        group = [g for g, m in zip(groups, groups_mask) if m][0]
        print('Electrodes belongs to {}-{}'.format(names[group[0]],
                                                   names[group[1]]))
    else:
        print('No group was found!')
        return
    _, cylinder, _ = fect.points_in_cylinder(electrodes[group[0]],
                                             electrodes[group[-1]], electrodes,
                                             error_radius)
    closest_points = fect.find_closest_points_on_cylinder(
        electrodes, [elc_ind1, elc_ind2], cylinder)
    dist = np.linalg.norm(closest_points[0] - closest_points[1])
    print(dist)