Skip to content

Commit

Permalink
Updates to upsampling, downsampling, level, and other fixes (#12)
Browse files Browse the repository at this point in the history
* updates to upsampling, and adds rechunk again
as was getting errors without it..

* changed behaviour of level selected in from_path()

- now also applies downsampling (in xy and z) if necessary
- also supports level > max_level

* updates for passing storage_options and path as store

* update downsample func, move static methods

downsample() now takes level as an argument, and has an option do_normalized_sum, which is used for field fraction calculation
TODO: use member variable for the z_level_offset

also moved a couple global helper functions to staticmethods

* limit to python3.10 or greater (| in type hints)

- remove unnecessary normalized sum (same as mean) in downsample
- add simple downsample test
  • Loading branch information
akhanf authored Nov 22, 2024
1 parent 2aa6ca8 commit 57315b9
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 55 deletions.
30 changes: 2 additions & 28 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packages = [{include = "zarrnii"}]


[tool.poetry.dependencies]
python = ">=3.9,<4.0"
python = ">=3.10,<4.0"
zarr = "^2.17.0"
nibabel = "^5.2.0"
dask = "^2024.2.0"
Expand Down
18 changes: 18 additions & 0 deletions tests/test_downsample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from test_io import nifti_nib, cleandir
import pytest
import numpy as np
from numpy.testing import assert_array_almost_equal, assert_array_equal
from zarrnii import ZarrNii

@pytest.mark.usefixtures("cleandir")
def test_downsample(nifti_nib):

nifti_nib.to_filename("test.nii")
znimg = ZarrNii.from_path("test.nii")

ds=np.array([2,5,8])
znimg_downsampled = znimg.downsample(along_x=ds[0],along_y=ds[1],along_z=ds[2])

#check size is same as expected size
assert_array_equal(znimg.darr.shape[1:],znimg_downsampled.darr.shape[1:] * ds)

Loading

0 comments on commit 57315b9

Please sign in to comment.