Skip to content

Commit

Permalink
Fixing pyramid scaling factor (#238)
Browse files Browse the repository at this point in the history
* Fixing pyramid scaling factor

* fix pyramid test

* fix test again
  • Loading branch information
JoOkuma authored Aug 7, 2024
1 parent 885661d commit 4bf8016
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion iohub/ngff/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ def initialize_pyramid(self, levels: int) -> None:
for tr in transforms:
if tr.type == "scale":
for i in range(len(tr.scale))[-3:]:
tr.scale[i] /= factor
tr.scale[i] *= factor

self.create_zeros(
name=str(level),
Expand Down
4 changes: 1 addition & 3 deletions tests/pyramid/test_pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def _mock_fov(
shape: tuple[int, ...],
scale: tuple[float, float, float],
) -> Position:

ds_path = tmp_path / "ds.zarr"
channels = [str(i) for i in range(shape[1])]

Expand Down Expand Up @@ -51,7 +50,6 @@ def _mock_fov(

@pytest.mark.parametrize("ndim", [2, 5])
def test_pyramid(tmp_path: Path, ndim: int) -> None:

# not all shapes not divisible by 2
shape = (2, 2, 67, 115, 128)[-ndim:]
scale = (2, 0.5, 0.5)[-min(3, ndim) :]
Expand Down Expand Up @@ -79,7 +77,7 @@ def test_pyramid(tmp_path: Path, ndim: int) -> None:
.scale
)
assert np.all(level_scale[:-3] == 1)
assert np.allclose(scale / level_scale[-3:], 2**level)
assert np.allclose(level_scale[-3:] / scale, 2**level)

assert fov.metadata.multiscales[0].datasets[level].path == str(level)

Expand Down

0 comments on commit 4bf8016

Please sign in to comment.