def test_shift_points5(self): data = { 0: gp.Point([3, 0]), 1: gp.Point([3, 2]), 2: gp.Point([3, 4]), 3: gp.Point([3, 6]), 4: gp.Point([3, 8]) } spec = gp.PointsSpec(gp.Roi(offset=(0, 0), shape=(15, 10))) points = gp.Points(data, spec) request_roi = gp.Roi(offset=(3, 0), shape=(9, 10)) shift_array = np.array([[3, 0], [-3, 0], [0, 0], [-3, 0], [3, 0]], dtype=int) lcm_voxel_size = gp.Coordinate((3, 2)) shifted_data = { 0: gp.Point([6, 0]), 2: gp.Point([3, 4]), 4: gp.Point([6, 8]) } result = gp.ShiftAugment.shift_points(points, request_roi, shift_array, shift_axis=1, lcm_voxel_size=lcm_voxel_size) # print("test 4", result.data, shifted_data) self.assertTrue(self.points_equal(result.data, shifted_data)) self.assertTrue(result.spec == gp.PointsSpec(request_roi))
def process(self, batch, request): srcpoints, trgpoints = self.__extract_synapses(batch, request) points_spec = self.spec[self.srcpoints].copy() points_spec.roi = request[self.srcpoints].roi batch.points[self.srcpoints] = gp.Points(data=srcpoints, spec=points_spec) batch.points[self.trgpoints] = gp.Points(data=trgpoints, spec=points_spec.copy()) # restore requested arrays if self.m_array in request: batch.arrays[self.m_array] = batch.arrays[self.m_array].crop( request[self.m_array].roi) if self.d_array in request: batch.arrays[self.d_array] = batch.arrays[self.d_array].crop( request[self.d_array].roi)
def test_shift_points1(self): data = {1: gp.Point([0, 1])} spec = gp.PointsSpec(gp.Roi(offset=(0, 0), shape=(5, 5))) points = gp.Points(data, spec) request_roi = gp.Roi(offset=(0, 1), shape=(5, 3)) shift_array = np.array([[0, -1], [0, -1], [0, 0], [0, 0], [0, 1]], dtype=int) lcm_voxel_size = gp.Coordinate((1, 1)) shifted_points = gp.Points({}, gp.PointsSpec(request_roi)) result = gp.ShiftAugment.shift_points(points, request_roi, shift_array, shift_axis=0, lcm_voxel_size=lcm_voxel_size) # print(result) self.assertTrue(self.points_equal(result.data, shifted_points.data)) self.assertTrue(result.spec == gp.PointsSpec(request_roi))