# Exporting CSV with parenchyma analysis module

**URL:** <https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697>\
**Category:** Support\
**Tags:** cip\
**Created:** [March 16, 2020, 11:07am UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697 "2020-03-16T11:07:45Z")\
**Posts on this page:** 19\
**Page:** 3

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 10, 2021, 4:48pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/41 "2021-12-10T16:48:12Z")

</div>

This is a temporary issue, we are just waiting for @raul to approve this pull request that contains the fix:

> <https://github.com/acil-bwh/SlicerCIP/pull/34>
>
> This pull request includes https://github.com/acil-bwh/SlicerCIP/pull/32 and add…s further fixes (such as report generation), design improvements and code refactoring.
> 
> @rbumm please test if everything works as expected. I've changed the API of the logic class, so you may need to adjust Lung CT Segmenter module accordingly.

---

<div class="post-metadata">

**Author:** ![chuawm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chuawm/32/11915_2.png) [@chuawm](https://discourse.slicer.org/u/chuawm)\
**Post date:** [December 10, 2021, 5:54pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/42 "2021-12-10T17:54:40Z")

</div>

Ok thank you @lassoan

On another note, I have been trying to create histograms for my own CT chest studies in Parenchymal Analysis Module using the steps laid out by @rbumm .

However, there always seems to be a spike in frequency at HU -1024. I have tried a few different CT studies

 ![ct chest spike](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/9/29cdc8c430a84e6546baa062faec7dbedd7633ca.jpeg)

This does not appear to be an issue for the DemoCTChest sample data. Is there a reason for it?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 10, 2021, 5:58pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/43 "2021-12-10T17:58:45Z")

</div>

-1000 HU corresponds to air, if you are interested in soft tissue density then you can ignore that peak.

---

<div class="post-metadata">

**Author:** ![chuawm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chuawm/32/11915_2.png) [@chuawm](https://discourse.slicer.org/u/chuawm)\
**Post date:** [December 10, 2021, 6:17pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/44 "2021-12-10T18:17:16Z")

</div>

In that case, shouldn’t the CTchest sample data also have the same peak to correspond to air? But as you can see in the image below, the sample data does not have the peak at -1024 HU. Instead, the peak is at ~HU-900. Also, the peak is smooth and not as sharp as mine.

 ![histogram (1)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/f/2f2bde0691aa390746c2f40ac8d71383935d71d9.jpeg)

I am all for ignoring it but I am worried that there might actually be erroneous data being generated.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 10, 2021, 7:41pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/45 "2021-12-10T19:41:13Z")

</div>

Probably all voxels below -1024 is lumped into the that -1024 bin. As you can see, the peak does not go down all the way to 0 at that density value (either the image is darker or more of the air voxels are included in the segmentation), you see one large value. Probably you could eliminate this by reducing the lower range from -1024 to -1200 or so, or by adjusting the segmentation to include less “air” voxels.

---

<div class="post-metadata">

**Author:** ![chuawm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chuawm/32/11915_2.png) [@chuawm](https://discourse.slicer.org/u/chuawm)\
**Post date:** [December 11, 2021, 2:47pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/46 "2021-12-11T14:47:21Z")

</div>

Ok thanks for helping @lassoan. I tried using a wider threshold as you suggested (i.e. HU -1200) and also ensuring that the segmentation is as accurate as possible to exclude air that is not lungs but it still does not work.

 ![ct chest spike](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/d/3db93df41d5a47f1f3cc86b37c815c788d606f1e.jpeg)

I think ideally it should have looked like the histogram in the 3D slicer sample data as this is what normal lung histogram looks like as seen below (peaking at about ~HU -900 without any spurious spike). I think the main issue is whether the other calculations (e.g. mean, skewness, kurtosis, perc) will be significantly affected by this spike.

 ![normal densitogram](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/d/fd76c3ce6c68844e66353fa633a8c33dc6f331fe.jpeg)

I will try on more studies but so far I am not getting it to work.

On another note, would you happen to know when @raul will be approving the pull request?

Thanks alot!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 11, 2021, 2:59pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/47 "2021-12-11T14:59:52Z")

</div>

You haven’t changed the histogram bin lower range from -1024. Changing the plot view’s zoom does not change the histogram bins. If adjusting the histogram bin range is not exposed on the GUI then you need to edit the Python script of the module.

---

<div class="post-metadata">

**Author:** ![chuawm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chuawm/32/11915_2.png) [@chuawm](https://discourse.slicer.org/u/chuawm)\
**Post date:** [December 11, 2021, 3:50pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/48 "2021-12-11T15:50:23Z")

</div>

Oh yes, I just realized that as well. I had a look at the script. It seems that there is no lower limit for the histogram. Is this correct?

 ![cip script](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/2/d28dec0a5453f918a10fd13161ed209dee77d838.jpeg)

Anyway, it still does not make sense as I feel that lungs should not have any density at or lower than HU -1024 if they are normal. We can see from the sample data that the range of densities does not come close to HU -1000.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 11, 2021, 4:29pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/49 "2021-12-11T16:29:53Z")

</div>

It all looks good to me. Probably the WholeLung segment includes the trachea, which is all air. The intensity barely goes below -1024, maybe by 5 bins, which can be due to noise and slight miscalibration of the CT.

It is also interesting to note that the shape of the intensity histogram may depend on the resolution of the CT due to the partial volume effect. A higher-resolution scan will contain more voxels that are completely filled with air, therefore the histogram will have a thicker tail (more voxels with approximately -1000 HU).

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [December 12, 2021, 9:57am UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/50 "2021-12-12T09:57:44Z")

