Lung CT Segmenter now supports 'lungmask' AI for lung and lobe segmentation

We have a new “experimental AI” option in Lung CT Segmenter for creating lung and lobe segmentations with minimal effort (one tracheal markup) on the fly.

This feature involves Johannes Hofmanningers lungmask with permission.

A short YouTube demo is here:

In this setting, an Nvidia GPU (1060 +), 6 GB GPU memory and “CUDA enabled” are strongly recommended.

Real processing time on a desktop PC with RTX 3070Ti GPU (without the in-video speedup): 97.23 s.
Slicer extension: Lung CT Analyzer
Dataset: From MONAILabel Task06_lung with permission.

7 Likes

That is great. Is it possible to use cli and save labelmaps?

Yes, you can.

The Lung CT segmenter AI test function is a working example.

The only thing to note is the current necessity to define one tracheal markup in this code. If you want just lungs and lobes you could just freely define one, f.e. as in the test example, it is not really needed for AI.

1 Like

You would have to convert the output segmentation to a labelmap if you really needed to.

1 Like

thanks, i will do that

Hi Rudolf. Mine is not working. It is said no module name torch. How to get it and use the module torch? Thank you.

Please install the “Pytorch Utils” extension and restart Slicer.
Then it should typically install torch when you run the lung segmenter extension, but you could also install it from Pytorch Utils directly:

image

Please be patient during installation, it will take several minutes with no reaction or progress bar.

Which version of 3D Slicer and Lung CT Segmenter are you using?

Also note that you may need 20-30GB of free disk space for installing pytorch. If you run out of disk space then you may need to completely remove all remnants of pytorch and then install it again. I’ve found that in this case it is easier to reinstall Slicer than trying to clean up things manually.

All dependencies (SegmentEditorExtraEffects, SurfaceWrapSolidify, and PyTorch) are now included in Lung CT Analyzer’s CMakeList.txt for user convenience.

A fresh 3D Slicer 5.0.3 install on a Windows 11 system occupies 850 MB which grows to 7.4 GB after AI lung segmentations (mainly from Pytorch).


Hi everyone, thank you for guiding me. I have installed the Pytorch and still got the same message. Is there any way to fix it? Thank you.

I am using Macbook Pro, macOS Big Sur, 2.8GHz Dual-Core Intel Core i7, Memory 8 GB. 3D Slicer version 5.03.
I have installed PyTorch as I mentioned and the AI still not working. Thank you for your help Rudolf.

Unfortunately, I have no experience with using PyTorch in MacOS.

Have you been pressing this button in the PyTorch Utils extension?

image

If yes and you still got the error message you may want to refer to this page on how to install PyTorch from Slicer´s Python Interactor. See “Installing on MacOS” section.

import torch

should not throw an exception and

import torch
x = torch.rand(5, 3)
print(x)

should show a result.

Following the steps to install and test pytorch that @rbumm suggested works for me on a mac (m2 macbook air) with Slicer 5.0.3.