Slice rotation in viewport when using SetSliceToRASByNTP in python

hey guys,
I have been trying to debug this issue to no avail and I’m hoping someone could help me out or point me in some direction. Please refer to my stackoverflow post, feel free to answer here or there. If solution or discussion occurs here I can post it in stackoverflow.

Thanks!

Determining a smoothly changing curve normal direction is not a trivial task. In recent Slicer versions, we introduced curve node, which can provide curve tangent and normal using Frenet-Serret frame.

Here is a complete example of computing a panoramic X-ray from a cone-beam dental CT. Just a demonstration of how an image can be resampled along a curve - the code is not optimized for performance or quality and distance along curve is not scaled (we simply used all point indices instead of retrieving point indices based on desired distance along curve).

Computed panoramic X-ray:

1 Like

Hey,
Really cool algorithm. I am trying to implement it but I am running into this error

Traceback (most recent call last):
File “C:/Users/talmazovg/SlicerDev/SlicerPano/SlicerPano/SlicerPano/SlicerPano.py”, line 234, in onCreatePathButtonClicked
test.construct_pano(self.path)
File “C:/Users/talmazovg/SlicerDev/SlicerPano/SlicerPano/SlicerPano/SlicerPano.py”, line 604, in construct_pano
curveNode.CreateDefaultDisplayNodes()
AttributeError: ‘NoneType’ object has no attribute ‘CreateDefaultDisplayNodes’

invoking curveNode = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLMarkupsCurveNode’) return NoneType object.

I am new to slicer programming so I apologize, am I not importing a class or something?
Using Slicer 4.10.2
Thanks!

“vtkMRMLMarkupsCurveNode” is only available in the Slicer nightly (4.11) which is why it is not working for you in Slicer 4.10.2

2 Likes

Based on my original question, how is it that the 3D world view retains proper orientation of the plane while the node view is flipped? Please refer to screenshot.
Is there some way I can anchor the plane to be parallel in the axial direction?

You can arbitrarily rotate the slice view content in the image plane or flip it along any axis, the physical position of the slice will still remain the same.

In your script, you computed the normal direction of the curve inconsistently along the curve (you flipped the normal direction along the curve), that’s why you see a flip in the slice view. If the curve is quasi planar then you can use the curve normal computation method implemented that is implemented in endoscopy module as is (that uses the normal of the plane fit to the curve; a reslicing transform is written to the scene that you can use in Volume reslice driver - see this video for step-by-step instructions). For arbitrary curve shapes, you can use Frenet-Serret frame (that is implemented in recent Slicer preview versions in curves, see my script above for a complete working example).

We now added a module that automates the reformat and creates curved planar reformatted volumes: How to implement CPR (curved plannar reconstruction) from centerline?

A post was split to a new topic: Create curve from many input points