Generate pyramid
linc_convert.utils.io.zarr.generate_pyramid ¶
Functions related to generation of downsampled layers in ome-zarr.
default_levels ¶
default_levels(spatial_shape, spatial_chunk, no_pyramid_axis)
Compute the default number of downsampling levels for a spatial pyramid.
For each axis in spatial_shape (except the one indexed by
no_pyramid_axis, if given), this computes how many times you can
halve the dimension (from spatial_shape[i]) by the corresponding chunk
size (spatial_chunk[i]) before reaching chunk ≤ 1, and returns the
maximum of those halving‐counts (rounded up), with a lower bound of 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_shape
|
tuple of int
|
The full size of each spatial dimension. |
required |
spatial_chunk
|
tuple of int
|
The chunk size used for each spatial dimension. |
required |
no_pyramid_axis
|
int or None
|
If not None, that axis index will be excluded when computing levels. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The number of pyramid levels (≥ 0) needed to reduce all applicable axes by repeated factors of two. |
next_level_shape ¶
next_level_shape(prev_shape, no_pyramid_axis)
Compute the shape of the next coarser level by halving each dimension.
Each axis in prev_shape is divided by two (integer division),
clamped to a minimum of 1, except for the axis indexed by
no_pyramid_axis, which remains unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prev_shape
|
sequence of int
|
Shape of the current level (e.g., [N1, N2, …]). |
required |
no_pyramid_axis
|
int or None
|
Axis index to leave unchanged; if None, all axes are halved. |
required |
Returns:
| Type | Description |
|---|---|
list of int
|
New shape for the next level, same length as |
compute_next_level ¶
compute_next_level(arr, ndim, no_pyramid_axis=None, window_func=da.mean)
Compute the next level of a dask array pyramid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
Array
|
Input array of shape (..., N1, N2, ..., Nndim). |
required |
ndim
|
int
|
Number of “pyramid” dimensions at the end of arr.ndim. |
required |
no_pyramid_axis
|
int or None
|
If not None, that axis (0 ≤ axis < ndim) will not be downsampled. |
None
|
window_func
|
callable
|
A reduction function like da.mean or da.median. |
mean
|
Returns:
| Type | Description |
|---|---|
Array
|
Array of shape (..., ceil(N1/2), ceil(N2/2), ...,ceil(Nndim/2))
except on |