# segment to numpy array

**URL:** <https://discourse.slicer.org/t/segment-to-numpy-array/12942>\
**Category:** Support\
**Created:** [August 11, 2020, 1:39pm UTC](https://discourse.slicer.org/t/segment-to-numpy-array/12942 "2020-08-11T13:39:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrielzhu1977](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@gabrielzhu1977](https://discourse.slicer.org/u/gabrielzhu1977)\
**Post date:** [August 11, 2020, 1:39pm UTC](https://discourse.slicer.org/t/segment-to-numpy-array/12942/1 "2020-08-11T13:39:13Z")

</div>

Hello All,

I need to study the density histogram of ROI on CT so I am trying to get a numpy array out of a segment. But when I convert segmentation node to labelmap node and then to numpy array, I only have binary array(0, or 1). I want a array with exact value of ROI on CT.  
Could anyone help me with this?  
Thanks for any help and advice.

Gabriel

---

<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:** [August 11, 2020, 4:05pm UTC](https://discourse.slicer.org/t/segment-to-numpy-array/12942/2 "2020-08-11T16:05:51Z")

</div>

You can use the array of 0/1 as a mask in numpy processing operations, or just blank out values in the CT (set to -10000) where the mask is 0.

See this complete example: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Mask\_volume\_using\_segmentation](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Mask_volume_using_segmentation)
