Skip to content
Snippets Groups Projects
Commit ed678c1a authored by Hugo chauvet's avatar Hugo chauvet
Browse files

add option to change the fuse function for create mosaic

parent 828d275e
No related branches found
No related tags found
No related merge requests found
......@@ -149,6 +149,7 @@ def fuse_func(
load_tile_func=None,
block_info=None,
data_dtype=np.uint16,
fuse_math_fun=np.max
) -> np.ndarray:
"""
Fuses the tiles that intersect the current chunk of a dask array using maximum projection.
......@@ -187,7 +188,7 @@ def fuse_func(
# note that the dtype comversion here happens without scaling
# may want to use one of the skimage.img_as_* functions instead
stack = np.stack([fused, tile_shifted])
fused = np.max(stack, axis=0)
fused = fuse_math_fun(stack, axis=0)
fused[fused == bad_value] = 0
return fused
......@@ -269,7 +270,7 @@ def tiles_as_shapely(metadata: dict, selected_tiles: [list, int] = -1,
def create_mosaic(zarr_file: str, roi: int = -1, channels: [list, int] = -1, mosaic_chunk_size: [int, int] = (1024, 1024),
output_file: str = None, nz: int = -1, scale_z: bool = True, data_dtype=np.uint16,
return_dask_array=False):
return_dask_array=False, fuse_math_fun=np.max):
"""
Stitch tiles together to create a stiched large image saved with as pyramid ome-zarr
......@@ -290,7 +291,8 @@ def create_mosaic(zarr_file: str, roi: int = -1, channels: [list, int] = -1, mos
_fuse_func = partial(fuse_func,
load_tile_func=mmzarr_load_one_tile,
data_dtype=data_dtype)
data_dtype=data_dtype,
fuse_math_fun=fuse_math_fun)
if roi == -1:
roi = [int(r.replace('roi', '')) for r in roi_tiles]
......@@ -410,9 +412,8 @@ def create_mosaic(zarr_file: str, roi: int = -1, channels: [list, int] = -1, mos
# Compute and save the mosaic inside a Roi:XX parent group
roi_group = root_group.create_group(f'Roi{r}')
dask_out = dask.array.stack(t_mosaic)
with ProgressBar():
writer.write_image(dask_out, roi_group,
writer.write_image(dask.array.stack(t_mosaic), roi_group,
scaler=scaler, axes='tczyx',
coordinate_transformations=scale_omezarr)
......@@ -426,4 +427,7 @@ def create_mosaic(zarr_file: str, roi: int = -1, channels: [list, int] = -1, mos
# roi_group['0']
if return_dask_array:
with ProgressBar():
dask_out = dask.array.stack(t_mosaic)
return dask_out
\ No newline at end of file
......@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "DITB"
version = "20240525rc4"
version = "20240525rc5"
readme = "README.md"
requires-python = ">=3.11"
authors = [{ name = "Hugo Chauvet", email = "hugo.chauvet@synchrotron-soleil.fr" }]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment