@staticmethod
    def convert_vtk_matrix_to_list(matrix):
        """ Convert a vtk matrix object into a list
        :param matrix: vtkMatrix4x4 or vtkMatrix3x3
        :return: list of elements with the same dimensions
        """
        if isinstance(matrix, type(vtk.vtkMatrix4x4())):
            dim = 4
        elif isinstance(matrix, type(vtk.vtkMatrix3x3())):
            dim = 3
        else:
            raise Exception("Type not allowed")
        threshold = 0.00000000000001    # Threshold for rounding
        result = []
        for i in range(dim):
            row = []
            for j in range(dim):
                n = matrix.GetElement(i, j)
                if abs(n) < threshold:
                    n = 0
                row.append(n)
            result.append(row)
        return result

    #########
    # OTHER FUNCTIONS
dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/CIP_Common/CIP/logic/Util.py/Util.convert_vtk_matrix_to_list/original