PyESAPI icon indicating copy to clipboard operation
PyESAPI copied to clipboard

Fast (approximate) structure mask implementation

Open fizxmike opened this issue 7 months ago • 1 comments

Implemented fast structure mask creation leveraging OpenCV's cv2.fillpoly(...) with contours from each slice read from ESAPI's Structure.GetContoursOnImagePlane(...). Boolean output only, when a lower slice (z) resolution is requested, the mask is generated based on the contours on the original CT slice intersected by the mid-plane of the lower resolution (requested) slice.

Example usage (CT grid): mask_ct_res = plan.StructureSet.np_mask_for_structure_fast(structure, plan.StructureSet.Image)

Mask for dose grid: mask_dose_res = plan.StructureSet.np_mask_for_structure_fast(structure, plan.Dose)

fizxmike avatar Jul 01 '25 19:07 fizxmike

The super sampling implementation increases the accuracy significantly. I chose 8 as the super sampling factor default after some empirical experimentation comparing a fairly complex mask slice between the original PyESAPI method and this new/fast/approximate method. Maybe 6 could work too, but a better study would involve impact on DVH.

image

fizxmike avatar Jul 01 '25 21:07 fizxmike