When getting contour mask from mesh, if the image z spacing (dZ_s) is smaller than the minimum mesh vertices along the Z axis (dZ_m), the mask is generated at every dZ_m/dZ_s slices. For example, on some CBCT images, when going from resolution (1 x 1 x 3) mm^3 to (1 x 1 x 1) mm^3, the mask is generated every 3 slices (figure below).
Here is the cause of the problem
file path:
/opentps_core/opentps/core/data/_roiContour.py:ROIContour.getBinaryMask()
line 119
if len(zDiff) == 0:
from opentps.core.data.images._roiMask import ROIMask
return ROIMask(imageArray=None, name=self.name, origin=contourOrigin, spacing=contourSpacing,
displayColor=self._displayColor)
else:
if np.isfinite(zDiff[0]):
contourSpacing[2] = zDiff[0]
else:
contourSpacing[2] = minSpatialResolution
The fix is very small:
if len(zDiff) == 0:
from opentps.core.data.images._roiMask import ROIMask
return ROIMask(imageArray=None, name=self.name, origin=contourOrigin, spacing=contourSpacing,
displayColor=self._displayColor)
else:
contourSpacing[2] = zDiff.min()
# if np.isfinite(zDiff[0]):
# # contourSpacing[2] = zDiff[0]
# else:
# # contourSpacing[2] = minSpatialResolution
note that numpy.min() function automatically ignores np.nan entries.
