Skip to content

Instantly share code, notes, and snippets.

@asim-shrestha
Created February 2, 2021 18:52
Show Gist options
  • Save asim-shrestha/21364af5c110f5469a8123956fe250e4 to your computer and use it in GitHub Desktop.
Save asim-shrestha/21364af5c110f5469a8123956fe250e4 to your computer and use it in GitHub Desktop.
from rt_utils import RTStructBuilder
import matplotlib.pyplot as plt
# Load existing RT Struct. Requires the series path and existing RT Struct path
rtstruct = RTStructBuilder.create_from(
dicom_series_path="./testlocation",
rt_struct_path="./testlocation/rt-struct.dcm"
)
# View all of the ROI names from within the image
print(rtstruct.get_roi_names())
# Loading the 3D Mask from within the RT Struct
mask_3d = rtstruct.get_roi_mask_by_name("ROI NAME")
# Display one slice of the region
first_mask_slice = mask_3d[:, :, 0]
plt.imshow(first_mask_slice)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment