Open qiancao opened 2 years ago
This is because in imageoperations.py (lines 47-49):
labels = numpy.unique(sitk.GetArrayFromImage(mask))
if len(labels) == 1:
raise ValueError('No labels found in this mask (i.e. nothing is segmented)!')
The use of numpy.unique checks for number of unique values in the mask image. I think this is inaccurate. The error message: "No labels found in this mask (i.e. nothing is segmented)!" should be interpreted as: when the mask image is all zeros (everything is background and nothing is segmented).
I suggest changing line 48 to:
if np.all((sitk.GetArrayFromImage(mask) == 0)):
I met the same problem
Describe the bug I didn't find clarification on this problem in the forums, and I don't think this is expected behavior, so I'm filing it under "bug". As the subject line states, RadiomicsFeatureExtractor.execute does not work when I have a mask of all ones (compute features using all voxels in the image).
The error thrown is: ValueError: No labels found in this mask (i.e. nothing is segmented)!
A hacky way to deal with this is to set a corner voxel to background, then it runs without issues.
To Reproduce Steps to reproduce the behavior (Scenario 1 fails and Scenario 2 works, albeit leaving out a single voxel from the calculation):
Expected behavior PyRadiomics should take a mask image of all ones and recognize that I would like the features to be computed on all voxels of the image.
Version (please complete the following information):