NeurodataWithoutBorders / nwbwidgets

Explore the hierarchical structure of NWB 2.0 files and visualize data with Jupyter widgets.
https://nwb-widgets.readthedocs.io/en/latest/
Other
47 stars 22 forks source link

nwb2widget - images are displayed rotated to the left by 90 degree #193

Open rozmar opened 2 years ago

rozmar commented 2 years ago

Hi there, This is a minor issue and probably can be fixed easily.

If there is an image in an .nwb file (pynwb.image.GrayscaleImage or pynwb.ophys.TwoPhotonSeries), nwbwidgets.nwb2widget displays it 90 degree rotated to the left. with nwb2widget: image with imshow: image The images are not too revealing, but the dimensions are obviously not right.

rozmar commented 2 years ago

Now that I look at the images side by side, it looks transposed not rotated.

bendichter commented 2 years ago

Yes, this is because imshow expects y,x and GrayscaleImage is x,y (though this could be clearer in the documentation)

rozmar commented 2 years ago

Thanks for the quick response! I didn't spot that in the documentation indeed. I am using scanimage for generating these data and it seems like their standard is also (y,x), although (x,y) would make more sense. Quite confusing. So what is the correct way to use it? Should I transpose all my movies and images before putting in the .nwb file? And when someone reads it, they should transpose it back if they want to use imshow? Could I specify the dimensions instead?

bendichter commented 2 years ago

Yes, images are often stored with y first. This is consistent with indexing of an array, but I agree it can be confusing nonetheless. If x vs y is important to you, you should transpose the data before saving it, then users would transpose when reading.

@weiglszonja, do you think you could add to the docval of PyNWB Image types to make this dimension order more clear to users of those classes?