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.11k stars 485 forks source link

[BUG] pyradiomics returns np.complex128 for some shape features for specific mask #843

Open kretes opened 8 months ago

kretes commented 8 months ago

Describe the bug First of all thanks for the effort in bringin pyradiomics to life! We use it in our research pipeline. I encountered a strange situation where for some cases I get an np.complex128 as return type for shape features:

When I filter all the features with complex type I get: [('original_shape_Elongation', (1.3384577598333993e-09+7.0338692994926e-10j)), ('original_shape_Flatness', (1.3384577598333993e-09-7.0338692994926e-10j)), ('original_shape_LeastAxisLength', (2.779484065372328e-07-1.460675728630001e-07j)), ('original_shape_MajorAxisLength', (207.66318884193223+0j)), ('original_shape_MinorAxisLength', (2.779484065372328e-07+1.460675728630001e-07j))] This is unexpected, since all the features should be simple types

PyRadiomics configuration no

PyRadiomics log file

2023-10-23 21:46:08 Enabled image types: {'Original': {}}
2023-10-23 21:46:08 Enabled features: {'firstorder': [], 'glcm': [], 'gldm': [], 'glrlm': [], 'glszm': [], 'ngtdm': [], 'shape': []}
2023-10-23 21:46:08 Calculating features with label: 1
2023-10-23 21:46:08 Loading image and mask
2023-10-23 21:46:11 Computing shape
2023-10-23 21:46:11 Adding image type "Original" with custom settings: {}
2023-10-23 21:46:11 Calculating features for original image
2023-10-23 21:46:11 Computing firstorder
2023-10-23 21:46:11 Computing glcm
GLCM is symmetrical, therefore Sum Average = 2 * Joint Average, only 1 needs to be calculated
2023-10-23 21:46:12 GLCM is symmetrical, therefore Sum Average = 2 * Joint Average, only 1 needs to be calculated
2023-10-23 21:46:12 Computing gldm
2023-10-23 21:46:12 Computing glrlm
2023-10-23 21:46:13 Computing glszm
2023-10-23 21:46:14 Computing ngtdm

To Reproduce It happens for a particular segmentation that has 2 separated voxels. I managed to reproduce it at https://gist.github.com/kretes/83790cb03d2b0d32422e2c180b71f69b

Expected behavior expected to get correct numerical value

Version (please complete the following information):

Additional context