Skip to content

Commit

Permalink
Merge pull request #279 from nanli-emory/master
Browse files Browse the repository at this point in the history
error check if mask is empty and abort early in LocalTextureEstimationModule.estimateGreyComatrixFeatures
  • Loading branch information
nanli-emory authored Jan 9, 2024
2 parents 0e688ed + df80baf commit 72d1093
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions histoqc/LocalTextureEstimationModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def estimateGreyComatrixFeatures(s, params):
img = color.rgb2gray(img)

mask = s[mask_name] if not invert else ~s[mask_name]
if len(mask.nonzero()[0]) == 0: # add warning in case the no tissus detected in mask
msg = f"LocalTextureEstimationModule.estimateGreyComatrixFeatures:{prefix} Can not estimate the empty mask since NO tissue remains detectable in mask"
logging.warning(f"{s['filename']} - {msg}")
s["warnings"].append(msg)
return

maskidx = mask.nonzero()
maskidx = np.asarray(maskidx).transpose()
idx = np.random.choice(maskidx.shape[0], npatches)
Expand Down

0 comments on commit 72d1093

Please sign in to comment.