Use of python interactor and already built-in functions for workflow efficiency

Hi everyone,
I have achieved what I want to do with slicer, which was segment a vessel, compute centerline, extract CE diameter, and compute the maximum Feret diameter of that cross-section (I want to do this for the whole vessel with a set spacing between each cross-section).
image
Segmentation, centerline computation and CE diameter computation were staightforward with Slicer. However, for the maximum feret diameter, I saw the cross section for a single slice in my Subject hierarchy tree, and exported the .vtk file, loaded it into MATLAB, calculated the furthest distance between all coordianates and I had it.

However, I want to do this for the whole vessel instead of only 1 cross-section, as well as for a couple more DICOM data sets. I am sure this is all programmed into the software, I’m just not sure how to do it / access these functions.

To do this I have two questions:

  1. As mentioned, I currently manually calculated the feret diameter of the plane outside of Slicer, but I am pretty sure I can do this within the software. When looking through the code of e.g. CrossSectionAnalysis.py I see lines like (lines 1107-1131):
# Place a plane perpendicular to the centerline
    plane = vtk.vtkPlane()
    plane.SetOrigin(center)
    plane.SetNormal(normal)

# Cut through the closed surface and get the points of the contour.
    planeCut = vtk.vtkCutter()
    planeCut.SetInputData(closedSurfacePolyData)
    planeCut.SetCutFunction(plane)
    planeCut.Update()
    planePoints = vtk.vtkPoints()
    planePoints = planeCut.GetOutput().GetPoints()
    # 

So it looks like there are also built-in functions sort of doing what I want, the problem is that I dont really know how to access those functions or use the python interactor.

  1. If this is not possible, can I then at least quickly export all the .vtk cross sections with a particular spacing. So that I can then do the computation myself with MATLAB?

Thanks a lot guys.
Cheers,
Jack

If you are somewhat familiar with Python (and preferably with VTK library, and if you want to create GUI then also Qt) then the PerkLab bootcamp Slicer programming tutorial is a good way to learn about how to use Python scripting in Slicer.

After that you should be ready to modify the CrossSectionAnalysis.py script to allow plotting not just MIS diameter, CE diameter, and Cross-section area but also Feret’s diameter.

1 Like