# Lung segmentation with LungCTSegmenter

**URL:** <https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704>\
**Category:** Support\
**Tags:** segmentation, lungctanalyzer, lung\
**Created:** [November 9, 2023, 10:03pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704 "2023-11-09T22:03:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [November 9, 2023, 10:03pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/1 "2023-11-09T22:03:12Z")

</div>

@rbumm  
Dear Prof. Rudolf Bumm,

Hi, I am using the LungCTSegmenter to segment the lungs with AIrwaySegmentation, Vessel Segmentation following this video: [https://www.youtube.com/watch?v=bw1IaxVkOM4&ab\_channel=medec021](https://www.youtube.com/watch?v=bw1IaxVkOM4&ab_channel=medec021)  
The difference is that I use “total segmentator lung extended” instead of “lungmask r231”  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/5/2566ad57df33da2e5e987e81324eb314813cb884.png)

The result is shown below

 ![Screenshot 2023-11-10 032330](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/9/69c384ed9348deaf059117ce880cbd7be85dc9e6.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/7/e72255111529391dd3f1c79088023ab2b4e9d258.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/0/705ac5762d78bbd5d7b591dce7b40caff4e8c76a.jpeg)

May I know what should be the vessels threshold value since it can be seen from the picture that the vessels are not segmenting well? it will perform even worse if I use the default values. I have tried different values with no luck  
Attached below please find the values  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/e/2e02526585f1d03921c0e68d5824e0a0bd623359.png)

I also noticed that 2 of the videos your provide can yield good results of vessel segmentation, may I know is it possible that I can combine the work of airway segmentation with the lungSegmentation created from lungCTSegmenter and produced a merged OBJ as final. I can export them to OBJ using OPEN anatomy individually but I am not sure of how to combine them.

