qurit / qurit/rt-utils

Return ROI names of geometric type

Open
#99 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
256
Forks
75
PR merge metrics
No merged PRs in 30d

Description

Hello,
In using the package I tended to call get_roi_names() to obtain a list of structures that I would like to retrieve a mask for, then retrieved the masks with the function get_roi_mask_by_name(). However, it ran into problems when there are different geometric types in the RTSTRUCT, especially the 'POINT' geometries. Generally if all of the contours are described as 'CLOSED_PLANAR' then the process works fine. But some datasets have these POINT ROIs and it is not always clear that they are from the name. So my proposal is to have another optional argument to get_roi_names() to specify the geometries we want to return. Default behaviour is the original version of listing all names. To get all CLOSED_PLANAR structures only we would call rtstruct_ds.get_roi_names('CLOSED_PLANAR') where rtstruct_ds is the rtstruct object from this repository. Here is the modified function below in rtstruct.py.

def get_roi_names(self, geometry = '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:
            return []
        
        if geometry == 'ALL':
            return [
                structure_roi.ROIName for structure_roi in self.ds.StructureSetROISequence
            ]
        
        return [
                self.ds.StructureSetROISequence[i].ROIName 
                for i in range(0,len(self.ds.ROIContourSequence)) 
                if self.ds.ROIContourSequence[i].ContourSequence[0].ContourGeometricType==geometry
            ]

Let me know if this is useful to incorporate, it certainly is for my work as I had to do this check separately outside this package.

Best wishes,
Matt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in rtstruct.py at get_roi_names() and compare it with get_roi_mask_by_name(), then review how ROI and contour sequences represent geometric types. Done means the default still returns all ROI names while an optional geometry argument returns only matching structures, including CLOSED_PLANAR and POINT cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.