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: Fail gracefully when grayvalue <= 0 #602

Merged
merged 1 commit into from Sep 5, 2020

Conversation

JoostJM
Copy link
Collaborator

@JoostJM JoostJM commented Jul 2, 2020

"0" is an invalid value for gray level and causes an index error in the calculation of texture matrices (e.g. for GLSZM, correct index in matrix is calculated as (i, j) = (grayvalue - 1, region size), which in case of gray value 0 results in index -1, which is invalid).

In some case, this resulted in a graceful error where an IndexError is raised, but this is most likely because the datatype used for the index (size_t) does not allow for negative indices on some systems and therefore results in an overflow, which on the subsequent check is then indeed larger than the maximum allowed index (which is checked). In other cases, size_t datatype does allow for negative values and therefore passes the maximum index check and subsequently fails with a Process terminated.

Add an additional check to ensure the gray level is > 0, otherwise, fail the C Extension gracefully. Non-gray level properties (i.e. run length, zone size, dependence counts) are calculated in the C extension and ensured to be >= 0.

"0" is an invalid value for gray level and causes an index error in the calculation of texture matrices (e.g. for GLSZM, correct index in matrix is calculated as (i, j) = (grayvalue - 1, region size), which in case of gray value 0 results in index -1, which is invalid).

In some case, this resulted in a graceful error where an IndexError is raised, but this is most likely because the datatype used for the index (`size_t`) does not allow for negative indices on some systems and therefore results in an overflow, which on the subsequent check is then indeed larger than the maximum allowed index (which is checked). In other cases, `size_t` datatype does allow for negative values and therefore passes the maximum index check and subsequently fails with a Process terminated.

Add an additional check to ensure the gray level is > 0, otherwise, fail the C Extension gracefully. Non-gray level properties (i.e. run length, zone size, dependence counts) are calculated in the C extension and ensured to be >= 0.
@JoostJM JoostJM merged commit e17e3da into AIM-Harvard:master Sep 5, 2020
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

Successfully merging this pull request may close these issues.

None yet

1 participant