Convert nifti segmentation mask to DICOM RTstruct

I have segmented some brain areas and have the results as a binary mask in a nifti file. I now need to convert the nifti file into a DICOM RTstruct file, which stores contours (coordinates) for each slice in the volume. I can get the coordinates using a function in scikit-image, but it is not clear how to save them into a DICOM RTstruct file. I have found tools for dcmtrstuct2nii but not the opposite. Has anyone done this before?

I would suggest you try 3D Slicer. I have posted a question on their forum, but you may want to write your own specific question on their forum if you have issues.

I need to run it inside a Docker container, so I ended up making my own Python script

MANAGED BY INCF