Skip to content
Snippets Groups Projects
Commit 37053592 authored by fima's avatar fima :beers:
Browse files

Merge branch 'OME_export_from_dask_array' into 'main'

Working for both Dask and Numpy arrays

See merge request !114
parents 46430997 2d3eea14
Branches
No related tags found
1 merge request!114Working for both Dask and Numpy arrays
......@@ -6,7 +6,13 @@ import os
import numpy as np
import zarr
from ome_zarr.io import parse_url
from ome_zarr.writer import write_image
from ome_zarr.writer import (
write_image,
_create_mip,
write_multiscale,
CurrentFormat,
Format,
)
from ome_zarr.reader import Reader
from ome_zarr import scale
import math
......@@ -100,14 +106,24 @@ def export_ome_zarr(
os.mkdir(path)
store = parse_url(path, mode="w").store
root = zarr.group(store=store)
write_image(
image=data,
fmt = CurrentFormat()
log.info("Creating a multi-scale pyramid")
mip, axes = _create_mip(image=data, fmt=fmt, scaler=scaler, axes="zyx")
log.info("Writing data to disk")
write_multiscale(
mip,
group=root,
axes="zyx",
storage_options=dict(chunks=(chunk_size, chunk_size, chunk_size)),
scaler=scaler,
fmt=fmt,
axes=axes,
name=None,
compute=False,
)
log.info("All done!")
return
def import_ome_zarr(path, scale=0, load=True):
"""
......@@ -160,7 +176,9 @@ def import_ome_zarr(path, scale=0, load=True):
scale = len(dask_data) - 1
if scale >= len(dask_data):
raise ValueError(f"Scale {scale} does not exist in the data. Please choose a scale between 0 and {len(dask_data)-1}.")
raise ValueError(
f"Scale {scale} does not exist in the data. Please choose a scale between 0 and {len(dask_data)-1}."
)
log.info(f"\nLoading scale {scale} with shape {dask_data[scale].shape}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment