Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing pyramid scaling factor #238

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading