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

Should we permute axes when converting from tiff/mat? #31

Open
balbasty opened this issue Nov 22, 2024 · 4 comments
Open

Should we permute axes when converting from tiff/mat? #31

balbasty opened this issue Nov 22, 2024 · 4 comments
Labels
question Further information is requested

Comments

@balbasty
Copy link
Collaborator

Currently we load the array as is (using tifffile or the matlab loader) and save them in the same order in the zarr.
However, the dimensions in the zarr are named in reverse ([z, y, x]), whereas the data in these input matlab or tiff must often be interpreted as [x, y] or [x, y, z]. Also, in the OCT converter, we stack slices along the last zarr dimension (i.e. "x"), whereas "z" is more natural.

Should we permute the input arrays so that their natural ["x", "y", "z"] axes become ["z", "y", "x"] ?

@balbasty balbasty added the question Further information is requested label Nov 22, 2024
@kabilar
Copy link
Member

kabilar commented Nov 25, 2024

Should we permute the input arrays so that their natural ["x", "y", "z"] axes become ["z", "y", "x"] ?

+1

@chourroutm
Copy link

@balbasty why do you assume XYZ for the TIFF files?

Using the tifffile package with OME-TIFF, it seems OME-TIFF forces the ZYX order (it fails when I try to keep the XYZ order):

import tifffile as tiff

# ...

dataset_in_memory = dataset.transpose((2,1,0)).rechunk((512,)*3).compute()
tiff.imwrite(data_path / "{:.2f}um_binned_{}_{}.tif".format(new_resolution_full_um,donor,organ),dataset_in_memory,metadata={'axes': 'ZYX'},ome=True)

@balbasty
Copy link
Collaborator Author

Ho you're right! So it seems we do things correctly in our LSM tiff converter, at least.

Is it the same for non-OME tiff? Can we always trust the "axes" metadata in tiffile, even in non-OME tiffs? I guess we should at least check what it contains and keep consistency with them if possible.

@chourroutm
Copy link

The "axes" metadata is only part of the OME specs. But yeah, if the tag is populated, it should be used.

I didn't check, but apparently these standards have other methods to indicate the axis order:

Axes information (e.g., X, Y, Z, time, channels) is not inherently standardized in non-OME TIFFs, but it can be added in custom tags or embedded using existing metadata standards like:

  • Exif (Exchangeable Image File Format)
  • XMP (Extensible Metadata Platform)
  • IPTC (International Press Telecommunications Council)

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

No branches or pull requests

3 participants