Using Reformat module from Python

mschumaker
Fri, 25 May 2018 21:07:47 +0000
Development

I’m trying to use the Reformat module from a Python scripted module. I’m having trouble using the setSliceNormal and setWorldPosition methods. Looking at qSlicerReformatModuleWidget, both setSliceNormal and setWorldPosition have slots that take double*, and setSliceNormal has a public method that takes three arguments: setSliceNormal (double x, double y, double z). I tried to use it both ways, but I keep getting ValueError. Sample code:

reformatWidget = slicer.modules.reformat.widgetRepresentation()
slice = slicer.app.layoutManager().sliceWidget('Red')
sliceNode = slice.mrmlSliceNode()
reformatWidget.setEditedNode(sliceNode,"","")
reformatWidget.setSliceNormal(1.0,0,0)

The result is: “ValueError: Called setSliceNormal(double normal) -> void with wrong number of arguments: (1.0, 0.0, 0.0)”.
I also tried a list, tuple, and a ctypes double array.
Is there a way I can accomplish this with the Reformat module? Is there Python compatibility code that’s missing from this module?

Thanks

10 posts - 2 participants