Skip to content

Commit

Permalink
Merge pull request #88 from thewtex/scale-order
Browse files Browse the repository at this point in the history
scale order
  • Loading branch information
thewtex authored Aug 25, 2024
2 parents 9b5fb46 + 9dffde5 commit fe271df
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 60 deletions.
6 changes: 4 additions & 2 deletions ngff_zarr/methods/_itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ def _downsample_itk_bin_shrink(
dims = ngff_image.dims
previous_dim_factors = {d: 1 for d in dims}
spatial_dims = [dim for dim in dims if dim in _spatial_dims]
spatial_dims = _image_dims[: len(spatial_dims)]
for scale_factor in scale_factors:
dim_factors = _dim_scale_factors(dims, scale_factor, previous_dim_factors)
previous_dim_factors = dim_factors
previous_image = _align_chunks(previous_image, default_chunks, dim_factors)

shrink_factors = [dim_factors[sf] for sf in _image_dims if sf in dim_factors]
shrink_factors = [dim_factors[sd] for sd in spatial_dims]

block_0 = _get_block(previous_image, 0)

Expand Down Expand Up @@ -218,12 +219,13 @@ def _downsample_itk_gaussian(
dims = ngff_image.dims
previous_dim_factors = {d: 1 for d in dims}
spatial_dims = [dim for dim in dims if dim in _spatial_dims]
spatial_dims = _image_dims[: len(spatial_dims)]
for scale_factor in scale_factors:
dim_factors = _dim_scale_factors(dims, scale_factor, previous_dim_factors)
previous_dim_factors = dim_factors
previous_image = _align_chunks(previous_image, default_chunks, dim_factors)

shrink_factors = [factor for dim, factor in dim_factors.items() if dim in _spatial_dims]
shrink_factors = [dim_factors[sd] for sd in spatial_dims]

# Compute metadata for region splitting

Expand Down
6 changes: 4 additions & 2 deletions ngff_zarr/methods/_itkwasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ def _downsample_itkwasm_bin_shrink(
dims = ngff_image.dims
previous_dim_factors = {d: 1 for d in dims}
spatial_dims = [dim for dim in dims if dim in _spatial_dims]
spatial_dims = _image_dims[: len(spatial_dims)]
for scale_factor in scale_factors:
dim_factors = _dim_scale_factors(dims, scale_factor, previous_dim_factors)
previous_dim_factors = dim_factors
previous_image = _align_chunks(previous_image, default_chunks, dim_factors)

shrink_factors = [dim_factors[sf] for sf in _image_dims if sf in dim_factors]
shrink_factors = [dim_factors[sd] for sd in spatial_dims]

block_0 = _get_block(previous_image, 0)

Expand Down Expand Up @@ -160,12 +161,13 @@ def _downsample_itkwasm(
dims = ngff_image.dims
previous_dim_factors = {d: 1 for d in dims}
spatial_dims = [dim for dim in dims if dim in _spatial_dims]
spatial_dims = _image_dims[: len(spatial_dims)]
for scale_factor in scale_factors:
dim_factors = _dim_scale_factors(dims, scale_factor, previous_dim_factors)
previous_dim_factors = dim_factors
previous_image = _align_chunks(previous_image, default_chunks, dim_factors)

shrink_factors = [factor for dim, factor in dim_factors.items() if dim in _spatial_dims]
shrink_factors = [dim_factors[sd] for sd in spatial_dims]

# Compute metadata for region splitting

Expand Down
108 changes: 54 additions & 54 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fe271df

Please sign in to comment.