Sikerdebaard / dcmrtstruct2nii

DICOM RT-Struct to mask
MIT License
93 stars 26 forks source link

Code to fix in cases of a hole existed in the mask #32

Closed soanduong closed 1 year ago

soanduong commented 2 years ago

The existing version works perfectly in cases of there is no hole in the mask. However it is not correct if a hole existed (i.e. in a slice, there is more than one contours). I found a simply way to address the issue by modify line 48 in dcmrtstruct2nii/adapters/convert)/rtstructcontour2mask.py by three lines of code as follows:

ex_mask = np_mask[z, ...] > 0

np_mask[z, ex_mask & filled_poly] = mask_background

np_mask[z, ex_mask ^ filled_poly] = mask_foreground
Sikerdebaard commented 1 year ago

A somewhat similar approach has been implemented through PR #37. Please upgrade to v3 to enable the new approach that supports holes out-of-the-box. pip install --upgrade dcmrtstruct2nii==5.