Skeleton, measuring a curve length

Operating system: Ubuntu 16
Slicer version: 4.8
Expected behavior: getting an output
Actual behavior: infinite loop

Dear all,
I have few questions related automatic measurement the length of an object in Slicer. The object is already segmented out and saves as a label. This object has a curvy shape so Ruler tool does not work.
Here are what I already tried:

  • I tried “Extract Skeleton” module with different parameters but it goes on infinite loop. Why I get such behavior? in case it works, how can I compute the length as the output is just number of points that already decided by the user?
  • I tried “BinaryThinningImageFilter”, it works and I get a curve from the object. How can I measure this curve length?


You could use: CurveMaker (since the Extension Manager)

1 Like

Another (less precise) option is that if you place fiducials close together
along the length of a curve, you can get the summed linear distance between
all the highlighted fiducials in the Markups module by right clicking in
the table.


1 Like

Many thanks for the info. Actually, I am trying to automate things here. Here is what I tried and it works so far.

First I apply “BinaryThinningImageFilter” on the label then I apply “Extract Skeleton”.
With this, I get a nice list of points that represent my curve in a text file. What I need to do now is to accumulate the distance between all these points. If there is already a python script for this, I appreciate sharing it. If not, I will try to write it and share it with everyone.
I guess it will be something like (please correct me if I am wrong):

  • P1 = the first point in the text file
  • P1 =IJK2RAS(P1)
  • D = 0
  • for all remaining points p
    P2 = p
    P2 =IJK2RAS(P2)
    D = D + dist(P1,P2)


Here is the script:

    import numpy as np
    inputFileName    = "CurveLength.txt"
    print("================= Start Process =====================")             
    # Get GetIJKToRASMatrix from the input volume
    mFid     = self.inputSelector.currentNode() # this is a slicer.qMRMLNodeComboBox()
    Distance = 0   #  curve length in mm
    i= 0                #  counter
    f = open(inputFileName,'r')
    for line in f:       
        i = i + 1 
        lineDig=[int(s) for s in line.split() if s.isdigit()] 
        Pijk = [lineDig[1],lineDig[2],lineDig[3], 1]
        Pras = mRAS.MultiplyDoublePoint(Pijk)
        if (i>1):
           P2x= Pras[0] ; P2y= Pras[1] ; P2z= Pras[2] ;  
           Distance = Distance + np.sqrt((P2x-P1x)**2 +  (P2y-P1y)**2 + (P2z-P1z)**2)                  
           P1x= Pras[0] ; P1y= Pras[1] ; P1z= Pras[2] ;  
           P1x= Pras[0] ; P1y= Pras[1] ; P1z= Pras[2] ;  

Still one problem. I get a length different from the one I get manually using the fiducial. Am I missing somethng?

I found out the points generated by the text files are not all the points generated by the skeleton filter, please check the images. The fiducial points represent the points from the text file. Any suggestion to correct this?


Have you enabled “Do not prune branches” option in “Extract skeleton” module?

What does the e.g “0.015 mm-1” in measurement of curvature in Markup? does it mean the redius of curvature is 1000/15 mm?

The value that Slicer computes is the curvature of a curve. You can look up the exact definition I. Wikipedia, but in short, curvature is 1/R where R is the radius of the circle that best approximates the curve at that point. For a circle that has a radius of 10 mm the curvature of every point is 0.1 and the unit is 1/mm.