Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] feature extractor stopped working (arrays used as indices must be of integer (or boolean) type) #601

Closed
mluerig opened this issue Jun 30, 2020 · 4 comments
Labels

Comments

@mluerig
Copy link

mluerig commented Jun 30, 2020

Describe the bug
Suddenly I can't run the feature extractor anymore (worked until a few weeks ago). Error message it get:

Traceback (most recent call last):

  File "<ipython-input-58-89ccd738bd53>", line 1, in <module>
    features = extractor.execute(img, mask, label=255)

  File "C:\Anaconda3\envs\pp\lib\site-packages\radiomics\featureextractor.py", line 327, in execute
    featureVector.update(self.computeFeatures(inputImage, inputMask, imageTypeName, **inputKwargs))

  File "C:\Anaconda3\envs\pp\lib\site-packages\radiomics\featureextractor.py", line 514, in computeFeatures
    for (featureName, featureValue) in six.iteritems(featureClass.execute()):

  File "C:\Anaconda3\envs\pp\lib\site-packages\radiomics\base.py", line 185, in execute
    self._calculateSegment()

  File "C:\Anaconda3\envs\pp\lib\site-packages\radiomics\base.py", line 222, in _calculateSegment
    for success, featureName, featureValue in self._calculateFeatures():

  File "C:\Anaconda3\envs\pp\lib\site-packages\radiomics\base.py", line 229, in _calculateFeatures
    self._initCalculation(voxelCoordinates)

  File "C:\Anaconda3\envs\pp\lib\site-packages\radiomics\glcm.py", line 111, in _initCalculation
    self.P_glcm = self._calculateMatrix(voxelCoordinates)

  File "C:\Anaconda3\envs\pp\lib\site-packages\radiomics\glcm.py", line 148, in _calculateMatrix
    P_glcm = numpy.delete(P_glcm, emptyGrayLevels - 1, 1)

  File "<__array_function__ internals>", line 6, in delete

  File "C:\Anaconda3\envs\pp\lib\site-packages\numpy\lib\function_base.py", line 4406, in delete
    keep[obj,] = False

IndexError: arrays used as indices must be of integer (or boolean) type

PyRadiomics configuration
setting:
binWidth: 1
padDistance: 0
force2D: True

To Reproduce

from radiomics import featureextractor
import SimpleITK as sitk
import six
import numpy as np

data=np.array([[ 0,  2,  1,  4,  4,  5,  6,  8,  8,  9, 10,  8,  8,  7,  5,  5,  3,  1,  0,  1],
       [ 1,  2,  1,  4,  5,  8, 10, 14, 14, 15, 15, 15, 12, 11,  9,  8,  2,  2,  1,  2],
       [ 0,  2,  4,  8, 11, 15, 16, 21, 24, 29, 30, 27, 25, 18, 15, 11,  6,  6,  3,  1],
       [ 1,  4,  7, 11, 16, 24, 33, 43, 46, 50, 50, 46, 42, 34, 24, 17, 11,  8,  3,  1],
       [ 4,  7, 13, 20, 29, 41, 53, 61, 65, 67, 68, 64, 55, 48, 34, 24, 17, 10,  5,  3],
       [ 4, 10, 18, 30, 42, 57, 70, 72, 75, 75, 78, 72, 66, 55, 48, 33, 21, 14,  7,  3],
       [ 7, 16, 26, 43, 55, 62, 74, 76, 79, 84, 78, 76, 70, 66, 55, 40, 28, 16, 10,  5],
       [ 7, 19, 34, 45, 60, 70, 77, 75, 85, 81, 83, 81, 77, 68, 58, 46, 28, 18, 10,  5],
       [12, 20, 35, 51, 65, 69, 74, 78, 77, 85, 86, 77, 77, 72, 59, 48, 34, 21, 11,  6],
       [11, 22, 33, 46, 59, 71, 76, 80, 85, 87, 86, 84, 76, 76, 68, 54, 36, 23, 11,  6],
       [12, 21, 31, 47, 52, 64, 79, 77, 86, 88, 89, 83, 78, 72, 68, 50, 37, 19, 10,  7],
       [10, 18, 24, 39, 49, 59, 71, 81, 86, 89, 87, 86, 76, 67, 56, 46, 30, 15,  9,  4],
       [ 6, 11, 20, 30, 45, 52, 65, 72, 78, 84, 82, 80, 69, 57, 46, 35, 23, 13,  6,  4],
       [ 5,  8, 12, 18, 29, 45, 53, 60, 65, 71, 72, 67, 56, 48, 35, 25, 15,  9,  6,  3],
       [ 5,  7,  9, 13, 19, 28, 37, 44, 52, 52, 56, 50, 43, 31, 23, 15, 10,  6,  4,  2],
       [ 1,  3,  6,  8, 13, 14, 22, 27, 31, 33, 34, 30, 23, 18, 13,  8,  5,  4,  1,  2],
       [ 2,  1,  4,  5,  7,  9, 10, 15, 16, 17, 16, 15, 12, 10,  6,  6,  3,  3,  2,  0],
       [ 0,  2,  1,  3,  4,  4,  7,  6,  8,  7,  7,  7,  5,  5,  3,  4,  1,  1,  0,  1]], dtype=np.uint8)

data_mask=np.array([[255, 255, 255, 255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255, 255, 255],
       [255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255],
       [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255],
       [255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255],
       [255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255],
       [255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255],
       [255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255],
       [255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255],
       [255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255, 255],
       [255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255, 255, 255],
       [255, 255, 255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255, 255, 255, 255, 255],
       [255, 255, 255, 255, 255, 255, 255, 255,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], dtype=np.uint8)

img = sitk.GetImageFromArray(data)
mask = sitk.GetImageFromArray(data_mask)

params = "params.yml"

extractor = featureextractor.RadiomicsFeatureExtractor(params)
features = extractor.execute(img, mask, label=255)

Expected behavior
A clear and concise description of what you expected to happen.

Version (please complete the following information):

  • OS: Windows 10
  • Python version: 3.7.7
  • PyRadiomics version 3.0
@mluerig mluerig added the bug label Jun 30, 2020
@mluerig mluerig changed the title [BUG] feature extractor stopped working [BUG] feature extractor stopped working (arrays used as indices must be of integer (or boolean) type) Jun 30, 2020
@mluerig
Copy link
Author

mluerig commented Jul 1, 2020

I found that numpy 1.19.0 is breaking, under 1.18.5 it still works

@JoostJM
Copy link
Collaborator

JoostJM commented Jul 2, 2020

Duplicate to #592

@JoostJM JoostJM closed this as completed Jul 2, 2020
@mluerig
Copy link
Author

mluerig commented Jul 2, 2020

Duplicate to #592

I forgot to mention that I tried the fix mentioned in #592, to no effect

@JoostJM
Copy link
Collaborator

JoostJM commented Jul 2, 2020

I forgot to mention that I tried the fix mentioned in #592, to no effect

I'm currently working on expanding the fix. However, as the same problem is handled in #592, it is better to reopen that issue than start a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants