Interactive lobe segmentation problem

Interactive lobe segmentation seems didn’t work well. no matter how many fiducials I seleted, five lung lobes can’t be segmented correctly.

Operating system:windows
Slicer version:5.0.3
Expected behavior:five lung lobes segmentations
3dslicer ideal

Actual behavior:as see in the picture

Interactive lobe segmentation is part of the Chest Imaging Platform which is partly outdated and has known problems with certain lung CT datasets. This module will probably be one of the next on our list to fix. If you identify errors and have working fixes we would greatly appreciate a pull request.

In the meantime, you could use the Lung CT Segmenter module of the Lung Ct Analyzer package and its implementation of “lungmask” or “TotalSegmentator” AI packages.
Both offer automatic lung lobe segmentation with Nvidia GPU.

Refer to the wiki for the setup which can be a bit tricky. Once set up on a computer with a strong GPU they can be real timesavers.

1 Like

Thank you a lot, rbumm. After 4 days attempts, working with my laptop(16G+RTX3060), I finally failure to use Lung CT Segmenter module of the Lung Ct Analyzer package. I’d like to share some problems I met these days.
First, Python could not install ‘lungmask’ module by ‘pip install git+https://github.com/JoHof/lungmask’. You need use an old script wrapper to install ‘lungmask’, like ‘import pip, pip.main([‘install’, ‘lungmask’])’.
3dslcier2
Second, after ‘lungmask’ installed successfully, new errors loomed. Such as.
‘‘Failed to compute results: unexpected EOF, expected 7749583 more bytes. The file might be corrupted.’’ , “Failed to compute results: std::bad_alloc: bad allocation” and so on.
So I guessed they might be bugs with Windows, and I tried download Linux(Ubuntu) version. But the same problems I met, and 3dslicer would crash in the end.
Lung lobes segmentation is readly hard! I may need a rest and think how to go on!

Sorry for keeping you busy for that long time, you should have responded earlier!
We are here to help.

Anyway, it seems as if you might have write access problems when trying to install “lungmask”.
Please do the following:

Install a fresh Windows version of Slicer 5.0.3 below your “Home” directory, where you have full read and write access.
Your “Home” directory is usually at
c:\\users\yourname\
so you could use
c:\\users\yourname\Slicer5.0.3\

Start 3D Slicer from there.
Install the Lung CT Analyzer extension again.
Restart 3D Slicer.
Load the CTChest dataset from “Sample Data”

image

Rerun the lungmask lobe segmentation. Upon the first run, it should automatically install and run “lungmask”.

If you get errors:

Please do a manual install of the “lungmask” AI package within Slicer, enter

slicer.util.pip_install("git+https://github.com/JoHof/lungmask")

in the Python Interactor and press enter.

If this results in an error message box, please press “Ok” and paste the complete error message from the Python Interactor here.

Thank you again, rbumm, you are so kind.
I did what you recommended, and as expected, ‘lungmask’ couldn’t be isntalled automatically.


I manual installed in the Python Interactor and pressed enter.
slicer.util.pip_install(“git+https://github.com/JoHof/lungmask”)
these are follow troubles.

Python 3.9.10 (main, Jul  8 2022, 02:32:50) [MSC v.1930 64 bit (AMD64)] on win32
>>> slicer.util.pip_install("git+https://github.com/JoHof/lungmask")
Collecting git+https://github.com/JoHof/lungmask
  Cloning https://github.com/JoHof/lungmask to c:\users\wangjian\appdata\local\temp\pip-req-build-8gmwibu8
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) - skipping
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3527, in pip_install
    _executePythonModule('pip', args)
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3490, in _executePythonModule
    logProcessOutput(proc)
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3459, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['C:/Users/WangJian/Slicer 5.0.3/bin/../bin\\PythonSlicer.EXE', '-m', 'pip', 'install', 'git+https://github.com/JoHof/lungmask']' returned non-zero exit status 1.
>>> 
StartSegmentation completed in 1.63 seconds
Saving markups in temp directory ...
Torchlogic module not found
Querying light-the-torch for torch wheel...
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/light-the-torch/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/light-the-torch/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/light-the-torch/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/light-the-torch/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/light-the-torch/
Could not fetch URL https://pypi.org/simple/light-the-torch/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/light-the-torch/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) - skipping
ERROR: Could not find a version that satisfies the requirement light-the-torch<0.4 (from versions: none)
ERROR: No matching distribution found for light-the-torch<0.4
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) - skipping
Failed to compute results: Command '['C:/Users/WangJian/Slicer 5.0.3/bin/../bin\\PythonSlicer.EXE', '-m', 'pip', 'install', 'light-the-torch<0.4']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "C:/Users/WangJian/Slicer 5.0.3/NA-MIC/Extensions-30893/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTSegmenter.py", line 605, in runProcessing
    self.logic.applySegmentation()
  File "C:/Users/WangJian/Slicer 5.0.3/NA-MIC/Extensions-30893/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTSegmenter.py", line 1644, in applySegmentation
    torch = torchLogic.installTorch(askConfirmation=True)
  File "C:/Users/WangJian/Slicer 5.0.3/NA-MIC/Extensions-30893/PyTorch/lib/Slicer-5.0/qt-scripted-modules/PyTorchUtils.py", line 93, in installTorch
    f'{self.wheelURL}'
  File "C:/Users/WangJian/Slicer 5.0.3/NA-MIC/Extensions-30893/PyTorch/lib/Slicer-5.0/qt-scripted-modules/PyTorchUtils.py", line 63, in wheelURL
    self._wheel = self.getTorchUrl()
  File "C:/Users/WangJian/Slicer 5.0.3/NA-MIC/Extensions-30893/PyTorch/lib/Slicer-5.0/qt-scripted-modules/PyTorchUtils.py", line 112, in getTorchUrl
    slicer.util.pip_install('light-the-torch<0.4')
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3527, in pip_install
    _executePythonModule('pip', args)
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3490, in _executePythonModule
    logProcessOutput(proc)
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3459, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['C:/Users/WangJian/Slicer 5.0.3/bin/../bin\\PythonSlicer.EXE', '-m', 'pip', 'install', 'light-the-torch<0.4']' returned non-zero exit status 1.
>>> slicer.util.pip_install("git+https://github.com/JoHof/lungmask")
Collecting git+https://github.com/JoHof/lungmask
  Cloning https://github.com/JoHof/lungmask to c:\users\wangjian\appdata\local\temp\pip-req-build-qgkg9ax7
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) - skipping
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3527, in pip_install
    _executePythonModule('pip', args)
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3490, in _executePythonModule
    logProcessOutput(proc)
  File "C:\Users\WangJian\Slicer 5.0.3\bin\Python\slicer\util.py", line 3459, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['C:/Users/WangJian/Slicer 5.0.3/bin/../bin\\PythonSlicer.EXE', '-m', 'pip', 'install', 'git+https://github.com/JoHof/lungmask']' returned non-zero exit status 1.
>>> 

You seem to run into problems because git lungmask installation throws ssl certificate errors on your computer.

Please try

slicer.util.pip_install("lungmask")

in the Python Interactor and post the result.

It seems we can manual install ‘lungmask’ with follows codes:

import pip
pip.main(['install', 'lungmask'])

or

slicer.util.pip_install("lungmask")

And I find what matters finally! My CT file is too big, about 356MB, it run out my laptop’s memory! So when I turn to use sample datas, everything is OK!


Thank you very much, rbumm! I can enjoy the world cup now!
My computer will be upgraded or CT datas should be smaller!

1 Like