Xarray for metadata support

Hi all,
I was recently reading about the xarray python library

It extends on numpy array and pandas dataframe by adding support for metadata and labelling of dimensions with human readable labels.
It seems that it could be very appropriate for hyperstack dimensions for instance.

Also since it has a built-in support for extensive metadata, I was wondering if anyone tried loading the metadata from for instance an OME-TIFF into such object.
With the advantage that you always have both the image array and the metadata in one object.

Maybe #napari is taking advantage of that already ?

1 Like

#pyimagej supports xarray for the conversion (including dimension metadata) between Java and Python representation of images:

And as far as I can tell, #napari has optional support for xarray as well already:

1 Like

Hi all,

napari does work with xarrays but only because xarrays allow friendly conversion to numpy arrays. We do not currently use xarray labels for axis names or metadata, although we discuss this often. Using the xarray labels for axis labels is one of our oldest issues, #14! I think it will happen eventually, certainly if an OME xarray object becomes standard. Currently things like scale aren’t even in the ome-zarr metadata spec, so I think that spec needs to stabilise before we start seriously supporting these things in napari.

But, to reiterate, we are excited about this possibility ourselves and I think official support will happen reasonably soon.

You can follow progress on xarray support by searching our issues and PRs for xarray.