AIM-Harvard / pyradiomics

Open-source python package for the extraction of Radiomics features from 2D and 3D images and binary masks. Support: https://discourse.slicer.org/c/community/radiomics
http://pyradiomics.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.16k stars 500 forks source link

[FEAT EXTRACTION] Unable to extract features using a mask covering the whole image #658

Closed abrahampm closed 3 years ago

abrahampm commented 3 years ago

Hello, first of all, congratulations to @JoostJM and all of the people who have contributed developing this wonderful Python package.

Describe the bug Recently, I've been experiencing an issue regarding the feature extraction after upgrading PyRadiomics version from 2.2.0 to 3.0.1. I currently work with 2D images. For processing, I split high resolution images into small patches. Then I process each image patch separately. The problem is that in some cases I require to extract the features from the whole image, and after upgrading PyRadiomics to 3.0.1 version, it's throwing an error saying ValueError: No labels found in this mask (i.e. nothing is segmented)! and stopping the extraction process. I've found in other issues, like #596, where the same error was raised but in that case, they were trying to supply an empty mask, which is, from my point of view, a wrong input. In my case, I'm supplying a mask covering the whole image. I don't think this is a wrong input mask for feature extraction. My workaround was to remove these lines from the source code, although I knew that it wasn't a good solution. https://github.com/Radiomics/pyradiomics/blob/08bea7067e350303eead533b471aa60697b3b8c3/radiomics/imageoperations.py#L47-L49 I would like to suggest in this case that instead of raising an error and stopping the feature extraction, you could easily raise a warning to alert the user and continue with feature extraction.

Thanks in advance for your time.

Version:

JoostJM commented 3 years ago

Good catch! I'll update it a bit to include a check for 0, so it only fails if the mask only contains 0's

JoostJM commented 3 years ago

Removing that line of code won't break anything vital, so you can use that until the fix is part of the master or next release.

abrahampm commented 3 years ago

Ok, thanks for the support. Please, don't forget to do the fix and include it in next releases.