Volume reslice driver crashes Slicer

Hi there!
I’m trying to use Volume reslice driver from python script ( since from console it works fine):

  def onTransformImageClicked(self):
    logic = ModuleLogic()
    result = logic.transformationImage()
    driver = slicer.vtkSlicerVolumeResliceDriverLogic()  # .MODE_TRANSVERSE = 6
    layoutManager = slicer.app.layoutManager()
    redView = layoutManager.layoutLogic().GetViewNodes().GetItemAsObject(0)
    driver.SetModeForSlice(6, redView)
    driver.SetDriverForSlice('vtkMRMLScalarVolumeNode1', redView)

    qt.QMessageBox.information(slicer.util.mainWindow(), 'Slicer Python', result)

And It just crashes without any error. I want to change following params (see image)


Any ideas what is wrong here?

Just figured it out, forgot to set scene before, now it doesn’t crush anymore. But still, small error will be nicer than a crash:)

    driver = slicer.vtkSlicerVolumeResliceDriverLogic()  # .MODE_TRANSVERSE = 6
    layoutManager = slicer.app.layoutManager()
    redView = layoutManager.layoutLogic().GetViewNodes().GetItemAsObject(0)
    driver.SetMRMLScene(slicer.mrmlScene) 
    driver.SetModeForSlice(6, redView)
    driver.SetDriverForSlice('vtkMRMLScalarVolumeNode1', redView)

For loadable modules, module logic is instantiated by the application and there should be only one instance. So, instead of creating a new module logic, use the existing one:

driver = slicer.modules.volumereslicedriver.logic()
1 Like