Just to let you know, @chuawm :
I have literally spent 6 hours on that problem, tried every possible way to make this work in 4.11, but had no success. The problem seems to be, that the “Parenchyma analysis” of CIP (which I am not the author of) is outdated and probably not fully compatible with 4.11. Whatever values I put into the “CIP colors” color table node, and use it during export of the “Lung CT Segmenter” segmentation and as an input into “Parenchyma analysis”, it is not associated with “right lung” and “left lung” and “left lung” histogram remains flat.
Just an example: segmentToLabelValueMapping.SetTypeToUser() is not in the vtkMRMLColorTableNode documentation. Am I / are we missing anything here ?
I could easily implement a histogram function into “LungCTSegmenter”, but as @lassoan said - this is probably not the right way to go because the specialized modules should be modernized.
Firstly, thank you @rbumm for helping! I really appreciate it!
I will probably have to make do with using the alternative you suggested for the time being, which is to use a histogram function for “LungCTSegmenter”.
Apologies as I am still new to this and I have a question about inserting the histogram function. How do I get the individual histograms for each segments (i.e. right lung, left lung)?
The script repository here that I’m using is likely generating a single histogram (I’m assuming its the whole lung).
Additionally, the count frequency and graph seem to be different when generated by CIP “Parenchyma Analysis” compared with the generic script I am using.
Did you copy that code into the python interactor or modify it before? You would need to.
The code you mention is an example of loading a brain tumor dataset and plotting a histogram …
I will add a histogram function, which will be helpful anyway, to LungCTAnalyzer during the next few days. Please check back.
Chest Imaging Platform fix has been merged today. So, in tomorrow’s Slicer Preview Release CIP should be available and it should work well with LungCTSegmenter output.
I can confirm that in 4.13.0-2021-08-24 → CIP is available. The “Parenchyma analysis” extension of CIP now correctly detects and analyzes a labelmap generated from a segmentation created by “LungCTSegmenter” using CIP-colors. As far as I see - good histograms:
I noticed that your segmentation colours are the default ones generated by “LungCTSegmenter” (i.e. green and yellow). I also tried using the default colours but the same flat histogram is still present.
CIP modules should be updated to take segmentations directly instead of requiring labelmap conversion.
@rbumm it would be awesome if you could review and modernize CIP modules. They contain excellent algorithms but they don’t seem to be actively maintained.
Allowing selfecting segmentation or labelmap volume as input should be straightforward. You can list multiple node types in the input selector combobox and if you receive a segmentation node then you can convert to labelmap node with the appropriate color table.
But I fully agree that overall the modernization of the CIP extension is significant effort. Any amount of work that you can put into it (and other extensions) are greatly appreciated.
I investigated this more and it turns out that VTK is supposed to support string vector references, there was just a bug in VTK that broke this for cases when there were multiple overloads for a method. I’ve reported the error to VTK developers, they fixed it, now we just need to backport these fixes in to Slicer’s VTK. Once that is done, you will not need to create a vtkStringArray but you can directly pass a Python string array to the ExportSegmentsToLabelmapNode method.
I realized that the Parenchymal Analysis Module is no longer available on the later versions of Slicer Preview Release (4.13.0-2021-12-09). Is this permanent or temporary? If permanent, is there another module that can analyze and create histogram of lung density similar to Parenchymal Analysis Module?