Closed MattAWard closed 1 year ago
@MattAWard As long as you can convert the NIfTI file into a numpy array, then you can incorporate that using rt-utils
. You can use nibabel
to read a nii.gz
and get the numpy array.
import nibabel as nib
nii = nib.load('path/to/.nii.gz')
arr = nii.get_fdata()
Hi! How do you exactly convert a NifTI file in numpy array into a RTStruct? It's unclear :/
Thanks @sunyu0410 and that bit isn't too bad @danihinjos you just do
rtstruct.add_roi(mask=arr, name=roi_name)
rtstruct.save(destination_folder)
I have a loop in my Python code that adds ROIs recursively then saves the rtstruct
What file type/ format are the masks expected to be in to create the RTStruct files? We're currently trialling a ML auto segmentation solution which outputs anatomical models as separate nii.gz (zipped nifti) files. Do you know if files of this type can be converted into the required format for them to be packaged into an RTStruct file? Thanks.