Skip to content
Open
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion rt_utils/rtstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_roi_mask_by_name(self, name) -> np.ndarray:
"""

for structure_roi in self.ds.StructureSetROISequence:
if structure_roi.ROIName == name:
if structure_roi.ROIName.casefold() == name.casefold():

@awtkns awtkns Feb 22, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

    def get_roi_mask_by_name(self, name: str) -> np.ndarray:
        """
        Returns the 3D binary mask of the ROI with the given input name
        """
        name = name.casefold() if type(name) is str else name

        for structure_roi in self.ds.StructureSetROISequence:
            if structure_roi.ROIName.casefold() == name:
                contour_sequence = ds_helper.get_contour_sequence_by_roi_number(
                    self.ds, structure_roi.ROINumber
                )
                return image_helper.create_series_mask_from_contour_sequence(
                    self.series_data, contour_sequence
                )

        raise RTStruct.ROIException(f"ROI of name `{name}` does not exist in RTStruct")

It may be safer to check that name is not none before calling .casefold() as shown above.

contour_sequence = ds_helper.get_contour_sequence_by_roi_number(
self.ds, structure_roi.ROINumber
)
Expand Down