qurit / rt-utils

A minimal Python library to facilitate the creation and manipulation of DICOM RTStructs.
MIT License
191 stars 56 forks source link

RTSTRUCT slice interpolation #17

Open DylanHsu opened 3 years ago

DylanHsu commented 3 years ago

Dear RT-UTILS authors,

Firstly, thank you for this wonderful and helpful library. It is amazing to use.

I would like to make a feature suggestion. I am not aware of any existing tool for resampling the RTSTRUCT pointsets into a different 3D geometry, which is a nontrivial problem. Existing tools are capable of handling different pixel spacing using workarounds, but not different slice spacing. For example, I could prepare a dummy CT series with different pixel spacing, and pass it to RTStructBuilder.create_from. Similar hacking is possible in Plastimatch using a dummy reference series or image file e.g. Nifti format. However, to get to a different slice spacing, nearest-neighbor interpolation is still required. I believe that a more intelligent way to handle this, starting from the pointsets and not the voxel masks, would be a choice addition to RT-UTILS.

Best regards, Dylan Hsu, Ph.D Memorial Sloan-Kettering Cancer Center

awtkns commented 3 years ago

HI @DylanHsu ,

Thanks for the feedback, we are happy RT-UTILS being received well and used in the public.

With regards pointsets vs voxel masks, I am not entirely sure this is possible with the RT-Struct standard as each mask is usually associated with a slice. Do you have an example use case?

We are always open to PRs 😄

DylanHsu commented 3 years ago

Hi Adam,

I can give an example where the aforementioned feature would help. As you probably know, to apply machine learning techniques to medical images, it's imperative to standardize your input data. Let's say we have a patient dataset with CT images and RTSTRUCT files containing the ground truth. Our CT images have non-uniform CT slice thickness, but we need rasterized 2D (3D) voxel data with a uniform voxel spacing. We choose the minimum slice thickness of all series, rasterize each structure set to its native slice spacing, then resample to the intended spacing using nearest-neighbor interpolation. Perhaps we have lost some quality in resampling those pointsets, which could be recovered by treating the pointset as some kind of polyhedron and determining a new pointset from intersecting planes of the intended spacing.

Proprietary software such as MIM have a feature to resample structure set to a different pixel and slice spacing, but I'm not sure if the structures are first rasterized and resampled into the new spacing, or if they are interpreted more intelligently from the pointset.

I'd be happy to contribute to a PR in the future.

All the best Dylan

awtkns commented 3 years ago

Hi Dylan. If you wanted to try and PR this that would be great. My one concern is that this could be out scope for Rt-utils as this seems to be more pixel manipulation rather then rt-utils core focus of rt-struct creation from masks.

Thoughts @carluri?