navis-org / pymaid

Python library to interface with CATMAID servers. Fully interoperable with navis.
https://pymaid.readthedocs.io/en/latest/
GNU General Public License v3.0
24 stars 11 forks source link

Use CATMAID stack info to create xarray.DataArrays #235

Closed clbarnes closed 10 months ago

clbarnes commented 1 year ago

Introduces a Stack class which loads stack and mirror info from CATMAID. That has a get_scale method which returns an xarray.DataArray representing that scale level, which wraps a dask array wrapping a zarr array. Depending on the mirror info, the zarr array pulls either from an N5 store, or one of a few custom zarr store shims implementing a few of our more common tile source types (JPEG stacks, for now, but H2N5 should be fairly low-hanging fruit as well). xarray allows us to pull data in voxel or world space.

The Stack can be created simply from a catmaid client instance and stack ID or title (or by selection with a CLI). By default the JPEG tile sources re-use the session from that client instance (so that auth headers are re-used).

Using dask arrays means we can have concurrent downloads and also do things like lazy transposes, which means we can use CATMAID's orientations. However, there is quite a lot of complexity in the interactions between N5, Zarr, and CATMAID orientations, which needs a fair bit of testing.

To do