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

revised get_roi_names for geometric type (#99) #100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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