# vmtkbranchclipper running for a day and still no result.

**URL:** <https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303>\
**Category:** VMTK\
**Created:** [January 17, 2023, 3:01pm UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303 "2023-01-17T15:01:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fotos\_Stylianou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fotos_stylianou/32/18053_2.png) [@Fotos\_Stylianou](https://discourse.slicer.org/u/Fotos_Stylianou)\
**Post date:** [January 17, 2023, 3:01pm UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/1 "2023-01-17T15:01:53Z")

</div>

Hi all,  
I am new here!  
As the title says, I have been using the vmtkbranchclipper on a tracheobronchial tree to generate the branches but the command is running forever.

The command I am using is this  
“~/vmtk\_Py36/vmtk/bin/vmtkbranchclipper -ifile TB.stl -centerlinesfile TB\_cl\_sm\_sp.vtp -ofile TB\_branch\_cl\_sm\_sp.vtp”

here is a look of the input files:

 ![TB](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/9/594d7210aae1fac7e2dc2325a3367e74d5eebf96.jpeg)

If I run the same command on a subset of the geometry the command gives an output. For example see the image below

 ![LLL](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/3/e30e3b8bf922f652cf6ab09e5580843f01bf4d94.jpeg)

In fact I can run the command for the other 4 subsets (lobes) and again I get an output.  
It takes about 30mins if I remember well to run each subsets. But the full tree was running for a day and I stopped it.

What seems to be the issue?  
I believe some form of optimisation is needed. Somewhere it gets trapped.

You can access my files here

> **[VMTK\_question](https://www.dropbox.com/sh/660ev16iocohivt/AADDnlyngCsBitqvWQJ47wc4a?dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [January 18, 2023, 10:37am UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/2 "2023-01-18T10:37:43Z")

</div>

It could be that your TB.stl file is corrupted, just a conclusion.

Try these in SLicer :

- load TB.stl
- in Data module, create a segmentation from the TB node
- in Segment editor module, hide 3D and show 3D again

This is the result :

 ![Screenshot](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/f/7f6d8fd8c20202923d4e4d61fcb9c6358471a97c.png)

No such glitches were found with [sample](https://www.allevi3d.com/sample-files/) STL files.

I can’t explain any of these unexpected behaviours, you may try regenerating your surface.

---

<div class="post-metadata">

**Author:** ![Fotos\_Stylianou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fotos_stylianou/32/18053_2.png) [@Fotos\_Stylianou](https://discourse.slicer.org/u/Fotos_Stylianou)\
**Post date:** [January 18, 2023, 4:44pm UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/3 "2023-01-18T16:44:40Z")

</div>

Hi and thank you for your reply.  
The stl file is not corrupted. It is an open surface meaning that the inlet and outlets are open. So your visualisation software is tying to close them and it fails.  
I have updated the dropbox folder and I provide also closed stl files.  
Try again if you like to see what is going on.

cheers  
Fotos

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [January 18, 2023, 5:14pm UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/4 "2023-01-18T17:14:19Z")

</div>

Yep, the closed surface does not get altered in Slicer, I mean, the segmentation derived from your original file.

Now I made other processing today with a segmentation containing only 19 branches, i.e., much fewer than in your model. I took 12 mins. Too much. And it uses only one CPU core throughout. Only VMTK folks can say if this processing can be multi-threaded.

Debranching your model would probable end up with success in a few days, that’s obviously not a pragmatic workflow. As for ‘How will so many branches help you in practice ?’, well, …

We learn that less is better here.

---

<div class="post-metadata">

**Author:** ![Fotos\_Stylianou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fotos_stylianou/32/18053_2.png) [@Fotos\_Stylianou](https://discourse.slicer.org/u/Fotos_Stylianou)\
**Post date:** [January 19, 2023, 9:24am UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/5 "2023-01-19T09:24:06Z")

</div>

any other ideas are welcome from the VMTK folks…

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [January 19, 2023, 1:59pm UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/6 "2023-01-19T13:59:48Z")

</div>

This is a great airway segmentation, would be interested in how you generated it.

Are you running vmtkbranchclipper from an extension in 3d Slicer, from the Python console, or from the command line?

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [January 19, 2023, 5:04pm UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/7 "2023-01-19T17:04:48Z")

</div>

> [@rbumm](#):
>
> Are you running vmtkbranchclipper from an extension in 3d Slicer, from the Python console, or from the command line?

> [@Fotos\_Stylianou](#):
>
> The command I am using is this  
> “~/vmtk\_Py36/vmtk/bin/vmtkbranchclipper

It seems @Fotos_Stylianou is using the command line, and I am using a newly available module in SlicerVMTK, based on vmtkbranchclipper.py.

But the bottleneck is [here](https://github.com/vmtk/vmtk/blob/a0ed7931c458bf43795b895370fbe16f729e24f4/vtkVmtk/ComputationalGeometry/vtkvmtkPolyDataCenterlineGroupsClipper.cxx#L290). Too many points in the surface, and too many branches will definitely be very long to process on one single CPU core.

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [January 19, 2023, 6:58pm UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/8 "2023-01-19T18:58:24Z")

</div>

Maybe trivial, but you may see on a CPU / GPU monitoring tool (I currently use and recommend [CPUid HWMonitor classic](https://www.cpuid.com/softwares/hwmonitor.html) on Windows) where the hardware performance bottlenecks really are at certain points of a script.

---

<div class="post-metadata">

**Author:** ![Fotos\_Stylianou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fotos_stylianou/32/18053_2.png) [@Fotos\_Stylianou](https://discourse.slicer.org/u/Fotos_Stylianou)\
**Post date:** [January 20, 2023, 11:54am UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/9 "2023-01-20T11:54:42Z")

</div>

Many thanks for your responses.  
@rbumm the segmentation mask is processed with meshmixer to reach the level you see at the images. I did some magic also with vmtk for the outlets.  
@chir.set thank you for pinpointing where the bottleneck is. Hopefully the VMTK team will look into it.  
I have to say that even if I reduce (by a lot) the number of cells on the surface mesh still the command does not produce anything. I believe that the number of branches is the problem.  
Anyhow, I was not expecting a quick solution.

By the way I found an other way to get something similar to what branchclipper does by using paraview. And it runs like in 1 second. So that is why I say that the vmtk branchclipper needs some rewriting and optimisation.

I summarise my steps in paraview with the images below in case someone might end up in my situation:

 ![1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/3/f3ae0caa49f1d93df3809e084bb84749ea49af13.jpeg)  
 ![2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/2/d28a03b2d3fed9d677b79405846df3831b8246ae.jpeg)  
 ![3](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/6/96bbb4593bcdb70eb70e301afffc4082ca0f7f8e.jpeg)  
the last two steps follow in the next post because I can only add 3 images per post

I will be deleting the dropbox folder next week because I do not want my geometry circulating the internet.

Many Thanks for your responses!

---

<div class="post-metadata">

**Author:** ![Fotos\_Stylianou](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fotos_stylianou/32/18053_2.png) [@Fotos\_Stylianou](https://discourse.slicer.org/u/Fotos_Stylianou)\
**Post date:** [January 20, 2023, 11:55am UTC](https://discourse.slicer.org/t/vmtkbranchclipper-running-for-a-day-and-still-no-result/27303/10 "2023-01-20T11:55:41Z")

</div>

![4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/b/3b595f4efaddcca77baec23e2a698420073e5fe6.jpeg)  
 ![5](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/3/831d44b871e568db0a9247753029d82541ef73c0.jpeg)
