Пример #1
0
    def setElectrodesSorted(self):
        """

        :return: list of tuples containing electrodes' (radius, angle, x, y)
        """
        center = self.cochlea_center
        points = self.electrodes_list

        ## TRANSFORM INTO POLAR FORM WITH FUNCTION polar()
        ## CREATE A LIST OF TUPLES WITH radius,angle,x,y
        sorting = [utils.polar(center, point) + point for point in points]

        ## SORT POINTS BY RADIUS (max to min) // TUPLE SORTING WITH KEY: LAMBDA
        sorted_angles = sorted(sorting, key=lambda tup: (-tup[0], tup[1]))

        ## IF MORE THAN 12 ELECTRODES ARE DETECTED, THE ONE'S FARTHEST AWAY ARE REMOVED (Less likely to be a hit)
        if len(points) > 12:
            sorted_angles = sorted_angles[len(points) - 12:]

        ## IF LESS ELECTRODES ARE FOUND, EMPTY SLOTS ARE ADDED SO THAT THE CORRECT ITERATION IS KEEP!
        ## ONE ADDITIONAL ITERATION IS ADDED TO FLUSH THE BUFFER AT THE END.

        if len(points) < 12:
            sorted_angles += [(0, 0, 0, 0)] * (12 - len(points))

        # sorted_angles = sorted(sorted_angles, reverse=True, key=lambda tup: tup[0])
        # print("SORTED ANGLES", len(sorted_angles), "\n", sorted_angles)

        return sorted_angles
Пример #2
0
def roller(thetas, rhos, radius):
    # Clipper works only with integers, scaling needed
    p = cartesian(thetas, rhos)
    scale = 1 / (rhos.max() *
                 (1 - np.cos(np.pi / thetas.shape[0])))  # very good
    p *= scale
    coords = p.astype(int)
    pco = pyclipper.PyclipperOffset()
    pco.AddPath(coords, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
    result = pco.Execute(-radius * scale)[0]
    p = polar(*zip(*result))
    p[1] /= scale
    return p
Пример #3
0
 def op(self):
     return polar((self.ox, self.oy))
Пример #4
0
 def yp(self):
     return polar((self.yx, self.yy))
Пример #5
0
 def xp(self):
     return polar((self.xx, self.xy))