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

Error with Nifti Images. #84

Open
umgpy opened this issue Sep 9, 2020 · 4 comments
Open

Error with Nifti Images. #84

umgpy opened this issue Sep 9, 2020 · 4 comments
Labels
awaiting response Issue is awaiting a response, such as confirmation that a bug has been fixed. bug Something isn't working

Comments

@umgpy
Copy link

umgpy commented Sep 9, 2020

Hi I was trying the collage module on the example jupyter notebook through the docker image. However on trying to pass a numpy array of a nifti image, collage.execute() results in an error. I am adding the error below, please let me know if anything more is required to replicate this error. Thanks

use_3D = True
...
print(image_data.shape)

>(183, 250, 250)

Error while calculating the collage features.

# Run CoLlage Algorithm.Prepare

full_images = collage.execute()

>Image shape = (183, 250, 250)
Mask size = 54x62x61
Image shape (cropped and padded) = (64, 72, 63)
Note: Dividing image values by 255 to convert to 0-1 range
Calculating pixel gradients:
Calculating pixel gradients done.
Calculating dominant gradient angles using SVD for each image patch of size 5x5
Window patch shape for dominant angle calculation = (11, 11, 1)
Calculating dominant gradient angles done.
Dominant angles shape = (54, 62, 63, 2)
Calculating haralick features of angles:
Calculating features for angle 0:
Rescaling dominant angles to 64 unique values.
Rescaling dominant angles done.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-157-f386c7d9cfe2> in <module>
      1 # Run CoLlage Algorithm.Prepare
----> 2 full_images = collage.execute()

/usr/local/lib/python3.8/dist-packages/collageradiomics.py in execute(self)
    565         for angle_index in range(angles_shape[3]):
    566             print(f'Calculating features for angle {angle_index}:')
--> 567             haralick_features[:,:,:,:,angle_index] = self.calculate_haralick_textures(dominant_angles[:,:,:,angle_index])
    568             print(f'Calculating features for angle {angle_index} done.')
    569         if self.verbose_logging:

/usr/local/lib/python3.8/dist-packages/collageradiomics.py in calculate_haralick_textures(self, dominant_angles)
    484         for z in range(depth):
    485             for y,x in product(range(height), range(width)):
--> 486                 if self.mask_array[y,x,z]:
    487                     haralick_image[y,x,z,:] = self.calculate_haralick_feature_values(dominant_angles_binned[:,:,z], x, y)
    488 

IndexError: index 61 is out of bounds for axis 2 with size 61
@nathanhillyer
Copy link
Contributor

@umgpy We are working on this. Could you please provide the image and mask being used so we may verify the problem and solution?

@nathanhillyer nathanhillyer added the bug Something isn't working label Sep 9, 2020
@umgpy
Copy link
Author

umgpy commented Sep 10, 2020

@nathanhillyer I may not be able to provide the image that I was using since it's part of our internal dataset, however I have replicated the error with the publicly available TCIA dataset. Image and mask used are uploaded here.

`# Run CoLlage Algorithm.Prepare

full_images = collage.execute()

Image shape = (240, 240, 155)
Mask size = 14x17x24
Image shape (cropped and padded) = (24, 27, 26)
Note: Dividing image values by 255 to convert to 0-1 range
Calculating pixel gradients:
Calculating pixel gradients done.
Calculating dominant gradient angles using SVD for each image patch of size 5x5
Window patch shape for dominant angle calculation = (11, 11, 1)
Calculating dominant gradient angles done.
Dominant angles shape = (14, 17, 26, 2)
Calculating haralick features of angles:
Calculating features for angle 0:
Rescaling dominant angles to 64 unique values.
Rescaling dominant angles done.


IndexError Traceback (most recent call last)
in
1 # Run CoLlage Algorithm.Prepare
----> 2 full_images = collage.execute()

/usr/local/lib/python3.8/dist-packages/collageradiomics.py in execute(self)
565 for angle_index in range(angles_shape[3]):
566 print(f'Calculating features for angle {angle_index}:')
--> 567 haralick_features[:,:,:,:,angle_index] = self.calculate_haralick_textures(dominant_angles[:,:,:,angle_index])
568 print(f'Calculating features for angle {angle_index} done.')
569 if self.verbose_logging:

/usr/local/lib/python3.8/dist-packages/collageradiomics.py in calculate_haralick_textures(self, dominant_angles)
484 for z in range(depth):
485 for y,x in product(range(height), range(width)):
--> 486 if self.mask_array[y,x,z]:
487 haralick_image[y,x,z,:] = self.calculate_haralick_feature_values(dominant_angles_binned[:,:,z], x, y)
488

IndexError: index 24 is out of bounds for axis 2 with size 24

`

@nathanhillyer
Copy link
Contributor

@umgpy Thank you, we've corrected this issue on the latest version.

Please run docker pull radxtools/collageradiomics-examples:latest and try it out.

@umgpy
Copy link
Author

umgpy commented Sep 11, 2020

@nathanhillyer Thank you for the quick fix, I shall give it a try.

@nathanhillyer nathanhillyer added the awaiting response Issue is awaiting a response, such as confirmation that a bug has been fixed. label Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Issue is awaiting a response, such as confirmation that a bug has been fixed. bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants