# Compute surface area in segment based on Hounsfield units (CT-images)

**URL:** <https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167>\
**Category:** Support\
**Tags:** feature\
**Created:** [April 17, 2020, 7:37pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167 "2020-04-17T19:37:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Justin](https://discourse.slicer.org/u/Justin)\
**Post date:** [April 17, 2020, 7:37pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/1 "2020-04-17T19:37:01Z")

</div>

Dear all,

I hope you guys can help. I’m relatively new to 3D slicer. I am using the 4.11 version.  
My goal is to compute skeletal muscle area in a single CT-slice.

I have loaded the CT and have created a segment using the segment editor. I manually outlined all the muscles in a single segment. If I go to the segment analysis, I can convert the segment to a model and I can calculate the surface area of this segment.

However, I am trying to calculate only the surface area of the pixels that have hounsfield units between -29 and +150, not the area of the entire segment. The main reason is to remove fatty tissue inside muscles from the calculation.  
Is there a way in 3d Slicer to achieve this?

Thanks a lot in advance,  
Best,  
Justin

---

<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 17, 2020, 11:11pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/2 "2020-04-17T23:11:39Z")

</div>

We developed a module for this with @hherhold some time ago, now I’ve touched it up and pushed it into [Sandbox extension](https://github.com/PerkLab/SlicerSandbox/tree/master/SegmentCrossSectionArea). You can download it tomorrow in latest Slicer Preview Release. The Sandbox extension is in Examples category, after you install it, the “Segment Cross-Section Area” module should show up in Quantification category.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/0/c011b587a9832cdf3a0bcc0a4a126e44d0e78e73.png)

---

<div class="post-metadata">

**Author:** ![Justin](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Justin](https://discourse.slicer.org/u/Justin)\
**Post date:** [April 18, 2020, 7:16am UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/3 "2020-04-18T07:16:33Z")

</div>

Dear Andras,

Thanks very much for your quick reply and solution!  
Once the module is available I’ll try it out.

Best, Justin

---

<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 18, 2020, 2:07pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/4 "2020-04-18T14:07:13Z")

</div>

Nightly build was not successful on Windows last night but tomorrow it should be OK. If you want to try it earlier then you can download the repository from github and add the SegmentCrossSectionArea folder to the additional module paths in Slicer application settings.

---

<div class="post-metadata">

**Author:** ![Justin](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Justin](https://discourse.slicer.org/u/Justin)\
**Post date:** [April 18, 2020, 8:07pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/5 "2020-04-18T20:07:32Z")

</div>

Thanks very much Andras,  
I noticed the windows version wasn’t updated, but I was able to install the module manually with your instruction.

I also found out that I could filter out the relevant HU range using the section editor, so I have all I need.

Thanks again,  
Best, Justin

---

<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 21, 2020, 3:38pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/6 "2020-04-21T15:38:05Z")

</div>

A post was split to a new topic: [Automating thresholding of existing segments](https://discourse.slicer.org/t/automating-thresholding-of-existing-segments/11229)

---

<div class="post-metadata">

**Author:** ![Justin](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Justin](https://discourse.slicer.org/u/Justin)\
**Post date:** [May 1, 2020, 7:34pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/7 "2020-05-01T19:34:02Z")

</div>

Can the SegmentCrossSectionArea also be reached through script?  
I’ve looked up the script and tried

areaNode = slicer.mrmlScene.AddNewNodeByClass(“SegmentCrossSectionAreaWidget(ScriptedLoadableModuleLogic)”)  
tableNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLTableNode”, “Segment cross-section area table”)  
plotChartNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLPlotChartNode”, “Segment cross-section area plot”)  
logic = SegmentCrossSectionAreaLogic()  
logic.run(segmentationNode, masterVolumeNode, “slice”, tableNode, plotChartNode)  
logic.showChart(plotChartNode)

I get the error that SegmentCrossSectionAreaLogic is not defined.  
Unfortunately I cannot make much more of the python script to see how SegmentCrossSectionAreaLogic should be defined or how I can add the right node so that it will work.

Do you have a suggestion?

---

<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:** [May 1, 2020, 8:38pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/8 "2020-05-01T20:38:19Z")

</div>

The module’s automatic test serves as an example of how to use the module from a script:

> <https://github.com/PerkLab/SlicerSandbox/blob/90320348677225ae86bb54d0dea563af55c5bcae/SegmentCrossSectionArea/SegmentCrossSectionArea.py#L494-L496>

If you run the code from a different file then of course you need to import the module or the classes that you use from them. For example, you can import the logic class by calling:

```python
from SegmentCrossSectionArea import SegmentCrossSectionAreaLogic
logic = SegmentCrossSectionAreaLogic()

```

---

<div class="post-metadata">

**Author:** ![Justin](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Justin](https://discourse.slicer.org/u/Justin)\
**Post date:** [May 1, 2020, 9:22pm UTC](https://discourse.slicer.org/t/compute-surface-area-in-segment-based-on-hounsfield-units-ct-images/11167/9 "2020-05-01T21:22:30Z")

</div>

Thanks, I found the example but I did not know I needed to import

As you say, I just followed the rest of the test module to work run the model from script.
