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

scaler.local_mean changes the data type to float64 #217

Closed
constantinpape opened this issue Jul 26, 2022 · 2 comments · Fixed by #233
Closed

scaler.local_mean changes the data type to float64 #217

constantinpape opened this issue Jul 26, 2022 · 2 comments · Fixed by #233
Labels
bug Something isn't working

Comments

@constantinpape
Copy link
Contributor

And creates an invalid ome.zarr file! See the minimal example below:

import numpy as np
import ome_zarr
import ome_zarr.scale
import ome_zarr.writer
import zarr

vol = np.random.randint(0, 1000, size=(32, 256, 256)).astype("uint16")

scaler = ome_zarr.scale.Scaler()
mip = scaler.local_mean(vol)

loc = ome_zarr.io.parse_url("./data", mode="w")
group = zarr.group(loc.store)

axes = [ 
    {"name": "z", "type": "space", "unit": "micrometer"},
    {"name": "y", "type": "space", "unit": "micrometer"},
    {"name": "x", "type": "space", "unit": "micrometer"},
]
ome_zarr.writer.write_multiscale(mip, group, axes=axes)

And after running this with ome-zarr 0.5.2 (from conda-forge):

$ cat data/0/.zarray
...
"dtype": "<u2"

$ cat data/1/.zarray
...
"dtype": "<f8"
...
@sbesson
Copy link
Member

sbesson commented Jul 29, 2022

Thanks @constantinpape and definitely agreed it should be fixed to generate resolutions with the same dtype. In addition to the implementation fix, there might be an RFE at the specification level as I cannot find an unambiguous statement that enforces that all datasets in a multiscales group MUST have the same dtype

@constantinpape
Copy link
Contributor Author

In addition to the implementation fix, there might be an RFE at the specification level as I cannot find an unambiguous statement that enforces that all datasets in a multiscales group MUST have the same dtype

Yes, this should absolutely be fixed in the spec. Note that we already have this in an issue: ome/ngff#100 / ome/ngff#2 (first one is a collection of minor points that should be tackled that includes this one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants