add ability to retrieve ROI names in a case insensitive way#47
Open
raffaelespinoni wants to merge 5 commits intoqurit:mainfrom
Open
Conversation
Author
|
issue targeted by the PR: link |
awtkns
reviewed
Feb 22, 2022
Contributor
There was a problem hiding this comment.
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).
rt_utils/rtstruct.py
Outdated
|
|
||
| for structure_roi in self.ds.StructureSetROISequence: | ||
| if structure_roi.ROIName == name: | ||
| if structure_roi.ROIName.casefold() == name.casefold(): |
Contributor
There was a problem hiding this comment.
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.
awtkns
approved these changes
Feb 23, 2022
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? |
Contributor
|
@asim-shrestha thoughts on either merging this or closing? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.