# How to save labelmap information in a volumetric mesh?

**URL:** <https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163>\
**Category:** Support\
**Tags:** segmentation, segmentmesher, meshing\
**Created:** [August 11, 2021, 10:57pm UTC](https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163 "2021-08-11T22:57:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matheus](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Matheus](https://discourse.slicer.org/u/Matheus)\
**Post date:** [August 11, 2021, 10:57pm UTC](https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163/1 "2021-08-11T22:57:19Z")

</div>

Hello everyone!

I segmented some DICOM files and turned the segmentation into a volumetric mesh. I have different segments for different biological tissues and I want to store the segment ID information after transforming it into a volumetric mesh. It seems that when the .vtk file is created this information is somehow lost. I say this because when I read the file in python the mesh volume appears as just one segment. Does anyone know how to help?

In short: How to save labelmap information in a volumetric mesh?

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:** [August 12, 2021, 3:42am UTC](https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163/2 "2021-08-12T03:42:34Z")

</div>

Segment ID is stored as a cell data in the mesh and it is saved into .vtk/.vtu files. If you load the mesh file and you want to see the different materials then you need to enable scalar display in Models module (and may need to cut into the mesh to see different segments).

---

<div class="post-metadata">

**Author:** ![Matheus](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Matheus](https://discourse.slicer.org/u/Matheus)\
**Post date:** [August 12, 2021, 3:57pm UTC](https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163/3 "2021-08-12T15:57:26Z")

</div>

Thanks Andreas!  
That worked!

I still need to extract the node, face and element information (uchar format) from .vtk file. Do you know how I can do this in python? (I’m trying to use meshio or pymesh)

---

<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, 2021, 5:12pm UTC](https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163/4 "2021-08-12T17:12:59Z")

</div>

You can get point (node) positions as numpy array using [arrayFromModelPoints](https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#slicer.util.arrayFromModelPoints), material ID from cell data using [arrayFromModelCellData](https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#slicer.util.arrayFromModelCellData), etc. If you want to access more mesh properties, cell connectivity, etc. then you can do it by a few lines of Python code - see examples [here](https://github.com/Slicer/Slicer/blob/1a692bf36e9c99c47661fbf5fdba0fd3c3e72f95/Base/Python/slicer/util.py#L1494-L1507).

---

<div class="post-metadata">

**Author:** ![Matheus](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Matheus](https://discourse.slicer.org/u/Matheus)\
**Post date:** [August 17, 2021, 12:52pm UTC](https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163/5 "2021-08-17T12:52:14Z")

</div>

Thanks Andreas!

I still need one more thing: where do I get the modelNode information?

---

<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 17, 2021, 6:01pm UTC](https://discourse.slicer.org/t/how-to-save-labelmap-information-in-a-volumetric-mesh/19163/6 "2021-08-17T18:01:13Z")

</div>

For testing, you can get modelNode by node name, for example `modelNode = getNode('MyNodeName')`. In a module typically users choose input/output nodes using node selector widgets.
