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.
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.
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?