nipy/niwidgets

FutureWarning raised when calling `nifti_plotter`

ZviBaratz opened this issue · 1 comments

Hi all,

I get the following FutureWarning from numpy when calling nifti_plotter:

image

It seems to be caused by line 197 in niwidget_volume.py:

else np.fliplr(np.flipud(np.rot90(data[slice_obj], k=1)))

I think it doesn't have any real effect other than displaying the annoying warning. However, it could be nice to either:


Option A

Add:

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

before importing numpy.


Option B

Even simpler, change line 197 to:

else np.fliplr(np.flipud(np.rot90(data[tuple(slice_obj)], k=1)))

I tested both solutions locally and they seem to work as expected.

If that makes sense to you I will gladly create a PR.

Thank you for all your amazing work!

Hi @ZviBaratz - thanks for flagging this! I think Option B would be better, as otherwise we'll soon have an error on our hands..!

If you could also change line 195 (slice_obj -> tuple(slice_obj)) that would be super helpful.

Thanks