Skip to content

Commit c36485e

Browse files
authored
Merge pull request #105 from thewtex/scale-factors-chunk-doc
DOC: Improve documentation of scale factors and interaction with checks
2 parents 01b1509 + 155dc16 commit c36485e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ngff_zarr/to_multiscales.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434

3535

3636
def _ngff_image_scale_factors(ngff_image, min_length, out_chunks):
37-
assert tuple(ngff_image.dims) == tuple(out_chunks.keys()), f"{ngff_image.dims} != {out_chunks.keys()}"
37+
assert tuple(ngff_image.dims) == tuple(
38+
out_chunks.keys()
39+
), f"{ngff_image.dims} != {out_chunks.keys()}"
3840
sizes = {
3941
d: s
4042
for d, s in zip(ngff_image.dims, ngff_image.data.shape)
@@ -44,7 +46,9 @@ def _ngff_image_scale_factors(ngff_image, min_length, out_chunks):
4446
dims = ngff_image.dims
4547
previous = {d: 1 for d in dims if d in _spatial_dims}
4648
sizes_array = np.array(list(sizes.values()))
47-
double_chunks = np.array([2 * s for d, s in out_chunks.items() if d in _spatial_dims])
49+
double_chunks = np.array(
50+
[2 * s for d, s in out_chunks.items() if d in _spatial_dims]
51+
)
4852
while (sizes_array > double_chunks).any():
4953
max_size = np.array(list(sizes.values())).max()
5054
to_skip = {d: sizes[d] <= max_size / 2 for d in previous}
@@ -252,12 +256,13 @@ def to_multiscales(
252256
If a list, integer scale factors to apply uniformly across all spatial dimensions or
253257
along individual spatial dimensions.
254258
Examples: 64 or [2, 4] or [{'x': 2, 'y': 4 }, {'x': 5, 'y': 10}]
259+
Scaling is constrained by size of chunks - we do not scale below the chunk size.
255260
:type scale_factors: int of minimum length, int per scale or dict of spatial dimension int's per scale
256261
257262
:param method: Specify the anti-aliasing method used to downsample the image. Default is ITKWASM_GAUSSIAN.
258263
:type Methods: ngff_zarr.Methods enum
259264
260-
:param chunks: Specify the chunking used in each output scale.
265+
:param chunks: Specify the chunking used in each output scale. The default is 128 for 3D images and 256 for 2D images.
261266
:type chunks: Dask array chunking specification, optional
262267
263268
:param cache: Cache intermediate results to disk to limit memory consumption. If None, the default, determine based on ngff_zarr.config.memory_target.

0 commit comments

Comments
 (0)