czbiohub-sf / shrimPy

shrimPy: Smart High-throughput Robust Imaging & Measurement in Python
BSD 3-Clause "New" or "Revised" License
8 stars 1 forks source link

Update scale metadata #86

Closed edyoshikun closed 1 year ago

edyoshikun commented 1 year ago

Fixes #85.

TC edit: I've finished a working prototype on this branch.

Example usage:

17:59:17 $ mantis update-scale-metadata -i phase_reg.zarr/*/*/*
The first dataset in the list you provided has (t, c, z, y, x) scale [1.0, 1.0, 0.4, 0.116, 0.116]
Please enter the new z, y, and x scales that you would like to apply to all of the positions in the list.
The old scale will be saved in a metadata field named 'old_scale', and the new scale will adhere to the NGFF spec.
Enter a new t scale: 1
Enter a new c scale: 1
Enter a new z scale: 2
Enter a new y scale: 4
Enter a new x scale: 4
The dataset now has (t, c, z, y, x) scale [1.0, 1.0, 2.0, 4.0, 4.0].

The old scale gets written to .zattrs['old_scale'] in case you make a mistake.

I've tested that the rescaled result appears correctly in napari.

talonchandler commented 1 year ago

@ziw-liu I was a bit confused about which metadata I should write so I used both to match what's currently in the zarr store. Lmk if I should change this.

input_dataset.set_transform("0", transform=transform)
input_dataset.set_transform("*", transform=transform)