Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add axis convention handling to conversion functions #17

Closed
mpinkert opened this issue Dec 1, 2018 · 4 comments
Closed

Add axis convention handling to conversion functions #17

mpinkert opened this issue Dec 1, 2018 · 4 comments
Labels
enhancement New feature or request

Comments

@mpinkert
Copy link
Contributor

mpinkert commented Dec 1, 2018

Numpy and matplotlib have limited axis handling capabilities when it comes to plotting. There is no way to specify a custom axis, such as XYCT vs XYTC, except by manually plotting it with foreknowledge of the axis.

In addition, numpy indexing is in row-major form (ZYX) which is reversed from Java (XYZ). However, as an exception, python plotting libraries assume that the image is RGB if the last channel is 3-dimensional. E.g. YXC or ZYXC. This complicates conversion back and forth between ImageJ and Numpy, as ImageJ opens RGB as XYZC, and so you can't simply reverse the axis order if you want to make the numpy image directly plotable.

The pyimagej conversion functions from_java and to_java should have some way of specifying channel conventions, and the view function should plot that convention correctly. This is particularly important in cases where ops/filters alter the axis order, which can quickly cause unintended errors.

@ctrueden suggests some form of hint variable or other way of passing through Metadata, but the implementation and edge-case handling needs to be determined.

@ctrueden ctrueden added this to the 1.0.0 milestone Dec 2, 2019
@ctrueden
Copy link
Member

ctrueden commented Dec 2, 2019

I think we should invert the dimension order by default when going between ImgLib2 and NumPy. And we need the API to support customizable ordering during conversion as well.

@ctrueden
Copy link
Member

ctrueden commented Dec 2, 2019

See also imageio/imageio#382 and xarray.

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/napari-should-i-reorder-the-dimensions-of-an-array-created-via-ij-py-from-java/53436/1

@ctrueden
Copy link
Member

Aaxis handling conventions are fully resolved with #151, as well as explained in the tutorials, and customizable with individual conversions via the optional dim_order keyword arg, as implemented in #238 and part of the PyImageJ 1.4.0 release.

@ctrueden ctrueden added the enhancement New feature or request label Jun 23, 2023
@ctrueden ctrueden removed this from the unscheduled milestone Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants