Closed damonmaria closed 8 years ago
Mmmm, it is strange behaviour. I am not sure what the result should be in this case, though.
(If you ignore_zeros, then there are the adjacency matrices are all zeros). What kind of output would you expect? An error? NaN
s? Zeros?
I don't think any value in a normally sized array result makes sense. My suggestion would be an exception because then at least it can be explained the reason for it. Overall I think the most important thing is to document what can happen in the parameter description of ignore_zeros
so that the caller hopefully knows to deal with it.
I'm ran into a related problem: mh.features.haralick(a, ignore_zeros=True, return_mean=True)
returns nan
instead of a numpy array.
The problem is that the array of feature values in line 321 in mh.features.texture.haralick_features()
is empty, which results in nan
when one tries to calculate the mean for the empty array:
import numpy as np
a = np.array([])
a.mean(axis=0)
In my opinion, returning an array of NaN
s would be the cleanest solution, since we would at least get the same data types (numpy.array
with float
values) and consistent dimensions ((4, 13)
).
A warning in the docs would be nice and would alert the user that this may happen in rare cases when setting ignore_zeros
to True
.
Thanks guys. Commit https://github.com/luispedro/mahotas/commit/fd097559a7e35fd8198341ae53e898bdf0ed897c improved the docs too.
On one particular input I'm getting an empty array from haralick. It has been working fine millions of times so I know it's this particular input.
And it's also to do with ignore_zeros
Are the haralick features not able to be calculated for this input? If so the docs should mention that such a result is possible.