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

How to export rt structure set #113

Closed
darcymason opened this issue Nov 27, 2014 · 10 comments
Closed

How to export rt structure set #113

darcymason opened this issue Nov 27, 2014 · 10 comments

Comments

@darcymason
Copy link
Member

From miki...@gmail.com on February 14, 2012 18:47:57

Is it possible to export contour data to dicom rt structure set right within this lib?

Thank you

Original issue: http://code.google.com/p/pydicom/issues/detail?id=112

@darcymason
Copy link
Member Author

From darcymason@gmail.com on February 14, 2012 18:48:06

Is it possible to export contour data to dicom rt structure set right within this lib?

Yes it is ... see reply on the discussion group.

@darcymason
Copy link
Member Author

From darcymason@gmail.com on February 15, 2012 17:55:16

Status: Verified

@argman
Copy link

argman commented Sep 2, 2017

@darcymason hi, I am also trying to export a rt file, but where is the discuss..

@darcymason
Copy link
Member Author

darcymason commented Sep 2, 2017

Can you be more specific please? Are you creating the file from scratch? There is an example in the repository showing what needs to be set for basic file writing.

The discussion referred to was probably this one. Quite old, so the setting items issue should no longer be relevant. Anyway, my answer there gives a quick idea of how to assign down the nested structures to the ContourData.

@darcymason
Copy link
Member Author

Oh, and there is the codify utility, which takes an existing file and produces a complete pydicom code to create that file. So find a DICOM file that is similar to your needs, and you can have an exact template for the code needed to make one like it.

@argman
Copy link

argman commented Sep 3, 2017

@darcymason , tks for this, I've just tried it, really awesome!

@asim-shrestha
Copy link

asim-shrestha commented Feb 13, 2021

Hey, though its been years since this thread was created, a team and I actually wrote a small Python package called RT-Utils that deals with easily creating RTStructs. If you already have series masks you would like segmented as contours, it should be a lot simpler than using the codify utility. You can find the package here for better documentation and you can install the package via pip.

Sample code:

from rt_utils import RTStructBuilder

# Create new RT Struct. Requires the DICOM series path for the RT Struct.
rtstruct = RTStructBuilder.create_new(dicom_series_path="./testlocation")

# Your code to generate the segmentation mask
segmentation_mask = get_segmentation_mask()

# Add the 3D mask as an ROI.
rtstruct.add_roi(mask=segmentation_mask)

# Save the resulting RT Struct
rtstruct.save('new-rt-struct')

For further info, check out this blogpost.

@renatobellotti
Copy link

The link to the blog post seems to be dead. Is there a new location?

@mrbean-bremen
Copy link
Member

@renatobellotti - I found the post and updated the link.

@renatobellotti
Copy link

Nice, thanks! This lools very interesting. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants