Skip to content

Commit

Permalink
LOG: Update logging during mask loading
Browse files Browse the repository at this point in the history
- Fix a bug in the check for presence of the label
- Raise error when resegmentation excludes all voxels in the ROI
  • Loading branch information
JoostJM committed Mar 19, 2019
1 parent 8df1190 commit 6d385a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion radiomics/imageoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def checkMask(imageNode, maskNode, **kwargs):
# If lsif fails, and mask is corrected, it includes a check whether the label is present. Therefore, perform
# this test here only if lsif does not fail on the first attempt.
if label not in lsif.GetLabels():
raise ValueError('Label (%g) not present in mask', label)
raise ValueError('Label (%g) not present in mask' % label)
except RuntimeError as e:
# If correctMask = True, try to resample the mask to the image geometry, otherwise return None ("fail")
if not kwargs.get('correctMask', False):
Expand Down Expand Up @@ -651,6 +651,9 @@ def resegmentMask(imageNode, maskNode, **kwargs):

roiSize = numpy.sum(ma_arr)

if roiSize == 0:
raise ValueError("Resegmentation excluded all voxels with label %i! Cannot extract features" % label)

# Transform the boolean array back to an image with the correct voxels set to the label value
newMask_arr = numpy.zeros(ma_arr.shape, dtype='int')
newMask_arr[ma_arr] = label
Expand Down

0 comments on commit 6d385a1

Please sign in to comment.