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

add ability to retrieve ROI names in a case insensitive way #47

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

raffaelespinoni
Copy link

No description provided.

@raffaelespinoni
Copy link
Author

issue targeted by the PR: link

@awtkns awtkns linked an issue Feb 22, 2022 that may be closed by this pull request
Copy link
Contributor

@awtkns awtkns left a comment

Choose a reason for hiding this comment

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

Thanks for this @raffaelespinoni!

@asim-shrestha this LGTM! I added a couple tests for this, one of which is currently failing until my comment below is resolved (NPE issue).

@@ -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():
Copy link
Contributor

@awtkns awtkns Feb 22, 2022

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.

@asim-shrestha
Copy link
Contributor

We should make this an optional function in get_roi instead of the default. I imagine there may be other existing rt_structs that are sensitive in regards to naming. Do we know if thats allowed by the dicom standards?

@awtkns
Copy link
Contributor

awtkns commented Jan 27, 2023

@asim-shrestha thoughts on either merging this or closing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add ability to retrieve ROI names in a case insensitive way
3 participants