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:
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?
I used (1,0,0) in the example, but I would like to be able to set a normal vector that’s off of the principal axes. Also a centre point of the rotation that’s not the centre of the image. I didn’t see a straightforward way to do that from vtkMRMLSliceNode.
Slice position and orientation are specified by SliceToRAS matrix. You can get it using GetSliceToRAS method and update it. You can also use SetSliceToRASByNTP to set slice orientation by slice normal and X axis and position.
Thank you, that’s exactly the method I was hoping to find. I missed it when I was looking at the API docs. Looking at the documentation for it, and at the code, I’m still unclear what the final parameter, “Orientation”, should be set to. In the switch statement in the code, it refers to the cases 0,1,2 as para-Axial, para-Sagittal, and para-Coronal, respectively. Does that mean that if the view I want is close to axial, I should set Orientation to 0?
SetSliceToRASByNTP’s orientation parameter can be used to generate orthogonal views corresponding to an axial view. It just saves you from figuring out how to change the normal vector for orthogonal views.
Ok. My concern is that I don’t see a way that it will set the elements of the SliceToRAS matrix if I don’t supply an Orientation value of 0, 1, or 2. I couldn’t tell if that meant I was limited to the standard orthogonal views.