Skip to content
Snippets Groups Projects

OME-ZARR Progress bar

+ 13
8
@@ -83,6 +83,7 @@ def export_ome_zarr(
@@ -83,6 +83,7 @@ def export_ome_zarr(
order=0,
order=0,
replace=False,
replace=False,
method="scaleZYX",
method="scaleZYX",
 
progress_bar:bool = True,
):
):
"""
"""
Export image data to OME-Zarr format with pyramidal downsampling.
Export image data to OME-Zarr format with pyramidal downsampling.
@@ -96,7 +97,7 @@ def export_ome_zarr(
@@ -96,7 +97,7 @@ def export_ome_zarr(
downsample_rate (int, optional): Factor by which to downsample the data for each scale. Must be greater than 1. Defaults to 2.
downsample_rate (int, optional): Factor by which to downsample the data for each scale. Must be greater than 1. Defaults to 2.
order (int, optional): Interpolation order to use when downsampling. Defaults to 0 (nearest-neighbor).
order (int, optional): Interpolation order to use when downsampling. Defaults to 0 (nearest-neighbor).
replace (bool, optional): Whether to replace the existing directory if it already exists. Defaults to False.
replace (bool, optional): Whether to replace the existing directory if it already exists. Defaults to False.
progress_bar (bool, optional): Whether to display progress while writing data to disk. Defaults to True.
Raises:
Raises:
ValueError: If the directory already exists and `replace` is False.
ValueError: If the directory already exists and `replace` is False.
ValueError: If `downsample_rate` is less than or equal to 1.
ValueError: If `downsample_rate` is less than or equal to 1.
@@ -149,19 +150,23 @@ def export_ome_zarr(
@@ -149,19 +150,23 @@ def export_ome_zarr(
mip, axes = _create_mip(image=data, fmt=fmt, scaler=scaler, axes="zyx")
mip, axes = _create_mip(image=data, fmt=fmt, scaler=scaler, axes="zyx")
log.info("Writing data to disk")
log.info("Writing data to disk")
n_chunks = get_n_chunks(
kwargs = dict(
shapes = (scaled_data.shape for scaled_data in mip),
pyramid=mip,
dtypes = (scaled_data.dtype for scaled_data in mip))
with OmeZarrExportProgressBar(path = path, n_chunks = n_chunks, reapeat_time=5):
write_multiscale(
mip,
group=root,
group=root,
fmt=fmt,
fmt=fmt,
axes=axes,
axes=axes,
name=None,
name=None,
compute=True,
compute=True,
)
)
 
if progress_bar:
 
n_chunks = get_n_chunks(
 
shapes = (scaled_data.shape for scaled_data in mip),
 
dtypes = (scaled_data.dtype for scaled_data in mip)
 
)
 
with OmeZarrExportProgressBar(path = path, n_chunks = n_chunks, reapeat_time=5):
 
write_multiscale(**kwargs)
 
else:
 
write_multiscale(**kwargs)
log.info("All done!")
log.info("All done!")
return
return
Loading