rbumm / SlicerLungCTAnalyzer

This is a 3D Slicer extension for segmentation and spatial reconstruction of infiltrated, collapsed, and emphysematous areas in lung CT.
Apache License 2.0
71 stars 23 forks source link

Added improved lung segmentation module #10

Closed lassoan closed 3 years ago

lassoan commented 3 years ago

Fixes #7

rbumm commented 3 years ago

Thank you Andras. How is the recommended procedure to test out Slicer pulls routinely? I am just going to download and unzip your code in a separate directory, but this can not be the proper solution ...

rbumm commented 3 years ago

Wow, this has awesome functionality and style. Great that you have put mask segmentation into a separate module. I had one exception upon first try, but it can not be reproduced at second try. The operation itself completed after "Apply" with a very good mask result.

rbumm commented 3 years ago

I only have two "Resampled Volume" s after the "Apply" in the "Data" module ... Could these maybe get automatically removed?

rbumm commented 3 years ago

I tested with the severe COVID case data and the segmenter showed an excellent mask result in this demanding data set.

lassoan commented 3 years ago

I only have two "Resampled Volume" s after the "Apply" in the "Data" module ... Could these maybe get automatically removed?

Indeed, some nodes could be left behind when the segmentation was cancelled or the module was reloaded. #11 should take care of these.

I tested with the severe COVID case data and the segmenter showed an excellent mask result in this demanding data set.

This is awesome news! Do you find it clinically useful? What are your plans for next steps?

rbumm commented 3 years ago

I find it very useful and my colleagues from the ICU agree. But until now I was only able to offer the evaluation in a few cases. Thanks to your excellent help the procedure can now be done in a few minutes, which is awesome.

I would like to evaluate the tool. Need to find a good clinical case for a case report - usually, our COVID patients receive an initial CT only, then follow-ups with conventional X-Rays. It will be very interesting to correlate the CovidQ with functional parameters.
Need to plan that with our Anaesthesiologists and the Pneumonologists.

rbumm commented 3 years ago

I have many new ideas for the Analyzer. It is so much better than the Chest Imaging Suite, which I could not operate nicely in most cases and which did not make use of the new Segment Editor function and your extra effects.

The segmenter could be expanded to include airway segmentation.
The Analyzer could make use of intelligent marker placement so that the thresholds can be automatically adjusted. We need to cut the lung segments in half because many of the patients have dorsal infiltrates - it would be clinically important to have that ventral vs. dorsal infiltration coefficient.

How would I notice if anybody else is using this? Feedback would go into the forum?

lassoan commented 3 years ago

It could be interesting to see how follow-up imaging using X-ray or maybe ultrasound could be correlated to the initial CT imaging. I guess there could be also applications of CT in long-term monitoring of patients with remaining complications.

Airway segmentation and ventral/dorsal split could be explored first by manually editing the segmentation and then if it seems that there is clinical value then the workflow can be automated to make it simpler and faster.

How would I notice if anybody else is using this?

We record how many times an extension is downloaded for each Slicer version. Other than that, we only get information indirectly, such as by getting questions on the Slicer forum or seeing acknowledgements and references in publications.

If you can do a clinical study and get it published then you can ask users to cite that paper when they use the extension, and then it becomes easier to track related work.

rbumm commented 3 years ago

I would like to implement a function that prints out the four selected slices and the two result tables after performing a Lung CT analyzer run. Preferably from a button in the GUI. Can you point me into the right direction here ?

lassoan commented 3 years ago

You can easily create a html report. See how it is done here: https://github.com/OrthodonticAnalysis/SlicerOrthodonticAnalysis/blob/master/OrthodonticAnalysis/OrthodonticAnalysis.py#L548-L579

You can then either open the html report in the default web browser or save it to PDF using a code snippet like this:

printer = qt.QPrinter(qt.QPrinter.PrinterResolution)
printer.setOutputFormat(qt.QPrinter.PdfFormat)
printer.setPaperSize(qt.QPrinter.A4)
printer.setOutputFileName("c:/tmp/output.pdf")

doc = qt.QTextDocument()
doc.setHtml("<h1>Hello, World!</h1>\n<p>Lorem ipsum dolor sit amet, consectitur adipisci elit.</p>")
doc.setPageSize(qt.QSizeF(printer.pageRect().size()))  # hide the page number
doc.print(printer)
lassoan commented 3 years ago

You can also create generate a lightbox image using Screen Capture module:

image

or using coronal plane:

image

Example script to create lightbox image: https://github.com/Slicer/SlicerJupyter/blob/767518de019431e18ed32f14d428594d3859a949/JupyterNotebooks/JupyterNotebooksLib/display.py#L258-L283

rbumm commented 3 years ago

So nice, thank you. Will keep me busy for a while.

rbumm commented 3 years ago

Slowly getting there (fantastic lightbox images you presented btw). Keep looking at them - the visual beauty of a deadly disease ... will definitely implement a lightbox series for a good overview. Progress will be a bit slower because I will be busy during the next days.

rbumm commented 3 years ago

What would be your recommended way to pass a new test version (html report and lightbox) to you? If I push to my master branch, will it not update automatically to Slicer next day?

lassoan commented 3 years ago

You can push to a new branch. You can specify a new remote branch name when you push your changes to github.

To notify me on github that there are changes ready for review, you can create a pull request from the branch and assign me as a reviewer. You may need to add me (lassoan) to your project to be able to assign such tasks to me.

rbumm commented 3 years ago

I should probably do that anyway and it would be a great honor to have you on that project. Pushing to a separate branch seem quite complicated for me, as the report button is not system-critical and you could make timely changes anyway, I would push the next change to the master branch. Could I / would you want me to assign rights for you to make direct changes in the master branch?

lassoan commented 3 years ago

What git client do you use on your computer? It should be easy to set a remote branch name.

Anyway, there should be no risk in pushing directly to the master if it works on your computer.

You can add me to the project in project settings (https://github.com/rbumm/SlicerLungCTAnalyzer/SlicerHeartPrivate/settings/access). If you give me write access there then I can push changes to the repository directly.

rbumm commented 3 years ago

The above URL was not correct (404), I used https://github.com/rbumm/SlicerLungCTAnalyzer/settings/access and invited you as a collaborator? Seems pending ... This was the only thing I could find. Is that the correct way? And pushed my latest preliminary changes to Github. Could not get the addition of an "<"img">"" URL to a Qt doc working yet, the lightboxes create fine in the LungCTGeneratorReports directory in Users/ (probably the wrong place for them to get noticed by the Qt editor), and slices are in the wrong order from down to up, we are used to cranial to caudal. On selected representation of the 3D view (current rotation image) should also be included in the report. The tables are quite complete, but I`ll make them prettier. It would be great to have form fields in the PDF instead of lines to avoid the need for handwriting, will try that later.

Btw I use the GIT Bash 2.29.2.

lassoan commented 3 years ago

I've accepted the invitation and already pushed a commit that completes the report generation: https://github.com/rbumm/SlicerLungCTAnalyzer/commit/5a73293e32dc1147186dacd6be27d65904e7475f

I use TortoiseGit (but there are other git clients with GUI, and editors, such as Visual Studio Code has built-in git functions) which makes it much easier to use git, as you don't need to memorize commands. Commonly needed operations are usually available by a few clicks.