Skip to content

Commit 1a6a8e1

Browse files
authored
enable anisotropic nearest interpolation downsampling (#643)
* change capacity of linear_filter_3d to also do anisotropic downsampling * update changelog * update comments
1 parent 91f4c36 commit 1a6a8e1

File tree

5 files changed

+3
-15
lines changed

5 files changed

+3
-15
lines changed

webknossos/webknossos/dataset/downsampling_utils.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,9 @@ def parse_interpolation_mode(
117117
def linear_filter_3d(data: np.ndarray, factors: List[int], order: int) -> np.ndarray:
118118
factors_np = np.array(factors)
119119

120-
assert np.all(
121-
factors_np == factors[0]
122-
), "The selected filtering strategy does not support anisotropic downsampling."
123-
factor = factors[0]
124-
125-
ds = data.shape
126-
assert not any((d % factor > 0 for d in ds))
127120
return zoom(
128121
data,
129-
1 / factor,
122+
1 / factors_np,
130123
output=data.dtype,
131124
# 0: nearest
132125
# 1: bilinear

webknossos/webknossos/dataset/layer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,6 @@ def downsample_mag(
715715
- "bilinear"
716716
- "bicubic"
717717
718-
Only "median" and "mode" currently work with anisotropic downsampling.
719-
720718
The `args` can contain information to distribute the computation.
721719
If allow_overwrite is True, an existing Mag may be overwritten.
722720

wkcuber/Changelog.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1616
### Changed
1717

1818
### Fixed
19-
19+
- Fixed that wkcuber.downsampling didn't support anisotropic downsampling for some downsampling modes like `nearest`. [#643](https://github.com/scalableminds/webknossos-libs/pull/643)
2020

2121
## [0.9.12](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.9.12) - 2022-03-18
2222
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.9.11...v0.9.12)
@@ -36,7 +36,6 @@ For upgrade instructions, please check the respective *Breaking Changes* section
3636
- Fixed that wkcuber.downsampling didn't support an anisotropic mag for `--from`. [#638](https://github.com/scalableminds/webknossos-libs/pull/638)
3737
- Fixed that wkcuber.downsampling didn't provide a meaningful error message when trying to do downsampling with an unsupported interpolation mode. [#619](https://github.com/scalableminds/webknossos-libs/pull/619)
3838

39-
4039
## [0.9.9](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.9.9) - 2022-03-03
4140
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.9.8...v0.9.9)
4241

wkcuber/wkcuber/downsampling.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ def downsample_mags(
115115
Argument `from_mag` expects the resolution to base downsampling on.
116116
117117
For the other parameters see the CLI help or `Layer.downsample` and `Layer.downsampling_mag`.
118-
119-
Note: Not all `interpolation_mode`s work with anisotropic downsampling.
120118
"""
121119
assert layer_name and from_mag or not layer_name and not from_mag, (
122120
"You provided only one of the following "

wkcuber/wkcuber/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def add_interpolation_flag(parser: argparse.ArgumentParser) -> None:
9898
parser.add_argument(
9999
"--interpolation_mode",
100100
"-i",
101-
help="Interpolation mode (median, mode, nearest, bilinear or bicubic). At the moment only median and mode is supported for anisotropic downsampling. All of the modes are working with isotropic downsampling.",
101+
help="Interpolation mode (median, mode, nearest, bilinear or bicubic).",
102102
default="default",
103103
)
104104

0 commit comments

Comments
 (0)