In Slicer 5.4, where to check the reformatLogic's new method RotateSlice()'s parameters?

reformatLogic = slicer.modules.reformat.logic()
Is there a way to find out the function parameters of RotateSlice()?


>>> help(reformatLogic.RotateSlice)
Help on built-in function RotateSlice:

RotateSlice(...) method of vtkSlicerReformatModuleLogicPython.vtkSlicerReformatLogic instance
    RotateSlice(node:vtkMRMLSliceNode, axisIndex:int,
        rotationAngleDeg:float) -> None
    C++: static void RotateSlice(vtkMRMLSliceNode *node,
        int axisIndex, double rotationAngleDeg)
    
    Rotate slice along an axis (0 = horizontal, 1 = vertical, 2 =
    slice normal) Flip: axisIndex = 0 (vertical) or 1 (horizontal),
    rotationAngleDeg = 180. In-plane rotation: axisIndex = 2,
    rotationAngleDeg > 0 for clockwise.
1 Like

Thanks for the help. If I have calcualte the rotation from a matrix, how to calcualte the rotation?
matrix_4x4 = np.array([
[0.707, 0.0, 0.707, 0.2],
[0.707, 0,-0.707, 0.3],
[0, 1, 0.0, 0.4],
[0, 0, 0, 1]
])
sy = math.sqrt(R[0,0] * R[0,0] + R[1,0] * R[1,0])
singular = sy < 1e-6
if not singular :
x = math.atan2(R[2,1] , R[2,2])
y = math.atan2(-R[2,0], sy)
z = math.atan2(R[1,0], R[0,0])
else :
x = math.atan2(-R[1,2], R[1,1])
y = math.atan2(-R[2,0], sy)
z = 0
But it seems that it is not working. Does Slicer have a quaternion method to calcuatle the rotation? Thanks!