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 @@ -25,6 +25,18 @@ def set_series_description(self, description: str):
"""

self.ds.SeriesDescription = description

def roi_number(self):
ROI_list = self.ds.StructureSetROISequence
ROI_number = []
for i in range(len(ROI_list)):
ROI_number.append(ROI_list[i].ROINumber.numerator)
Comment on lines +30 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use list comprehension here to simplify

Suggested change
ROI_list = self.ds.StructureSetROISequence
ROI_number = []
for i in range(len(ROI_list)):
ROI_number.append(ROI_list[i].ROINumber.numerator)
roi_numbers = [roi.ROINumber.numerator for roi in self.ds.StructureSetROISequence ]

note we have been using lowercase for ROI, we should remain consistent

j = 0
while j in ROI_number :
j = j+1
return j

"""choose a ROI number which has not been attributed to the ROI already existing the original RTstructure. This might prevent duplicate and error in opening"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should be placed after the function declaration

def roi_number(self):
    """
    choose a ROI number which has not been attributed to the ROI already existing the original RTstructure. This might prevent duplicate and error in opening
    """


def add_roi(
self,
Expand All @@ -44,12 +56,12 @@ def add_roi(
"""

# TODO test if name already exists
self.validate_mask(mask)
roi_number = len(self.ds.StructureSetROISequence) + 1
self.validate_mask(mask)
roi_number = self.roi_number()
roi_data = ROIData(
mask,
color,
roi_number,
color,
roi_number,
name,
self.frame_of_reference_uid,
description,
Expand Down