Rotation&zooming

Hello,

How can I modify or call the rotation of an image on the python interactor on 3dslicer ?

Is it possible to modify or edit zooming in and out of the image on python console ?

here’s a snippet to get the slice logic from the interface:

https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Manipulate_a_Slice_View

Once you have that you can call methods either on the sliceLogic [1] or you can get the sliceNode [2] and call methods like redLogic.GetSliceNode().SetFieldOfView(20,30,1) to change the zoom.

[1] http://apidocs.slicer.org/master/classvtkMRMLSliceLogic.html

[2] http://apidocs.slicer.org/master/classvtkMRMLSliceNode.html

Hello,
I have tried redLogic.GetSliceNode().SetFieldOfView(20,30,1) in order to change the zoom, but it did not change anything. I was using the four up view, and the red window turned black when I used redlogic for some reason. How can I use it properly in order to change the zoom ?

This is what I get when I plug in

:

group__Slicer__QtModules

when I plug in redLogic.SetSliceOffset(10):

I presume that redlogic is controlling the shape of the image and the brightness at the same time one of the windows turned black, instead of controlling the zoom.

I have figured how it works thanks a lot. However, I do not know how to control the rotation of the image via python interactor ?

Thanks again!

I do not know how to control the rotation of the image via python interactor

Adjust SliceToRAS transform in the slice node. It is a homogeneous transform, so the top-left 3x3 matrix specifies the slice orientation (first column is slice X, second column is slice Y, third column is slice normal direction) and 4th column specifies slice position.

As you can see in the attached image whenever I try to execute any different numbers for the x,y and normal slices for the axial view, I do not get to zoom in or out, instead a black image. I believe the problem is I am zooming in a lot, however what I want to know how to control is to zoom in or out of the image itself only via python interactor.

instead I would like to control the zooming in the following mechanism which can be done by using the mouse. But, in my case I want to control the zooming mechanism into the image and out of the image like it can be seen on the following images on the 2D yellow image view.

23%20PM14%20PM

FieldOfView defines the zoom factor. Get the old value, multiply x and y components by a factor (e.g., by 1.1 to zoom out a bit), and set the resulting values as new FOV.

I tried the same thing you suggested, but the image disappeared and I could not bring it back.

1 Like

You’ve forgot to get the old FOV value (or at least the screenshot that you attached did not show how you got the old value).

How do I set the resulting values as new FOV ?

Use GetFieldOfView method to get current values, scale them, and set the new values using SetFieldOfView.