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