How to reset the size of one slice to make it display maximum

Operating system: Win10
Slicer version:4.11.0
Expected behavior:
Actual behavior:

I want to maximum slice to make them fit the size of their viewer box by a python script.

I found a method: slicer.util.resetSliceViews(),

But it can’t work well. Is there any other method to do that?

Thank you very much!

slicer.util.resetSliceViews() works well for me. What did you expect the method will do? What happened instead?

Hello lassoan,

It’s hard to express.
I just want to reset the size of the image in each widget to make them display maximum.
I call this function while one button was pressed.

so How can I make it work?

Thank you for your help~

Please post a screenshot of what you see and mark on it what/where would like to be different.

Hello Iassoan,

I want to maximum slice in each widget.
From
image
to
image
but don’t want to reset slicer offset.

Thank you very much.

If you don’t want to reset the offset, but want to change the zoom, right-clicking and dragging up and down will allow you to zoom in or out to any degree you want. If you are concerned with keeping multiple slices in sync with one another in terms of relative physical scaling, linking the slices together (making the rings just below the pressed push pin toggle to linked rather than unlinked) and then changing the zoom on any of the slices will cause their scaling to sync. Generally I find those two controls cover most of my use cases well enough. If I want the image to be exactly filling the slice, then I click the center button and then scroll the offset back to where I want to be, either by spinning the scroll wheel or by holding the shift key down and moving the cursor (no click) to the region I want to focus on in another slice. Holding the shift key down centers all of the slices on the point your cursor is over (if the meaning of that isn’t clear, just give it a try, it is easier to understand in action that it is to describe it).

Hello mikebind,

Thank you for your reply.
In fact, I want to maximize the view by python code.

In that case, you might find this code from the script repository helpful: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Set_slice_position_and_orientation_from_3_markup_fiducials

Hello mikebind,

Thank you very much, I will try it~