loli / medpy

Medical image processing in Python
http://loli.github.io/medpy/
GNU General Public License v3.0
559 stars 136 forks source link

Anisotropic Diffusion Numpy Warning (+ solution ?) #90

Closed StenSipma closed 6 months ago

StenSipma commented 5 years ago

The current implementation of Anisotropic Diffusion gives two FutureWarnings (from numpy):

FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  matrices[i][slicer] = numpy.diff(matrices[i], axis=i)

This occurs at both usages of slicer. The solution seems to be to change slicer to a tuple. I changed both slicers like this: from slicer = [slice(1, None) if j == i else slice(None) for j in range(out.ndim)] to slicer = tuple([slice(1, None) if j == i else slice(None) for j in range(out.ndim)])

Hope it helps!

loli commented 5 years ago

Thanks for the notice!

loli commented 6 months ago

Solved in new release.