GateTools icon indicating copy to clipboard operation
GateTools copied to clipboard

gt_image_to_dicom_rt_struct ?

Open tbaudier opened this issue 5 years ago • 3 comments

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

tbaudier avatar Jun 19 '20 08:06 tbaudier

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

  1. use the existing gt_dicom_rt_struct_to_image to convert a given ROI from DICOM structure and a given image into a mask
  2. use the new gt_image_to_dicom_rt_struct to convert that mask and the given image into a new ROI
  3. use the existing gt_dicom_rt_struct_to_image to 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).

djboersma avatar Jun 19 '20 08:06 djboersma

Do we have use cases for this?

djboersma avatar Jun 19 '20 08:06 djboersma

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.

tbaudier avatar Jun 19 '20 09:06 tbaudier