Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File type for ML masks #83

Closed
MattAWard opened this issue Feb 24, 2023 · 3 comments
Closed

File type for ML masks #83

MattAWard opened this issue Feb 24, 2023 · 3 comments

Comments

@MattAWard
Copy link

MattAWard commented Feb 24, 2023

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.

@sunyu0410
Copy link

@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()

@danihinjos
Copy link

Hi! How do you exactly convert a NifTI file in numpy array into a RTStruct? It's unclear :/

@MattAWard
Copy link
Author

MattAWard commented Jun 1, 2023

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

@plesqui plesqui closed this as completed Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants