How to read and process a '.seg' or '.seg.vtm' files in a CLI 3DSlicer module

Hello Friends!!!

i need to load and process image files generated for a RT planning. Among those files, there is this ‘.seg’ or ‘.seg.vtm’ files which I would like to read and treat like a label map.

Can anyone here give me a hint on it?

Thank you!

CLI modules currently only use non-overlapping labelmaps as input/output. If you have time and some C++ programming experience then it would not be too difficult to add it (we can help you to get started). If not, then you can export the segmentation node to a labelmap node using Segmentations module Import/Export section.

Hey Dr. Lasso,

I do have some time and a bit of c++ experience. Would like learn how to read and process this… how can I get started?

I’ll also try the segmentation module functions…

Thanks a lot.

Great! The first step is to build Slicer. Then, you have to improve vtkSlicerCLIModuleLogic::ApplyTask method so that when the input is a vtkMRMLSegmentationNode it can write it to a file.

Dr. Lasso,

Is there any loss or limitation in the Export/Import function of the Segmentations module?

Thanks!

There is no information loss during export. You only lose information if you convert between different representations (closed surface <-> binary labelmap; overlapping segments stored in a 4D volume -> single 3D labelmap containing all segments).

First, I would recommend to make Segmentation nodes show up in image type="label" elements. If user selects a segmentation node then we would export the segmentation to a merged labelmap. Later, we can add support for overlapping labels, by introducing a new type="overlapping-label", in which case we would write the segmentation to file as a 4D volume.

We could also make Segmentation nodes show up for geometry type="model" elements, as Segmentation nodes can also be saved as surface models.

I am not a slicer expert but it is just an idea:

if we save more than one color information in the same voxel value, then we can use a 3D volume instead of 4 D e.g. by storing each color value in specific bits, we will have short range of colors but this should be OK as usually we don’t have too many segmentations parts in one image.

Yes, that’s the first step I’m proposing. You can get a “merged labelmap” from the segmentation, which is a single 3D volume, just like those that are stored in labelmap volume nodes.

Thank you, guys. Those information are new to me. I’ll try to read a little and check what is the best way to use it.

Right now, my aim is to use the segmentation areas delimited in an RT planning (.seg file) as a CT image ROI in a numerical analysis.

Thanks again.

Leonardo Machado
Mestre e Doutorando em Física Aplicada a Medicina e Biologia

Laboratório de Computação em Sinais e Imagens Médicas - CSIM

Faculdade de Filosofia, Ciencias e Letras de Ribeirão Preto

Universidade de São Paulo

Cel +55 16 99458 4435

Tel +55 16 3315 0376

leonardomachado@usp.br

leodemachado@gmail.com

“Entrega o teu destino a Deus, confia nEle, e com certeza Ele agirá.”

Sl 36(37), 5.

Note that you can do numerical analysis very efficiently in Python. If you use Python, then you don’t need to implement sending of Segmentation node to CLI modules. You can get a segmentation as numpy array by calling slicer.util.arrayFromSegment(segmentationNode, segmentId).