# How can I get an array from seg.nrrd file in Python?

**URL:** <https://discourse.slicer.org/t/how-can-i-get-an-array-from-seg-nrrd-file-in-python/37842>\
**Category:** Development\
**Tags:** segmentation, python, segmentations, segment-editor\
**Created:** [August 12, 2024, 12:39pm UTC](https://discourse.slicer.org/t/how-can-i-get-an-array-from-seg-nrrd-file-in-python/37842 "2024-08-12T12:39:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rim](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@rim](https://discourse.slicer.org/u/rim)\
**Post date:** [August 12, 2024, 12:39pm UTC](https://discourse.slicer.org/t/how-can-i-get-an-array-from-seg-nrrd-file-in-python/37842/1 "2024-08-12T12:39:19Z")

</div>

I want to read the data from the seg.nrrd file using the nrrd.read() function and obtain it in array format as a 3D array. However, the data in the seg.nrrd file consists only of arrays filled with zeros.

What might I be missing?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/a/2a87c52057bfa27829489fc5775261f65e143f66.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:** [August 12, 2024, 12:42pm UTC](https://discourse.slicer.org/t/how-can-i-get-an-array-from-seg-nrrd-file-in-python/37842/2 "2024-08-12T12:42:27Z")

</div>

You are probably not missing anything. Labelmap files containing segmentations are usually mostly zeros.

What do you get if you run this command?

```python
print(np.count_nonzero(label_mask))

```
