Skip to content

Commit 7a67eea

Browse files
authored
Merge pull request #74 from giovp/docs/resizing-methods
list downsampling methods in docstring of `to_multiscale`
2 parents 77e0269 + e74bf62 commit 7a67eea

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ examples/chelsea.zarr/
88
.ipynb_checkpoints
99
examples/sub-I46_ses-SPIM_sample-BrocaAreaS01_stain-GAD67_chunk-00_SPIM*
1010
examples/dask-worker-space/
11+
12+
# Byte-compiled / optimized / DLL files
13+
__pycache__/

multiscale_spatial_image/_docs.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from textwrap import dedent
2+
from typing import Any, Callable
3+
4+
5+
def inject_docs(**kwargs: Any) -> Callable[..., Any]:
6+
# taken from scanpy
7+
def decorator(obj: Any) -> Any:
8+
obj.__doc__ = dedent(obj.__doc__).format(**kwargs)
9+
return obj
10+
11+
return decorator

multiscale_spatial_image/to_multiscale/to_multiscale.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ._xarray import _downsample_xarray_coarsen
1212
from ._itk import _downsample_itk_bin_shrink, _downsample_itk_gaussian, _downsample_itk_label
1313
from ._dask_image import _downsample_dask_image
14+
from .._docs import inject_docs
1415

1516
class Methods(Enum):
1617
XARRAY_COARSEN = "xarray_coarsen"
@@ -21,7 +22,7 @@ class Methods(Enum):
2122
DASK_IMAGE_MODE = "dask_image_mode"
2223
DASK_IMAGE_NEAREST = "dask_image_nearest"
2324

24-
25+
@inject_docs(m=Methods)
2526
def to_multiscale(
2627
image: SpatialImage,
2728
scale_factors: Sequence[Union[Dict[str, int], int]],
@@ -35,7 +36,8 @@ def to_multiscale(
3536
]
3637
] = None,
3738
) -> MultiscaleSpatialImage:
38-
"""Generate a multiscale representation of a spatial image.
39+
"""\
40+
Generate a multiscale representation of a spatial image.
3941
4042
Parameters
4143
----------
@@ -46,10 +48,18 @@ def to_multiscale(
4648
scale_factors : int per scale or dict of spatial dimension int's per scale
4749
Integer scale factors to apply uniformly across all spatial dimension or
4850
along individual spatial dimensions.
49-
Examples: [2, 2] or [{'x': 2, 'y': 4 }, {'x': 5, 'y': 10}]
51+
Examples: [2, 2] or [{{'x': 2, 'y': 4 }}, {{'x': 5, 'y': 10}}]
5052
5153
method : multiscale_spatial_image.Methods, optional
52-
Method to reduce the input image.
54+
Method to reduce the input image. Available methods are the following:
55+
56+
- `{m.XARRAY_COARSEN.value!r}` - Use xarray coarsen to downsample the image.
57+
- `{m.ITK_BIN_SHRINK.value!r}` - Use ITK BinShrinkImageFilter to downsample the image.
58+
- `{m.ITK_GAUSSIAN.value!r}` - Use ITK GaussianImageFilter to downsample the image.
59+
- `{m.ITK_LABEL_GAUSSIAN.value!r}` - Use ITK LabelGaussianImageFilter to downsample the image.
60+
- `{m.DASK_IMAGE_GAUSSIAN.value!r}` - Use dask-image gaussian_filter to downsample the image.
61+
- `{m.DASK_IMAGE_MODE.value!r}` - Use dask-image mode_filter to downsample the image.
62+
- `{m.DASK_IMAGE_NEAREST.value!r}` - Use dask-image zoom to downsample the image.
5363
5464
chunks : xarray Dask array chunking specification, optional
5565
Specify the chunking used in each output scale.

0 commit comments

Comments
 (0)