Skip to content

Commit e34110c

Browse files
valentin-pinkauvalentin-pinkau
andauthored
allow RemoteDataset as argument (#1382)
* allow RemoteDataset as argument * add changelog --------- Co-authored-by: valentin-pinkau <[email protected]>
1 parent b38c6b7 commit e34110c

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
3737
- The returned dataset ID from dataset exploration is now used. [#1378](https://github.com/scalableminds/webknossos-libs/pull/1378)
3838
- Refactored the architecture, by introducing RemoteLayers, RemoteSegmentationLayers and their abstract base classes. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
3939
- Updated the api version of the webknossos-api to 12. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
40+
- Allowing RemoteDataset to align mags, when down- or upsampling [#1382](https://github.com/scalableminds/webknossos-libs/pull/1382)
4041

4142
### Fixed
4243

webknossos/webknossos/dataset/layer/_downsampling_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from collections.abc import Callable
55
from enum import Enum
66
from itertools import product
7-
from typing import TYPE_CHECKING, Optional
7+
from typing import TYPE_CHECKING, Union
88

99
import numpy as np
1010
from scipy.ndimage import zoom
1111

1212
if TYPE_CHECKING:
13-
from webknossos.dataset.dataset import Dataset
13+
from webknossos.dataset.dataset import Dataset, RemoteDataset
1414

1515
from webknossos.dataset_properties import LayerCategoryType
1616
from webknossos.geometry import Mag, Vec3Int, Vec3IntLike
@@ -46,7 +46,7 @@ def determine_upsample_buffer_shape(array_info: ArrayInfo) -> Vec3Int:
4646
def calculate_mags_to_downsample(
4747
from_mag: Mag,
4848
coarsest_mag: Mag,
49-
dataset_to_align_with: Optional["Dataset"],
49+
dataset_to_align_with: Union["Dataset", "RemoteDataset"] | None,
5050
voxel_size: tuple[float, float, float] | None,
5151
) -> list[Mag]:
5252
assert np.all(from_mag.to_np() <= coarsest_mag.to_np())
@@ -119,7 +119,7 @@ def calculate_mags_to_downsample(
119119
def calculate_mags_to_upsample(
120120
from_mag: Mag,
121121
finest_mag: Mag,
122-
dataset_to_align_with: Optional["Dataset"],
122+
dataset_to_align_with: Union["Dataset", "RemoteDataset"] | None,
123123
voxel_size: tuple[float, float, float] | None,
124124
) -> list[Mag]:
125125
return list(

webknossos/webknossos/dataset/layer/layer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from inspect import getframeinfo, stack
44
from os import PathLike
55
from os.path import relpath
6-
from typing import TYPE_CHECKING, Optional, Union
6+
from typing import TYPE_CHECKING, Union
77

88
import numpy as np
99
from cluster_tools import Executor
@@ -39,7 +39,7 @@
3939
)
4040

4141
if TYPE_CHECKING:
42-
from webknossos.dataset import Dataset
42+
from webknossos.dataset import Dataset, RemoteDataset
4343
from webknossos.dataset.layer import RemoteLayer
4444

4545
from .segmentation_layer import SegmentationLayer
@@ -955,8 +955,8 @@ def _create_dir_for_mag(self, mag: MagLike) -> UPath:
955955
return full_path
956956

957957
def _get_dataset_from_align_with_other_layers(
958-
self, align_with_other_layers: Union[bool, "Dataset"]
959-
) -> Optional["Dataset"]:
958+
self, align_with_other_layers: Union[bool, "Dataset", "RemoteDataset"]
959+
) -> Union["Dataset", "RemoteDataset"] | None:
960960
if isinstance(align_with_other_layers, bool):
961961
return self.dataset if align_with_other_layers else None
962962
else:
@@ -970,7 +970,7 @@ def downsample(
970970
interpolation_mode: str = "default",
971971
compress: bool | Zarr3Config = True,
972972
sampling_mode: str | SamplingModes = SamplingModes.ANISOTROPIC,
973-
align_with_other_layers: Union[bool, "Dataset"] = True,
973+
align_with_other_layers: Union[bool, "Dataset", "RemoteDataset"] = True,
974974
buffer_shape: Vec3Int | None = None,
975975
force_sampling_scheme: bool = False,
976976
allow_overwrite: bool = False,
@@ -990,7 +990,7 @@ def downsample(
990990
compress (bool | Zarr3Config): Whether to compress the generated magnifications. For Zarr3 datasets, codec configuration and chunk key encoding may also be supplied. Defaults to True.
991991
sampling_mode (str | SamplingModes): How dimensions should be downsampled.
992992
Defaults to ANISOTROPIC.
993-
align_with_other_layers (bool | Dataset): Whether to align with other layers. True by default.
993+
align_with_other_layers (bool | Dataset | RemoteDataset): Whether to align with other layers. True by default.
994994
buffer_shape (Vec3Int | None): Shape of processing buffer. Defaults to None.
995995
force_sampling_scheme (bool): Force invalid sampling schemes. Defaults to False.
996996
allow_overwrite (bool): Whether existing mags can be overwritten. False by default.

0 commit comments

Comments
 (0)