Using U-net (R231) model for lung segmentation in Python IDE

Hi,

I want to use U-net model for lung segmentation and create it’s mask, I read the descriptive text on “GitHub - JoHof/lungmask: Automated lung segmentation in CT” but unfortunately it didn’t help me enough.
Is there any source code about it?

Thanks.

In which Python IDE do you want to use lungmask AI?

You should be able to run lungmask as descibed on their GitHub website like

from lungmask import LMInferer
import SimpleITK as sitk

inferer = LMInferer()

input_image = sitk.ReadImage(INPUT)
segmentation = inferer.apply(input_image)  # default model is U-net(R231)

Thank you for your reply Dr bumm.

I want to use it in Spyder.
Yes as I mentioned, it didn’t help me for some part of my work.
For example how can i use it with Pyradiomics package for feature extraction?

The code provided by Dr.Bumm should work in Spyder. Just be sure to install the lungmask and simpleitk packages first using any package manager, such as pip and be sure Spyder is using the right Python interpreter.

Pyradiomics is a package separate from lungmask. For pyradiomics, you can call it from Python also. The examples included with the PyRadiomics repository were helpful to me, hopefully it will work for you if you follow the included examples.

1 Like