How to save labelmap information in a volumetric mesh?

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!

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).

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)

You can get point (node) positions as numpy array using arrayFromModelPoints, material ID from cell data using 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.

Thanks Andreas!

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

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.

1 Like