fmi-faim / faim-ipa

A collection of Image Processing and Analysis (IPA) functions used at the Facility for Advanced Imaging and Microscopy (FAIM)
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

Histogram computation and ome-zarr metadata #147

Open imagejan opened 5 months ago

imagejan commented 5 months ago

When this was still named faim-hcs, we had this code to compute histograms and add it to the zarr attrs:

https://github.com/fmi-faim/faim-ipa/blob/7594dc679baef9715ec4d193557dae4c617372f2/src/faim_hcs/Zarr.py#L173-L183

@tibuch what do you think, does it make sense to add the list of histogram paths to the metadata somehow, or should we just rely on the presence of those files inside the zarr directory tree?

Maybe we can come up with a small utility function that returns the histogram loaded from file if it's present, and otherwise computes the histogram on the fly and (optionally) saves it into the zarr (for future use).

What do you think?

tibuch commented 5 months ago

A small utility function sounds like a useful start.

I think this would be a great opportunity to explore how we could create and use extensions with the ngff spec.

imagejan commented 4 months ago

@tibuch How about extending zarr.Group with some histogram awareness:

from zarr import Group

class HistogramAwareZarrGroup(Group):
    def histogram(self) -> UIntHistogram:
        ...

    def __compute_and_persist_histogram(self):
        ...

(naming to be debated)

???

tibuch commented 4 months ago

Not sure if we want this to be a class. Maybe a mixin would be better suited?

imagejan commented 1 month ago

We should store histograms a zarr group instead of numpy data.