nipy/niwidgets

Issue Plotting float32 data

cancan101 opened this issue · 3 comments

I am trying to plot a volume of float32 data (takes on values 0-1) and I get the following:
image
If instead I convert the float data to uint8 (*255), the plotting looks fine (not totally washed out).

Likewise If I just do:

plt.imshow(img_float.dataobj[...,87], vmin=0., vmax=1., cmap='viridis')

I also am able to see the image. What is happening in niwidgets to wash out the image?

Thanks for flagging this. I think this is because of the way I tried to do automatic backround masking in T1 structural images, where the background is often around 0, but not exactly 0. I'll do this by default in the future, but for now what should help is passing the kwarg mask_background=False.

There seems to be no easy way to "automatically" detect what is background and what isn't when images can have such different ranges of numeric values, so I think I'll provide some easier way to use standard template brain masks in the future... But if you have any other thoughts on that I'd appreciate hearing them.

Changed the default behavior. If the image now looks OK to you when you install from the master branch, I'll close this issue and open a new one to figure out a better way to mask the background in the future.

Yes that seemed to fix the issue.