How to use the batchgenerators.augmentations.utils.create_matrix_rotation_z_3d function in batchgenerators

To help you get started, we’ve selected a few batchgenerators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MIC-DKFZ / TractSeg / tractseg / data / spatial_transform_peaks.py View on Github external
def rotate_peaks(peaks, angle_x, angle_y, angle_z):
        rot_matrix = np.identity(3)
        rot_matrix = create_matrix_rotation_x_3d(angle_x, rot_matrix)
        rot_matrix = create_matrix_rotation_y_3d(angle_y, rot_matrix)
        rot_matrix = create_matrix_rotation_z_3d(angle_z, rot_matrix)
        # rotate clockwise -> wrong
        # peaks_rot = np.dot(peaks.reshape(3, -1).transpose(), rot_matrix).transpose().reshape(peaks.shape)
        # rotate counterclockwise -> this is correct
        peaks_rot = np.dot(rot_matrix, peaks.reshape(3, -1)).reshape(peaks.shape)
        return peaks_rot
github MIC-DKFZ / TractSeg / tractseg / data / spatial_transform_peaks.py View on Github external
def rotate_tensors(peaks, angle_x, angle_y, angle_z):
        rot_matrix = np.identity(3)
        rot_matrix = create_matrix_rotation_x_3d(angle_x, rot_matrix)
        rot_matrix = create_matrix_rotation_y_3d(angle_y, rot_matrix)
        rot_matrix = create_matrix_rotation_z_3d(angle_z, rot_matrix)

        peaks = peak_utils.flat_tensor_to_matrix_tensor(peaks)  # (x, y, 3, 3)
        # rotate clockwise -> wrong
        # peaks_rot = rot_matrix.T @ peaks @ rot_matrix  # (x, y, 3, 3)
        # rotate counterclockwise -> this is correct
        peaks_rot = rot_matrix @ peaks @ rot_matrix.T  # (x, y, 3, 3)
        peaks_rot = peak_utils.matrix_tensor_to_flat_tensor(peaks_rot)
        return peaks_rot