Slicer VMTK LevelSetSegmentation no Start

Hi all,
so filling out the basics:

Operating system: Ubuntu 20.04
Slicer version: 4.11.20210226

Expected behavior: Generating a LevelSetSegmentation of a bunch of coronaries.

Actual behavior: So I was able to install the VMTK Extension and also able to create a vesselness. However when I start to use the LevelSetSegmentation I can put seeds and stoppers and hit preview but then I cannot click on the Start button. Did I forget to do anything beforehand?

After Preview is completed, Start button should become available. Do you see an error in the Python console?

That’s the output of the python console:

Loading with imageIOName: GDCM
Traceback (most recent call last):
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 288, in onPreviewButtonClicked
self.start(True)
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 583, in start
for n in xrange(numberOfSliceNodes):
NameError: name ‘xrange’ is not defined
Traceback (most recent call last):
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 288, in onPreviewButtonClicked
self.start(True)
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 583, in start
for n in xrange(numberOfSliceNodes):
NameError: name ‘xrange’ is not defined
Traceback (most recent call last):
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 288, in onPreviewButtonClicked
self.start(True)
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 583, in start
for n in xrange(numberOfSliceNodes):
NameError: name ‘xrange’ is not defined
Traceback (most recent call last):
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 288, in onPreviewButtonClicked
self.start(True)
File “/home/karabele/software/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/SlicerVMTK/lib/Slicer-4.11/qt-scripted-modules/LevelSetSegmentation.py”, line 583, in start
for n in xrange(numberOfSliceNodes):
NameError: name ‘xrange’ is not defined

seems to be that LevelSetSegmentation uses Python2 instead of Python3

Yes, probably there are a few similar Python2/3 incompatibilites. It would be great if you could fix them and send a pull request to the SlicerVMTK extension. Thank you!

Hi Andras,
so fixing the xrange makes the module work. However documentation on the levelsetsegmentation is a bit sparse. According to github of SlicerVMTK I should be able to segment a coronary artery tree. But I’m not quite sure how. I tried to add a few diameter seeds and also stoppers and thought I might add a stopper at each end of the tree, however this will always segment just one part of the coronary tree.

I added a Screenshot showing my progress so far.

It can only segment one curve at a time, not a complete tree. You could change the code so that it can take multiple input points and extract multiple curves.

Great! Please send a pull request with your changes.

You’re probably using Python3, where xrange has become range.

The error message ‘xrange’ is not defined would seem to indicate that you are trying to run a Python 2 codebase with Python 3 . In Python 2, an iterable object is often created with xrange() method , usually in a “for loop”, which behaves very similarly to a generator. In Python 3, range() method is implemented the same as the xrange() method , so there is no dedicated xrange(). So, if you use xrange() in Python 3, it will generate NameError:name ‘xrange’ is not defined error.