</div>

I get the same vertical histogram bar at -1024 … obviously, the voxel intensities at and below -1024 seem to be pooled at this value.

Threshold segmentation (range -1024 to -1024):

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/6/a6e9e153ea38d6e6657a1f933445aecada4a6668.jpeg)

---

<div class="post-metadata">

**Author:** ![chuawm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chuawm/32/11915_2.png) [@chuawm](https://discourse.slicer.org/u/chuawm)\
**Post date:** [December 14, 2021, 2:34pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/51 "2021-12-14T14:34:22Z")

</div>

Thanks @rbumm and @lassoan ! Yes I tried a few more cases and even used another program to test. All of them return a spike and it is likely due to the smaller airways or air pockets that we cannot exclude. I might have to adjust the threshold higher if I want to remove the spike.

Thanks again!

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [December 19, 2021, 5:43pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/52 "2021-12-19T17:43:21Z")

</div>

Checked this out a little further and - sorry to say - I can not reproduce the disturbing vertical spike at -1024 when implementing my own histogram chart with scatterbars in the LungCTAnalyzer:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/c/bc47ca0bb688e75dacb889bd633796bbe16f904f.jpeg)

Tested several CTs with the new function not showing a spike. Unfortunately, I can not check this against Parenchyma Analysis of CIP because although CIP can be loaded with yesterday’s Slicer preview (4.13.0-2021-12-17 r30503 / fff83f9) it results in all kinds of error messages, and Parenchyma Analysis is not initialized.

So if you all agree I will probably include a histogram table and chart production as an additional output in LungCTAnalyzer.

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/3/23fb1f3893b83b4b9eed257021777db5ad8c68a8.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 19, 2021, 10:23pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/53 "2021-12-19T22:23:58Z")

</div>

It is better to fix the existing Parenchyma analyzer module than duplicating the feature in Lung CT analyzer: it keeps lung CT analyzer module slightly sinpler and significantly reduces maintenance workload (no need to maintain the same feature in two places).

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [January 3, 2022, 1:01pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/55 "2022-01-03T13:01:46Z")

</div>

Happy new year, @lassoan.

> > It is better to fix the existing Parenchyma analyzer module

Although I was a bit reluctant (possible delays of getting CIP PR’s accepted) I was able to fork and locally build Slicer\_CIP, as far as I see without errors. Now I am stuck on how to locally install this extension build in my recently compiled Slicer from disk. How would you recommend doing so? Use the Developer Tools → Extension Wizard or is there a command-line option?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 3, 2022, 1:34pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/56 "2022-01-03T13:34:27Z")

</div>

I usually just add the module folders to “additional module paths” in application settings. See some more details here: [Extensions — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/extensions.html#run-slicer-with-your-custom-modules)

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [January 3, 2022, 2:00pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/57 "2022-01-03T14:00:11Z")

</div>

Great, works.

It turns out that loading the current Slicer\_CIP in two recent Slicer previews throws seven “No module named Editor” exceptions like this:

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\D\S4R\python-install\Lib\imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:/D_CIP/SlicerCIP/SlicerCIP-build/inner-build/lib/Slicer-4.13/qt-scripted-modules/CIP_RVLVRatio.py", line 10, in <module>
    from CIP.ui import CaseReportsWidget
  File "C:\D_CIP\SlicerCIP\SlicerCIP-build\inner-build\lib\Slicer-4.13\qt-scripted-modules\CIP\ui\ __init__.py", line 1, in <module>
    from .CIP_EditorWidget import CIP_EditorWidget
  File "C:\D_CIP\SlicerCIP\SlicerCIP-build\inner-build\lib\Slicer-4.13\qt-scripted-modules\CIP\ui\CIP_EditorWidget.py", line 7, in <module>
    from Editor import EditorWidget
ModuleNotFoundError: No module named 'Editor'  

```

Probably easy to solve ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 3, 2022, 2:54pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/58 "2022-01-03T14:54:58Z")

</div>

The Editor module has been removed from Slicer. The replacement may not be trivial, but should improve the extension. This may be a good task for the upcoming project week.

---

<div class="post-metadata">

**Author:** ![chuawm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chuawm/32/11915_2.png) [@chuawm](https://discourse.slicer.org/u/chuawm)\
**Post date:** [April 13, 2022, 10:19am UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/59 "2022-04-13T10:19:12Z")

</div>

@rbumm For the spike, I realized it depends on what kernel the images were acquired in. If I used images reconstructed with smooth kernel (soft tissue window), the spikes will not be there. But if I used images reconstructed with lung kernel (lung window), then the spikes will be there.

Lung Kernel example:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/d/cdb5d3092e135a707016c91d1ec72a398138ab99.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/4/14340ae451bf6c81fb25cd3113d980d267566da0.jpeg)

Smooth kernel example of same patient:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/6/9679bb7a60d0d0657ead435c6f316137c92d76c1.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/d/6d28275d31cba509c9441bf0872517272362a690.jpeg)

Not sure if that helps.

By the way, @lassoan do you know if the parenchyma analysis module has been fixed?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 13, 2022, 8:18pm UTC](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697/60 "2022-04-13T20:18:07Z")

</div>

Forget about that peak. You can safely ignore that. The segment have thousands of voxels and the peak is just a few dozens voxels.

> [@chuawm](#):
>
> By the way, @lassoan do you know if the parenchyma analysis module has been fixed?

It was a long time ago, but I think it works well in current Slicer Preview Release.

[Previous page](https://discourse.slicer.org/t/exporting-csv-with-parenchyma-analysis-module/10697.md?page=2)
