# how to obtain a report/table of the histogram of grayvalues 

**URL:** <https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330>\
**Category:** Support\
**Created:** [October 9, 2018, 4:58pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330 "2018-10-09T16:58:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nuria](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@Nuria](https://discourse.slicer.org/u/Nuria)\
**Post date:** [October 9, 2018, 4:58pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/1 "2018-10-09T16:58:36Z")

</div>

Hi!

I’m trying to obtain a table with the histogram of gray values of a volume (obtained from a segmentation using the mask volume) but I can’t. At the moment, I only see the plot in the volume module but I need the values. It is possible?

Thanks!

---

<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:** [October 9, 2018, 5:14pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/2 "2018-10-09T17:14:49Z")

</div>

A solution is described in this post: [Histogram of volume in regions defined by segments](https://discourse.slicer.org/t/histogram-of-volume-in-regions-defined-by-segments/2236)

---

<div class="post-metadata">

**Author:** ![Nuria](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@Nuria](https://discourse.slicer.org/u/Nuria)\
**Post date:** [October 9, 2018, 5:56pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/3 "2018-10-09T17:56:18Z")

</div>

When I paste the script to my slicer, it crashes, I have the version 4.8.1

---

<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:** [October 9, 2018, 5:57pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/4 "2018-10-09T17:57:08Z")

</div>

You need to use latest nightly version.

---

<div class="post-metadata">

**Author:** ![Nuria](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@Nuria](https://discourse.slicer.org/u/Nuria)\
**Post date:** [October 9, 2018, 6:58pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/5 "2018-10-09T18:58:24Z")

</div>

Thanks! I will try it

---

<div class="post-metadata">

**Author:** ![Nuria](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@Nuria](https://discourse.slicer.org/u/Nuria)\
**Post date:** [October 10, 2018, 11:25am UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/6 "2018-10-10T11:25:57Z")

</div>

Hi again!

Now I have the latest nightly version, and the script works but I don’t know how to change it to work with my data. I have performed the segmentation (using thresholding values) with the segmentation module, then I have created the mask volume with the segment created and filling outside with 0. But this is all, I don’t know how to call my mask volume and segmentation to obtain the histogram chart and table. Also I would like to know how to obtain the histogram and table of my initial master volume.  
Sorry, I have never used python language.

---

<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:** [October 10, 2018, 12:54pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/7 "2018-10-10T12:54:46Z")

</div>

Run the script as is and modify it step-by-step to see the effect of your changes. I would strongly recommend to copy-paste the code into a Python scripted module (as described in the [programming tutorial](https://www.slicer.org/wiki/Documentation/Nightly/Training#Slicer4_Programming_Tutorial)) and run it line by line using a [Python debugger](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#How_can_I_use_a_visual_debugger_for_step-by-step_debugging). If you are not confident with Python syntax, then spend a couple of days completing basic Python tutorials.

---

<div class="post-metadata">

**Author:** ![Nuria](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@Nuria](https://discourse.slicer.org/u/Nuria)\
**Post date:** [October 10, 2018, 1:47pm UTC](https://discourse.slicer.org/t/how-to-obtain-a-report-table-of-the-histogram-of-grayvalues/4330/8 "2018-10-10T13:47:02Z")

</div>

Thanks a lot, I will try it
