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

ENH: Support different axis orders #45

Open
tbirdso opened this issue Aug 9, 2023 · 1 comment
Open

ENH: Support different axis orders #45

tbirdso opened this issue Aug 9, 2023 · 1 comment

Comments

@tbirdso
Copy link
Collaborator

tbirdso commented Aug 9, 2023

Current Behavior

After #43 ITKIOOMEZarrNGFF will support reading from OME-Zarr stores where spatial axes appear in the order z,y,x. For instance, the following are supported:

  • y,x
  • z,y,x
  • t,y,x
  • t,c,z,y,x
  • t,z,y,x,c
    etc.

OME-Zarr and ITK axis access conventions are reversed. A 3D ITK image represents data with x,y,z axes, where "x" is the fastest moving and "z" is the slowest moving image axis. A 3D OME-Zarr store with axes "z", "y", "x" equivalently represents data where "z" is the slowest moving image axis and 'x" is the fastest moving image axis.

EDIT: Note that the order of spatial axes is not explicitly enforced. In theory images with out-of-order spatial axes can be read out of order. However, spatial metadata in the resulting ITK image may similarly be out of order.

Requested Behavior

Allow the user to specify the order in which OME-Zarr axes should permute to map to ITK axes. Handle spatial metadata (direction, origin, spacing) accordingly.

For instance:

imageio = itk.OMEZarrNGFFImageIO.New()
imageio.SetNamedAxes(['x','y','z']) # equivalent to ITK default
# read, etc...

or:

imageio = itk.OMEZarrNGFFImageIO.New()
imageio.SetNamedAxes(['x','z','y'])
# read, etc...

NamedAxes should default to the expected ITK spatial axes, i.e. [x,y,z].

Enhancement 1

Allow the user to query what named axes are available and reconfigure accordingly.

image_reader.SetImageIO(imageio)
image_reader.SetFileName(filename)
image_reader.UpdateOutputInformation()
print(imageio.GetNamedAxes())    # ['x','t','angle',etc]

Enhancement 2

Consider mapping arbitrary axes to ITK dimensions:

imageio.SetNamedAxes(['t','angle','z'])
imageio.SetNamedIndex('x', 5)
imageio.SetNamedIndex('y',10)
# read, etc...

Metadata may get tricky under this general approach.

@dzenanz
Copy link
Member

dzenanz commented Aug 9, 2023

ITK's default order of axes is c,x,y,z,t. In OME-zarr specification, this is known as t,z,y,x,c order. This corresponds to identity direction matrix. Any other permutation corresponds to non-identity direction. I was suggesting that direction be set according the the axes order, so your described "enhancement 1".

Channel axis should be treated differently, as per #32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants