Exporting CSV with parenchyma analysis module

Hello everyone,
I’m having troubles exporting results from the parenchyma analysis module in CSV. It only exports the first row without the resulting values. Also, I cannot copy and paste to excel which instead is possible when using the scalar volume module

Any clue? I’m using slicer 4 on MAC

Thanks

I’m not sure if CIP developers monitor the Slicer forum. Could you try to contact them directly and let us know if they respond?

@raul

Thanks for answering
I couldn’t find any email address to contact them

Hi Ezio,

Thank you for your email and sorry for the trouble.

Can you provide more info about the Slicer version that you are using to try to reproduce the results?

Are you able to see the results in the module table before exporting the values? A screenshot of a test case might be helpful

Thanks

Raul

Hi there,

Sorry, I am new to this and I am also having trouble.

  1. I am not able to export the data in parenchyma analysis in CSV format.
  2. I can only export one parameter each time. Is there a way to export all the results at one go?
  3. I tried using my own segmentation label map volume (using segment editor). My histogram does not look correct. My left lung histogram is flat. I am not sure what I am doing wrong.

How did you segment the lungs? Using Segment Editor module? Have you clicked “Apply” in “Grow from seeds” effect after the preview looked good?

You could also consider using the LungCTAnalyzer extension. If you miss some features (e.g., want to compute histogram) then probably @rbumm could easily add it.

Thanks for your reply!

I used this youtube video as a guide: COVID-19 lung CT segmentation using 3D Slicer - YouTube

  1. Set threshold as mask (HU -1024 to -200)
  2. using paint to draw general outlines for right lung, left lung and trachea
  3. Click on grow from seeds and initialize
  4. Add additional areas of paint for regions that need correction
  5. Click on apply under grow from seeds to finalize
  6. Export as new label map volume
  7. Go to parenchyma analysis and select input CT volume and the newly created label map volume
  8. Click on apply

I tried the lung CT segmenter extension as well (using landmarks for right lung, left lung and trachea). I still get the same flat histogram for left lung



I am trying to use other parameters (such as perc 85%) to analyze lung fibrosis.

You do not have to do lung masks in “Parenchyma Analysis”. Just set the input volume to the lung CT dataset and leave the “Label map volume” set to “None”, then press “Apply”.

@lassoan Having a histogram in the LungCTAnalyzer is probably good idea !

I see, thanks! I will try to use the native label map volume from “Parenchyma Analysis” as much as possible.

My only concern is if there are some studies where the automated segmentation by the “Parenchyma Analysis” is not optimal and I have to manually edit some areas. In that case, I am worried that this issue will again recur.

I would also like to ask if there is any way to export the data in “Parenchyma Analysis” as a CSV file?

I am not the developer of this extension but - yes, after “Parenchyma analysis” and if you go into the “Data” extension, you see, that the results of the analysis are stored in table nodes.

When saving your scene select the CSV format:

image

The flat histogram looks good, it belongs the trachea (or “other”) segment, which is very small and dark compared to the two lung segments.

The Parenchyma Analysis module probably uses hardcoded label values, which are not the same as the values that are used when you export the segmentation that was created in Lung CT segmentation module. The module should be modernized so that it can use segmentation as input (so that we don’t need to rely on hardcoded label values anymore). The module should also modernized so that for plotting it does not use Charts (that will be removed soon from Slicer) but Plots.

You can compute the histogram of a segmented region by a few lines of Python code, so it would be easy to add it to Lung CT analyzer module. But it is probably better to not create modules with overlapping features but fix/modernize the existing module instead.

Thanks alot!

That is very helpful

I see!

I am not very experienced with Python coding but I will play around with it. Does that mean I can possibly add in my own parameters for analysis (such as other percentile densities instead of the ones provided)?

I realized that if I were to switch the order around in “segment editor”, where “left lung” comes before “right lung”, I will get the histogram for the “left lung” but it will be labelled as “right lung” in “parenchymal analysis”. Essentially, “parenchymal analysis” will create the histogram for the first segmentation accurately but not the others.

This is the original histogram with “right lung” on 1st in order by default:

After I switch the order, putting “left lung” 1st in order as follows:

I get the histogram for the “left lung” but it is labelled as the “right lung” in “parenchymal analysis”

Yes you could do that, the python code is exposed in that extension.
You would need to switch Slicer to “Enable developer mode” under “Application Settings” > “Developer”, then you would be able to “Edit” and “Reload” the extension code (with great care)

image

This is the expected behavior if you export the segmentation to labelmap without specifying a mapping from segment names to label values.

You could change the label values quite easily manually, using numpy, but it is more elegant to specify a color mapping from segment names to label values using a color table node. You can create a color node that matches label values of CIP conventions for a few labels like this:

segmentToLabelValueMapping = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLColorTableNode", "CIP colors")
segmentToLabelValueMapping.SetTypeToUser()
segmentToLabelValueMapping.HideFromEditorsOff()
segmentToLabelValueMapping.SetNumberOfColors(69)
segmentToLabelValueMapping.SetColor( 0, "background", 0.0, 0.0, 0.0, 0.0)
segmentToLabelValueMapping.SetColor( 1, "whole lung", 0.42, 0.38, 0.75, 1.0)
segmentToLabelValueMapping.SetColor( 2, "right lung", 0.26, 0.64, 0.10, 1.0)
segmentToLabelValueMapping.SetColor( 3, "left lung",  0.80, 0.11, 0.36, 1.0)
segmentToLabelValueMapping.SetColor(58, "trachea",    0.49, 0.49, 0.79, 1.0)
segmentToLabelValueMapping.NamesInitialisedOn()

You can then specify this color table when you export the segmentation to labelmap to get the desired label values.

@rbumm if you want to make it easier to use LungCTAnalyzer segmentations with CIP then you could create a color node like this in the segmentation module and set it in the segmentation node. I think it would be used by default when you export the segmentation to labelmap.

1 Like

Done and working (created in 4.13, CIP tested vs 4.11).

image

1 Like

That success message was too early.
I will create an issue in LungCTAnalyzer to prevent pushing this up all the time in discourse.

Sorry Lassoan,

I tried changing the label values to match those of CIP conventions as per your suggestion. I used the exact labels which you kindly provided.


However, my histogram still looks flat for the left lung.

Do you know where did I go wrong?