34
34
35
35
36
36
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 ()} "
38
40
sizes = {
39
41
d : s
40
42
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):
44
46
dims = ngff_image .dims
45
47
previous = {d : 1 for d in dims if d in _spatial_dims }
46
48
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
+ )
48
52
while (sizes_array > double_chunks ).any ():
49
53
max_size = np .array (list (sizes .values ())).max ()
50
54
to_skip = {d : sizes [d ] <= max_size / 2 for d in previous }
@@ -252,12 +256,13 @@ def to_multiscales(
252
256
If a list, integer scale factors to apply uniformly across all spatial dimensions or
253
257
along individual spatial dimensions.
254
258
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.
255
260
:type scale_factors: int of minimum length, int per scale or dict of spatial dimension int's per scale
256
261
257
262
:param method: Specify the anti-aliasing method used to downsample the image. Default is ITKWASM_GAUSSIAN.
258
263
:type Methods: ngff_zarr.Methods enum
259
264
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.
261
266
:type chunks: Dask array chunking specification, optional
262
267
263
268
: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