LungCTAnalyzer error: Input lung CT is invalid

Hello, I am a novice user of 3D Slicer and trying to use version 5.0.2 of the software in macOS 10.12.

For a CT that I am looking at, I could get segmentation done, but at the next step, Analyzer shows error message: Failed to compute results: Input lung CT is invalid. When I click the OK button on the message, I see a message Starting processing - 0% but nothing happens. What may be the reason? I see the same error with Load Covid-19 demo data.

error

(sorry for double posting here and GitHub; I noticed later that the GitHub project page suggests using this community)

Sorry, it is macOS 12.2 and not 10.12.

Hello,
I just tested again on a Windows 11 PC with Slicer 5.0.2 and Lung CT Analyzer V 2.49

There are no such error messages.
The one thing that comes to my mind: I do not see the Lung CT Analyzer version number on your screenshot.

image

Are you maybe using an outdated version of the extension?

1 Like

Thanks for the quick response. I also noticed the missing version identifier. I used the extension manager within 5.0.2 to install Chest Imaging Platform (CIP) and Lung CT Analyzer a couple of days ago, and for the analysis I used CIP > Lung CT Analyzer. I will try updating the extensions.

Maybe something has gone wrong with that install on the mac.
You could remove the Lung CT Analyzer extension and restart Slicer. Check that it is gone.

Then, clone the Lung CT Analyzer Github version by

git clone https://github.com/rbumm/SlicerLungCTAnalyzer.git

into a directory of your choice.

Then go to Slicers “Application settings”

and manually add two folders here:

LungCTSegmenter
LungCTAnalyzer

Restart Slicer. This should give you the most recent version of the extension.

1 Like

Thanks. Will do and report within a day.

I’ve tried 5.0.2 on macOS using the DemoChestCT sample data set and everything worked perfectly. The version string (V 2.49) appears for me.

I don’t think we need to experiment with manual download of the repository and adding them as additional module paths, because it may lead to more complications (there are a lot of possibilities for user errors in manual installation).

Instead, I would recommend to check the application log for any errors. Also, try if segmentation and analysis work with the DemoChestCT sample data set.

2 Likes

Agree - this was just to show how it could be troubleshot. Generally, it would be better to use the extension manager.

Unfortunately I am still seeing the same issues – invalid input CT, and no version number – with both my and the Covid-19 demo CTs under four different installation settings:

  1. Removing the extension and reinstalling from GitHub as suggested in Dr. Bumm.

  2. Completely removing the Slicer app (with App Cleaner to remove any ancillary file), reinstalling Slicer 5.0.2 using the macOS installer DMG from Slicer download site, and installing just the Lung Segmenter and Analyzer as in #1.

  3. As #2 but using Homebrew to install Slicer 5.0.2.

  4. As #2 but using Extension Manager to install LungCTAnalyzer.

