# Slicer VMTK LevelSetSegmentation no Start

**URL:** <https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184>\
**Category:** Support\
**Tags:** segmentation, vmtk\
**Created:** [June 17, 2021, 12:37pm UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184 "2021-06-17T12:37:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elias\_Karabelas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/elias_karabelas/32/11286_2.png) [@Elias\_Karabelas](https://discourse.slicer.org/u/Elias_Karabelas)\
**Post date:** [June 17, 2021, 12:37pm UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/1 "2021-06-17T12:37:48Z")

</div>

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?

 ![Bildschirmfoto vom 2021-06-17 08-28-17](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/d/7d1d77ca74af02c4d3025e274e0d1f619be1a7b2.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 17, 2021, 1:40pm UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/2 "2021-06-17T13:40:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Elias\_Karabelas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/elias_karabelas/32/11286_2.png) [@Elias\_Karabelas](https://discourse.slicer.org/u/Elias_Karabelas)\
**Post date:** [June 17, 2021, 3:25pm UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/3 "2021-06-17T15:25:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Elias\_Karabelas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/elias_karabelas/32/11286_2.png) [@Elias\_Karabelas](https://discourse.slicer.org/u/Elias_Karabelas)\
**Post date:** [June 17, 2021, 3:26pm UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/4 "2021-06-17T15:26:57Z")

</div>

seems to be that LevelSetSegmentation uses Python2 instead of Python3

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 17, 2021, 3:54pm UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/5 "2021-06-17T15:54:21Z")

</div>

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](https://github.com/vmtk/SlicerExtension-VMTK/). Thank you!

---

<div class="post-metadata">

**Author:** ![Elias\_Karabelas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/elias_karabelas/32/11286_2.png) [@Elias\_Karabelas](https://discourse.slicer.org/u/Elias_Karabelas)\
**Post date:** [June 18, 2021, 7:39am UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/6 "2021-06-18T07:39:24Z")

</div>

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.

 ![SlicerScreenshot.PNG](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/0/704d375d47dbf3d1b6a72c3471cc1125b3739d58.jpeg)

I added a Screenshot showing my progress so far.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 18, 2021, 9:23pm UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/7 "2021-06-18T21:23:42Z")

</div>

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.

> [@Elias\_Karabelas](#):
>
> so fixing the xrange makes the module work

Great! Please [send a pull request](https://github.com/vmtk/SlicerExtension-VMTK/pulls) with your changes.

---

<div class="post-metadata">

**Author:** ![ricslator](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@ricslator](https://discourse.slicer.org/u/ricslator)\
**Post date:** [September 12, 2022, 6:32am UTC](https://discourse.slicer.org/t/slicer-vmtk-levelsetsegmentation-no-start/18184/8 "2022-09-12T06:32:03Z")

</div>

> [@Elias\_Karabelas](#):
>
> NameError: name ‘xrange’ is not defined

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](http://net-informations.com/python/pro/xrange.htm)() 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.
