Converting RTStruct to Dicom SEG for Pyradiomics

Hi all!

I am new here, and have been recently struggling with the following.

I have a dataset from TCIA I am hoping to analyze containing a CT series and associated segmentations in RTStruct format. Although, I can extract radiomic features through the GUI, I am hoping to use script this in python specifically and use pyradiomics-labs to process the dicom imagery.

Using dcmrtstruct2nii, I have been able to extract .nii masks of all the features from the RTStruct, and similarly using SimpleITK, have convered it to a .nrrd format. However, this is where I am stuck trying to convert either of these masks to a Dicom SEG object.

It may be simpler at this point to convert my dicom series to .nrrd potentially.

Thanks for the help!

It seems it may actually be easier to just convert my dicom serise to nrrd for now.

I don’t know how dcmrtstruct2nii works, but in SlicerRT we have a quite sophisticated algorithm that can convert the antiquated contour set to an interpolated surface and then labelmap. If you’re interested after all let me know. All you need are the SlicerRT and DCMQI extensions.

SlicerRT is excellent, I was using it in the GUI.

Is there an available API or a way to script it to work over multiple files without user intervention?

dcmrtstruct2nii seemed to work well for the meantime. It took ~5h to convert about 400 RtStruct files with ~20 masks within each. Not sure if this is fast or slow haha.

We have a script in the repo that batch-converts RTSS to nrrd. It is not a long way from here to DICOM SEG.

I hope it still works, this one is not regularly tested. Let me know if anything comes up!