FOV, spacing match Volumes

Hi developers,

What is the python function to set the slice views as “FOV, spacing match Volumes” instead of “FOV, spacing match 2D” ?
Thank you,
Best

It controls how Slicer generates pixels of the slice that is shown in the 3D view. See more details here. Let us know if you need more details.

Hello,
Thank you for your answer. I know what is done, I just would like to know how can I automatically set this option with my own script in python ?
Thank you

How to find a Python function for any Slicer features:

  • Go to Slicer project repository on github
  • Enter text that you see on the GUI near the function that you want to use. In this case, enter "FOV, spacing match Volumes" (adding quotes around the text makes sure it finds that exact text)
  • Usually the text is found in a .ui file, in this case it is in qMRMLSliceControllerWidget.ui, open the file
  • Find the text in the page, and look up what is the name of the widget or action that it is associated with - in this case it is an action named actionSliceModelModeVolumes
  • Search for that widget or action name in the repository, you should find a source file(s) that use it. In this case it will is qMRMLSliceControllerWidget.cxx
  • Search for the action/widget name, and you’ll find what it does - in this case it calls setSliceModelModeVolumes method, which calls this->setSliceModelMode(vtkMRMLSliceNode::SliceResolutionMatchVolumes), which then calls d->MRMLSliceNode->SetSliceResolutionMode(mode)

This means that this action calls someSliceNode->SetSliceResolutionMode(vtkMRMLSliceNode::SliceResolutionMatchVolumes) in Python syntax it is someSliceNode.SetSliceResolutionMode(slicer.vtkMRMLSliceNode.SliceResolutionMatchVolumes). For example, for the red slice node this will be:

sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')
sliceNode.SetSliceResolutionMode(slicer.vtkMRMLSliceNode.SliceResolutionMatchVolumes)
3 Likes

Thank you so much for your help !