The Slicer app’s error log (for #4 setting with Covid-19 demo CT):

This will clear all data in the scene. Do you want to continue?
Clearing the scene
Registering the sample data
Downloading COVID Chest CT dataset
<b>Verifying checksum</b>
<b>File already exists and checksum is OK - reusing it.</b>
<b>Requesting load</b> <i>DemoChestCT</i> from /Users/ashipde/Library/Caches/NA-MIC/Slicer/SlicerIO/DemoChestCT.nrrd ...
Clearing the scene
Registering the sample data
Downloading COVID Chest CT dataset
Loaded volume from file: /Users/ashipde/Library/Caches/NA-MIC/Slicer/SlicerIO/DemoChestCT.nrrd. Dimensions: 490x490x361. Number of components: 1. Pixel type: short.


"Volume" Reader has successfully read the file "/Users/ashipde/Library/Caches/NA-MIC/Slicer/SlicerIO/DemoChestCT.nrrd" "[0.99s]"
<b>Load finished</b>
Downloading COVID Lung Mask segmentation
<b>Verifying checksum</b>
<b>File already exists and checksum is OK - reusing it.</b>
<b>Requesting load</b> <i>DemoLungMasks</i> from /Users/ashipde/Library/Caches/NA-MIC/Slicer/SlicerIO/DemoLungMasks.seg.nrrd ...
Downloading COVID Lung Mask segmentation
"Segmentation" Reader has successfully read the file "/Users/ashipde/Library/Caches/NA-MIC/Slicer/SlicerIO/DemoLungMasks.seg.nrrd" "[1.62s]"
<b>Load finished</b>
Centering.
Normal end of loading procedure.
Centering.
Normal end of loading procedure.
Apply
Processing started.
Apply
Processing started.
Failed to compute results: Input lung CT is invalid
Failed to compute results: Input lung CT is invalid
Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 853, in onApplyButton
    self.logic.process()
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 2135, in process
    raise ValueError("Input lung CT is invalid")
ValueError: Input lung CT is invalid

My system: macOS 12.2.1 with XCode 13.4.1, Intel Core i9 3.6 GHz 8-core, 48 GB DDR4, Radeon Pro 580X 8 GB; Slicer app has full data access privilege in macOS Preferences.

Thank you @ashipde. Could you restart Slicer and enable the Python interactor for a test, then run Lung CT Analyzer?

image

Do you see any exceptions/error messages in the interactor?

Thank you Dr. Bumm. Using the Interactor as you suggested helps us identify a possible cause: a file permission issue.

My computer is at an institution and managed by IT, though I have admin rights. The Slicer installer (dmg) had installed Slicer.app with drwxr-xr-x permission.

To possibly solve the issue, I set permissions to 777 for /Applications/Slicer.app, /Applications/Slicer.app/Contents, ~/Documents/SlicerDICOMDatabase, and ~/Documents/LungCTAnalyzerReports.

But the problem remains.

Below is message log from Python interactor from one session. I have annotated it with my actions.

/////// Start

Python 3.9.10 (main, May  6 2022, 02:57:10) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
>>> 

/////// Load – my CT DICOM

Loading with imageIOName: GDCM

/////// Switch module selector in top menu to Lung CT Segmenter > Start > Apply

StartSegmentation completed in 1.09 seconds
self.extentGrowthRatio = 0.5
masterImageExtent = (0, 174, 0, 174, 0, 142)
labelsEffectiveExtent = (34, 148, 56, 132, 62, 133)
labelsExpandedExtent = [0, 174, 18, 170, 27, 142]
Grow-cut operation on volume of 175x153x116 voxels was completed in 0.5 seconds.
Saving markups in temp directory ...
ApplySegmentation completed in 8.02 seconds

/////// Switch module selector in top menu to Lung CT Analyzer > (Input volume/segmentation already selected) > Computer results

Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 211, in setup
    with open('LCTA.INI', 'w') as configfile:    # save
OSError: [Errno 30] Read-only file system: 'LCTA.INI'
Directory changed
Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 895, in onReportDirectoryChanged
    with open('LCTA.INI', 'w') as configfile:    # save
OSError: [Errno 30] Read-only file system: 'LCTA.INI'
Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 337, in enter
    self.initializeParameterNode()
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 375, in initializeParameterNode
    self.setParameterNode(self.logic.getParameterNode())
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 415, in setParameterNode
    self.updateGUIFromParameterNode()
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 462, in updateGUIFromParameterNode
    self.ui.checkForUpdatesCheckBox.checked = self.checkForUpdates
AttributeError: 'LungCTAnalyzerWidget' object has no attribute 'checkForUpdates'

//////// Download and examine demo CT – Within Lung CT Analyzer module window > Load Demo Covid-19 data >  Compute results

This will clear all data in the scene. Do you want to continue?
Clearing the scene
Registering the sample data
Downloading COVID Chest CT dataset
Downloading COVID Lung Mask segmentation
Centering.
Normal end of loading procedure.
Apply
Processing started.
Failed to compute results: Input lung CT is invalid
Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 853, in onApplyButton
    self.logic.process()
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 2135, in process
    raise ValueError("Input lung CT is invalid")
ValueError: Input lung CT is invalid

//////// Again download demo CT (but not analyze) – Within Lung CT Analyzer module window > Load Demo Covid-19 data

This will clear all data in the scene. Do you want to continue?
Clearing the scene
Registering the sample data
Downloading COVID Chest CT dataset
Downloading COVID Lung Mask segmentation
Centering.
Normal end of loading procedure.

//////// Try other module commands – Within Lung CT Analyzer module window > Report directory > Change report directory

Open Directory
Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 880, in onOpenReportDirectoryButton
    subprocess.Popen(f'explorer {os.path.realpath(self.reportFolder)}')
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'explorer /Users/ashipde/Documents/LungCTAnalyzerReports'

/// Folder '/Users/ashipde/Documents/LungCTAnalyzerReports' exists

//////// Try other module commands – Within Lung CT Analyzer module window > Report directory > Open report directory

Directory changed
Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/Extensions-30822/LungCTAnalyzer/lib/Slicer-5.0/qt-scripted-modules/LungCTAnalyzer.py", line 895, in onReportDirectoryChanged
    with open('LCTA.INI', 'w') as configfile:    # save
OSError: [Errno 30] Read-only file system: 'LCTA.INI'

Yes, the mac now has several safety features that can make things difficult, like read-only volumes. Try moving the Slicer.app folder to your home directory. It should run fine out of there and be able to store files.

@rbumm I would recommend not to try to create files in such locations (where code is stored). Instead, use the folders provided by the application or the scene:

  • slicer.app.temporaryPath: for data that will not be preserved after restarting Slicer, suitable for large data (images, etc.)
  • slicer.app.cachePath: for data that will be preserved after restarting Slicer, but will be removed when more recent data is added to the cache and the cache size limit is reached, suitable for large data (images, etc.)
  • slicer.app.slicerUserSettingsFilePath: folder of this file is good for storing data that needs to be persistently stored; suitable for small data, such as configuration information, but not for bulk data (images, etc.)
  • slicer.app.defaultScenePath: default location for exported data or reports; the best is to only use this as default and let the user specify a different folder
  • slicer.mrmlScene.GetRootDirectory(): current scene file location, for exported data or reports

Also, I would not recommend to create a separate ini file (LCTA.INI) for your module but instead use all your settings in Slicer.ini (via slicer.app.userSettings() object). Slicer settings would become very difficult to manage if each module maintained its settings in a separate ini file.

@piper The issue also occurs with Slicer app in my user directory. Note that the Lung CT Segmenter part of the LungCTAnalyzer extension works but the Lung CT Analyzer part fails. Another extension, DensityLungSegmentation, that I tried works fine with my and the demo Covid-19 data.

The LungCTAnalyzer extension works well with my CTs in Windows 10, so the issue is macOS-specific. I also updated macOS from 12.2 to 12.4 but it didn’t help.

@ashipde as a workaround, you can probably simply comment out the offending lines. For example, it won’t cause much trouble if your settings are not saved in the private .ini file.

@lassoan Thank you for the suggestion. I commented out the LCTA.INI calls in LungCTAnalyzer.py (8 lines) and I was able to get LungCTAnalyzer to perform the analysis.

2 Likes

@rbumm Dr. Bumm, I am actually planning to use the LungCTAnalyzer to quantify ILD progression over a period of two years. There are 9 CT scans, from different CT imagers and of varying slice thickness, but same position, supine, and respiratory phase, inspiratory. Will my use of the software be appropriate?

Thank you @lassoan for the recommendations.

Will put LCTA.ini into slicer.app.slicerUserSettingsFilePath in an update folloing today and use Slicer.ini as soon as I figure that out.

Yes, the Lung CT Analyzer should be sufficient in ILD if you select the appropriate thresholds.
I have mainly used LCTA for COVID-19 data until now but would be very interested to see how this works in ILD.
BTW Thanks you for doing all those tests on your MAC !

Different CT scanner should not make any difference. Different slice thickness may make small differences, but probably not more than a few percent.

If you want to estimate the possible effects of different slice thickness, you can resample a volume at different resolutions (for example, using “Crop volume” module) and see how much difference it makes in the analysis results.