Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions rt_utils/rtstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,29 @@ def validate_mask(self, mask: np.ndarray) -> bool:

return True

def get_roi_names(self) -> List[str]:
def get_roi_names(self, geometry: str = 'ALL') -> List[str]:
"""
Returns a list of the names of all ROI within the RTStruct
Optional argument to return only ROI of specific geometric type: E.g. [CLOSED_PLANAR, POINT]
"""

if not self.ds.StructureSetROISequence:
print("StructureSetROISequence is empty.")
return []

return [
structure_roi.ROIName for structure_roi in self.ds.StructureSetROISequence
]
if geometry == 'ALL':
return [
structure_roi.ROIName for structure_roi in self.ds.StructureSetROISequence
]
if geometry in ['CLOSED_PLANAR', 'OPEN_PLANAR', 'OPEN_NONPLANAR', 'POINT']:
return [
self.ds.StructureSetROISequence[i].ROIName
for i in range(0,len(self.ds.ROIContourSequence))
if self.ds.ROIContourSequence[i].ContourSequence[0].ContourGeometricType==geometry
]
else:
print(f"Unrecognised geometric type: {geometry}")
return []

def get_roi_mask_by_name(self, name) -> np.ndarray:
"""
Expand Down