[![](https://img.youtube.com/vi/mcGqcxU5qBE/maxresdefault.jpg "Airway Segmentation Tutorial") ](https://www.youtube.com/watch?v=mcGqcxU5qBE)

[![](https://img.youtube.com/vi/9iiOBmaP8bA/maxresdefault.jpg "Airway segmentation in 3D Slicer with "Grow from Seeds"") ](https://www.youtube.com/watch?v=9iiOBmaP8bA&t=541s)

Thank you very much.

Slicer: 5.4.0  
Pytorch:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/c/2c1666d507439e03541d3e4afc60f133a4434190.png)

---

<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:** [November 9, 2023, 10:26pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/2 "2023-11-09T22:26:44Z")

</div>

What you see is a typical airway/vessel leak. Stat with airway segmentation → “low detail” and leave out vessel segmentation for a test.  
Ii is in he plans to offer a lung segmentation course during the upcoming PW week in Las Palmas. Jan 24.

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [November 10, 2023, 2:19am UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/3 "2023-11-10T02:19:34Z")

</div>

Thank you for your reply, I can obtain good results with only airway segmentation. But what I want to achieve is vessel segmentation. May I know if the lungCTSegmenter can’t produce good results with vessel segmentation at the moment?  
 ![WhatsApp Image 2023-11-09 at 15.00.39_b4319be3](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/f/4f547df1751e521dbf5af84ff165f5c40b2dcdc7.jpeg)

Moreover, if I generate the airway from the “grow from seeds” function or airway segmentation module, is it possible that I can combine this result with the result I got from previous screenshot: e.g. lung Segmentation with airway segmentation enabled?

Thank you very much

---

<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:** [November 10, 2023, 3:01pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/4 "2023-11-10T15:01:04Z")

</div>

This is the kind of vesselmask you can automatically generate with Lung CT Segmenter.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/f/8f001b5949b7de7c96d4a6a8fdc754eaf151f7cf.jpeg)

There is no differenciation between the pulmonary artery and vein.

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [November 10, 2023, 3:24pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/5 "2023-11-10T15:24:12Z")

</div>

Thank you for your reply. May I know how can I acheive the result you posted in the comment?  
What vessel threshold should I set ?is there any tutorial that I can follow?

Thank you

「Rudolf Bumm via 3D Slicer Community \<[notifications@slicer.discoursemail.com](mailto:notifications@slicer.discoursemail.com)\>」在 2023年11月10日 週五，下午11:01 寫道：

---

<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:** [November 10, 2023, 8:38pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/6 "2023-11-10T20:38:25Z")

</div>

Yes, sure, here you are:

[![](https://img.youtube.com/vi/w5vWBiZeJO4/maxresdefault.jpg "Automatic lung, airway and vesselmask segmentation with Lung CT Segmenter and 3D slicer") ](https://www.youtube.com/watch?v=w5vWBiZeJO4)

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [November 11, 2023, 4:21am UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/7 "2023-11-11T04:21:29Z")

</div>

Thank you very much for your tutorial

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [November 16, 2023, 1:37pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/8 "2023-11-16T13:37:19Z")

</div>

Dear rbumm,

After testing with numerous dataSets, I found that the dataSet from slicer in built demoChest CT produce the best results:

 ![WhatsApp Image 2023-11-14 at 22.31.42_58f8232f](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/f/ff3da3887ac66d228e5e21cd6e2f3cdf13d8db13.jpeg)

However, if I tried to use my own datasets obtained from:  
[https://nbia.cancerimagingarchive.net/nbia-search/?MinNumberOfStudiesCriteria=1&CollectionCriteria=Lung-PET-CT-Dx](https://nbia.cancerimagingarchive.net/nbia-search/?MinNumberOfStudiesCriteria=1&CollectionCriteria=Lung-PET-CT-Dx)  
I cant clearly show the airway segmentations:

 ![WhatsApp Image 2023-11-09 at 14.47.33_c26497ae](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/b/9b3a807803ae7d359e6527c778233b7c980c77b8.jpeg)  
I have also used the grow from seeds function to try to obtain better results but the result is shown above,

I have tried 3 different samples :  
and the results are more or less the same:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/e/0eb4d1610adb797ba0d5756badfc973e753e2c26.jpeg)

Do you think what are the possible problems?  
Do I need to do a little bit of preprocessing like resampling on the DICOM data before segmentation?

Thank you.

---

<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:** [November 16, 2023, 5:40pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/9 "2023-11-16T17:40:17Z")

</div>

My results using your widely spaced data are not as bad when I use Slicer 5.5.0 and CT calibration. However, there is still room for better airway segmentation. At least I do not get these nasty airway leaks.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/6/269d5abb93510dadcd5fd829245e28a4d3749655.jpeg)

Thank you for putting work into this.

So please use 3D Slicer 5.5.0 and the Totalsegmentator extension that belongs to it.

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [November 23, 2023, 4:38pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/10 "2023-11-23T16:38:44Z")

</div>

Sorry for asking again. Sometimes this error will come out when there are too many images. Is there any way to configure the settings or prevent this from happening.

Thank you very much.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/0/309eda3781843df0a3722afc272617da02726bdd.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 23, 2023, 4:54pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/11 "2023-11-23T16:54:13Z")

</div>

That just means you’ve run out of memory. For best results, upgrade your computer.

---

<div class="post-metadata">

**Author:** ![EvelynBundy](https://avatars.discourse-cdn.com/v4/letter/e/c5a1d2/32.png) [@EvelynBundy](https://discourse.slicer.org/u/EvelynBundy)\
**Post date:** [December 7, 2023, 11:54am UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/12 "2023-12-07T11:54:37Z")

</div>

To improve vessel segmentation, experiment with different threshold values. For combining airway and lung segmentation, export as separate OBJ files and merge using software like Blender.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [December 7, 2023, 12:06pm UTC](https://discourse.slicer.org/t/lung-segmentation-with-lungctsegmenter/32704/13 "2023-12-07T12:06:48Z")

</div>

> [@EvelynBundy](#):
>
> For combining airway and lung segmentation, export as separate OBJ files and merge using software like Blender.

I think you can use CombineModels module from Sandbox Slicer’s extension for this
