gt_image_to_dicom_rt_struct ?
Hi all, Hi @djboersma ,
Do you think it's possible to create a tool converting binary mask to DicomRTStruct; the opposite of gt_dicom_rt_struct_to_image?
Thank you
I think it is "kind of possible": for every layer, draw contours around the contiguous islands of "enabled" voxels. There are many ways to do this, probably, each with their pros and cons. The algorithm for identifying the "contiguous islands" is an interesting intellectual exercise, though it probably has been solved many times already in mathematics and in code; it's probably part of lots of pattern recognition algorithms. Maybe the "shapely" module has something to offer here?
I wrote "kind of possible" instead of "possible" because the tool will not be an exact inverse of gt_dicom_rt_struct_to_image, even when the mask/image has the z-step identical to the distance between the contours in the structure set. But if you do the following ...
- use the existing
gt_dicom_rt_struct_to_imageto convert a given ROI from DICOM structure and a given image into a mask - use the new
gt_image_to_dicom_rt_structto convert that mask and the given image into a new ROI - use the existing
gt_dicom_rt_struct_to_imageto convert the new ROI and the given image (same as in 1.) into another mask
... then the masks created in step 1 and 3 should be identical. So the original ROI and the new ROI have different contours but are "equivalent" in the sense that they include/exclude the same sets of voxels (only for the "given image", because for other images with different voxel geometry they may not be equivalent, due to the slightly different contours).
Do we have use cases for this?
Thank you for you answer,
We already have a tool in c++ (the code is here https://github.com/open-vv/vv/blob/master/common/clitkImage2DicomRTStructFilter.txx but it's complicated to install it with an external GDCM) and it use VTK to convert binary image to a mesh.
But I wondered if what you implemented in roi_utils.py could be useful to do such a tool in Python. If I have time I will investigate using vtk python wrapping.
Yes we have use case, usually to put ROI in clinical software we already drew.