# binary label map layers

**URL:** https://discourse.slicer.org/t/binary-label-map-layers/14700
**Category:** Support
**Tags:** segmentation
**Created:** [November 20, 2020, 4:40am UTC](https://discourse.slicer.org/t/binary-label-map-layers/14700 "2020-11-20T04:40:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dzf](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@dzf](https://discourse.slicer.org/u/dzf)
#### Post date: [November 20, 2020, 4:40am UTC](https://discourse.slicer.org/t/binary-label-map-layers/14700/1 "2020-11-20T04:40:39Z")

</div>

Operating system: windows 10  
Slicer version: 4.11.20200930  
Expected behavior: keep every segment in different layer when saving after annotation  
Actual behavior: all segments merged in one layer

 ![0](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/1/c1dbc347c7ecd9c5ae4bcbe6f315c3016c93fe9d.jpeg)  
 ![1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/3/d34434de9a72bf9f49f9506f557587727ae380e7.jpeg)  
 ![2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/7/f7789cae8112f43bdaaf34f3c170f1208ef114a1.jpeg)

---

<div class="post-metadata">

### Author: ![dzf](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@dzf](https://discourse.slicer.org/u/dzf)
#### Post date: [November 20, 2020, 4:40am UTC](https://discourse.slicer.org/t/binary-label-map-layers/14700/2 "2020-11-20T04:40:50Z")

</div>

Operating system: windows10  
Slicer version: 4.11.20200930  
Expected behavior: every segment in different layers after saving  
Actual behavior: all segments are automatically collapse 1 layer after saving.  
how can i solve 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: [November 20, 2020, 4:49am UTC](https://discourse.slicer.org/t/binary-label-map-layers/14700/3 "2020-11-20T04:49:23Z")

</div>

A few years ago we did not collapse layers and it led to lots of complaints an inefficiencies. Therefore, I would recommend to keep using the collapsed format and use these code snippets to retrieve metadata and pixel data of segments: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get\_information\_from\_segmentation\_nrrd\_file\_header](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_information_from_segmentation_nrrd_file_header)

If this does not work for you then you can submit a feature request to [issues.slicer.org](http://issues.slicer.org) asking for adding a flag to the storage node that can disable automatic collapsing on save.

---

<div class="post-metadata">

### Author: ![dzf](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@dzf](https://discourse.slicer.org/u/dzf)
#### Post date: [November 25, 2020, 11:33am UTC](https://discourse.slicer.org/t/binary-label-map-layers/14700/4 "2020-11-25T11:33:56Z")

</div>

thank you for your reply, i try your suggestion but can not solve my problem. if all segments are in one layer, and my question is when the segments in different layers, I can get the volume information of every segment by exporting the binary labelmap for every segment, and the volume information of each segement is correct, but now, all segments in one layer, when i export the binary labelmap, the volume of each segment is same as each other, and the volume information actually is the volume of the combination of all segments, this is incorrect for me. how can i get the volume information of each segment correctly?

---

<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: [November 25, 2020, 2:18pm UTC](https://discourse.slicer.org/t/binary-label-map-layers/14700/5 "2020-11-25T14:18:15Z")

</div>

> [@dzf](#):
>
> how can i get the volume information of each segment correctly?

You can use [Segment Statistics module](https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentstatistics.html) to get volume of each segment (and many other metrics, such as surface, bounding box, mean intensity, sphericity, principal axes, …).

If you prefer to compute these yourself then you can extract a single labelmap from a numpy array by indexing, for example you can get segment with label value 5 from `mylabelmap` numpy array like this `segment5 = mylabelmap[mylabelmap==5]`.
