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

ENH: Add check to prevent too many bins from being generated #391

Merged
merged 1 commit into from Jun 20, 2018

Conversation

JoostJM
Copy link
Collaborator

@JoostJM JoostJM commented Jun 20, 2018

When the GLCM is calculated in C, an array is generated of size Ng x Ng x Na (Ng = number of bins, Na = number of angles). If the number of bins exceeds 12852 with 13 angles, the resulting array has more than 2,147,483,648 elements, which in turn causes the index variable (int32) to overflow, crashing the python interpreter.

Seeing as generally ~100 bins are advised, limit the number of bins instead of using datatypes that can reach higher numbers. A maximum number of 7000 is chosen (allowing for a maximum of 43 angles in GLCM). If the number of bins exceeds this number, an error is raised.

Additionally, add a size check prior to instantiating the output arrays in C. If the size > 2147483648, throw an error.

Fix typo in error message when calculation of angles fails.

When the GLCM is calculated in C, an array is generated of size Ng x Ng x Na (Ng = number of bins, Na = number of angles). If the number of bins exceeds 12852 with 13 angles, the resulting array has more than 2,147,483,648 elements, which in turn causes the index variable (int32) to overflow, crashing the python interpreter.

Seeing as generally ~100 bins are advised, limit the number of bins instead of using datatypes that can reach higher numbers. A maximum number of 7000 is chosen (allowing for a maximum of 43 angles in GLCM). If the number of bins exceeds this number, an error is raised.

Additionally, add a size check prior to instantiating the output arrays in C. If the size > 2147483648, throw an error.

Fix typo in error message when calculation of angles fails.
@JoostJM
Copy link
Collaborator Author

JoostJM commented Jun 20, 2018

Related to this issue on the pyradiomics google groups.

@JoostJM JoostJM merged commit f0e82e3 into AIM-Harvard:master Jun 20, 2018
@JoostJM JoostJM deleted the bins-check branch June 20, 2018 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant