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

Regarding urgent debugging problem of data format debugging #465

Closed
shong95 opened this issue Feb 18, 2019 · 2 comments
Closed

Regarding urgent debugging problem of data format debugging #465

shong95 opened this issue Feb 18, 2019 · 2 comments

Comments

@shong95
Copy link

shong95 commented Feb 18, 2019

Hello I have a inquiry regarding urgent debugging problem of data format debugging.

@shong95
Copy link
Author

shong95 commented Feb 18, 2019

Hello, I'm getting trouble regarding data format...

# Instantiate the extractor
params = os.path.join(os.getcwd(), '..', 'examples', 'exampleSettings', 'Params.yaml')

print(DC_img_1.GetSize())
print(DC_roi_1.GetSize())

# result = extractor.execute(imagePath, maskPath)
extractor = featureextractor.RadiomicsFeaturesExtractor(params)
DC_result_1 = extractor.execute(DC_img_1, DC_roi_1[2,:,:])
# PC_result_1 = extractor.execute(PC_img_1, PC_roi_1[2,:,:])`

The results of errors are like this:

(976, 1976)
(288, 432, 3)

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-57-2572afd595f0> in <module>
      7 # result = extractor.execute(imagePath, maskPath)
      8 extractor = featureextractor.RadiomicsFeaturesExtractor(params)
----> 9 DC_result_1 = extractor.execute(DC_img_1, DC_roi_1[2,:,:])
     10 # PC_result_1 = extractor.execute(PC_img_1, PC_roi_1[2,:,:])

~/anaconda3/envs/venv_py3/lib/python3.6/site-packages/radiomics/featureextractor.py in execute(self, imageFilepath, maskFilepath, label, voxelBased)
    391     # 1. Load the image and mask
    392     featureVector = collections.OrderedDict()
--> 393     image, mask = self.loadImage(imageFilepath, maskFilepath)
    394 
    395     # 2. Check whether loaded mask contains a valid ROI for feature extraction and get bounding box

~/anaconda3/envs/venv_py3/lib/python3.6/site-packages/radiomics/featureextractor.py in loadImage(self, ImageFilePath, MaskFilePath)
    507       # Do not include the image here, as the overlap between image and mask have not been checked
    508       # It is therefore possible that image and mask do not align, or even have different sizes.
--> 509       self.generalInfo.addMaskElements(None, mask, label)
    510 
    511     # This point is only reached if image and mask loaded correctly

~/anaconda3/envs/venv_py3/lib/python3.6/site-packages/radiomics/generalinfo.py in addMaskElements(self, image, mask, label, prefix)
    112     lssif.Execute(mask)
    113 
--> 114     self.generalInfo[self.generalInfo_prefix + 'Mask-' + prefix + '_BoundingBox'] = lssif.GetBoundingBox(label)
    115     self.generalInfo[self.generalInfo_prefix + 'Mask-' + prefix + '_VoxelNum'] = lssif.GetNumberOfPixels(label)
    116 

~/anaconda3/envs/venv_py3/lib/python3.6/site-packages/SimpleITK/SimpleITK.py in GetBoundingBox(self, label)
  42674 
  42675         """
> 42676         return _SimpleITK.LabelShapeStatisticsImageFilter_GetBoundingBox(self, label)
  42677 
  42678 

RuntimeError: Exception thrown in SimpleITK LabelShapeStatisticsImageFilter_GetBoundingBox: /opt/miniconda2/conda-bld/simpleitk_1520542297279/work/build/ITK-prefix/include/ITK-4.13/itkLabelMap.hxx:164:
itk::ERROR: LabelMap(0x3c367d0): No label object with label 1.`

I hope your kind advice really...

@JoostJM
Copy link
Collaborator

JoostJM commented Feb 18, 2019

@shong95, as you can read from the error message No label object with label 1, your mask does not contain a segmented region with label (=value of the pixels) 1. Using the following code, you can detect the labels present in your ROI:

lssif = sitk.LabelShapeStatisticsImageFilter()
lssif.Execute(DC_roi_1)

print(lssif.GetLabels())

On a side note. Be careful with slicing on a SimpleITK image. Slicing the occurs in [x, y, z] order.

Finally, even after fixing this error, your extraction will not work, as your input image is 2D. We are currently in the process of making PyRadiomics support N-Dimensional extraction, but this is not yet done.

Checkout the google groups and the other issues on pointer how to deal with 2D input for now.

@JoostJM JoostJM closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants