Skip to content

Commit 4a21fbd

Browse files
authored
Add cli argument for coarsest mag. (#1203)
* Add cli argument for coarsest mag. * Update changelog.
1 parent 8aa1c37 commit 4a21fbd

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1515
### Breaking Changes
1616

1717
### Added
18+
- Added `--coarsest-mag` argument to the `webknossos downsample` command. [#1203](https://github.com/scalableminds/webknossos-libs/pull/1203)
1819

1920
### Changed
2021

webknossos/webknossos/cli/downsample.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
from typing_extensions import Annotated
99

1010
from ..dataset import Dataset, SamplingModes
11+
from ..geometry import Mag
1112
from ..utils import get_executor_for_args
12-
from ._utils import DistributionStrategy, SamplingMode, parse_path
13+
from ._utils import DistributionStrategy, SamplingMode, parse_mag, parse_path
1314

1415

1516
def main(
@@ -31,6 +32,14 @@ def main(
3132
help="Name of the layer to downsample (if not provided, all layers are downsampled)."
3233
),
3334
] = None,
35+
coarsest_mag: Annotated[
36+
Optional[Mag],
37+
typer.Option(
38+
help="Mag to stop downsampling at. \
39+
Should be number or minus separated string (e.g. 2 or 2-2-2).",
40+
parser=parse_mag,
41+
),
42+
] = None,
3443
jobs: Annotated[
3544
int,
3645
typer.Option(
@@ -66,9 +75,14 @@ def main(
6675
with get_executor_for_args(args=executor_args) as executor:
6776
if layer_name is None:
6877
dataset.downsample(
78+
coarsest_mag=coarsest_mag,
6979
sampling_mode=SamplingModes.parse(sampling_mode.value),
7080
executor=executor,
7181
)
7282
else:
7383
layer = dataset.get_layer(layer_name)
74-
layer.downsample(executor=executor)
84+
layer.downsample(
85+
coarsest_mag=coarsest_mag,
86+
sampling_mode=SamplingModes.parse(sampling_mode.value),
87+
executor=executor,
88+
)

webknossos/webknossos/dataset/dataset.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,13 +1929,15 @@ def compress(
19291929
def downsample(
19301930
self,
19311931
sampling_mode: SamplingModes = SamplingModes.ANISOTROPIC,
1932+
coarsest_mag: Optional[Mag] = None,
19321933
executor: Optional[Executor] = None,
19331934
) -> None:
19341935
"""
19351936
Downsamples all layers that are not yet downsampled.
19361937
"""
19371938
for layer in self.layers.values():
19381939
layer.downsample(
1940+
coarsest_mag=coarsest_mag,
19391941
sampling_mode=sampling_mode,
19401942
executor=executor,
19411943
)

0 commit comments

Comments
 (0)