Skip to content

webknossos.dataset

RemoteLayer

RemoteLayer(
    dataset: RemoteDataset,
    properties: LayerProperties,
    read_only: bool,
)

Bases: AbstractLayer

bounding_box property writable

bounding_box: NDBoundingBox

Gets the bounding box encompassing this layer's data.

Returns:

  • NDBoundingBox ( NDBoundingBox ) –

    Bounding box with layer dimensions

category property

category: LayerCategoryType

Gets the category type of this layer.

Returns:

  • LayerCategoryType ( LayerCategoryType ) –

    Layer category (e.g. COLOR_CATEGORY)

data_format property

data_format: DataFormat

Gets the data storage format used by this layer.

Returns:

  • DataFormat ( DataFormat ) –

    Format used to store data

Raises:

  • AssertionError

    If data_format is not set in properties

dataset property

dataset: RemoteDataset

default_view_configuration property writable

default_view_configuration: LayerViewConfiguration | None

Gets the default view configuration for this layer.

Returns:

dtype_per_channel property

dtype_per_channel: dtype

Gets the data type used per channel.

Returns:

  • dtype

    np.dtype: NumPy data type for individual channels

dtype_per_layer property

dtype_per_layer: str

Deprecated, use dtype_per_channel instead. Gets the data type used for the entire layer.

Returns:

  • str ( str ) –

    Data type string (e.g. "uint8")

mags property

mags: Mapping[Mag, MagView]

Getter for dictionary containing all mags.

name property writable

name: str

Returns the name of the layer.

num_channels property

num_channels: int

Gets the number of channels in this layer.

Returns:

  • int ( int ) –

    Number of channels

Raises:

  • AssertionError

    If num_channels is not set in properties

read_only property

read_only: bool

Whether this layer is read-only.

Returns:

  • bool ( bool ) –

    True if layer is read-only, False if writable

add_mag_as_copy

add_mag_as_copy(
    foreign_mag_view_or_path: (
        PathLike | UPath | str | MagView
    ),
    transfer_mode: TransferMode = COPY,
    common_storage_path_prefix: str | None = None,
    overwrite_pending: bool = True,
) -> MagView[RemoteLayer]

Copies the data at foreign_mag_view_or_path which can belong to another dataset to the current remote dataset. Additionally, the relevant information from the datasource-properties.json of the other dataset are copied, too.

as_segmentation_layer

as_segmentation_layer() -> RemoteSegmentationLayer

Casts into SegmentationLayer.

delete_mag

delete_mag(mag: MagLike) -> None

downsample

downsample(
    *,
    from_mag: Mag | None = None,
    coarsest_mag: Mag | None = None,
    interpolation_mode: str = "default",
    compress: bool | Zarr3Config = True,
    sampling_mode: str | SamplingModes = ANISOTROPIC,
    align_with_other_layers: bool = True,
    buffer_shape: Vec3Int | None = None,
    force_sampling_scheme: bool = False,
    transfer_mode: TransferMode = COPY,
    common_storage_path_prefix: str | None = None,
    overwrite_pending: bool = True,
    executor: Executor | None = None
) -> None

Downsample data from a source magnification to coarser magnifications.

Downsamples the data starting from from_mag until a magnification is >= max(coarsest_mag). Different sampling modes control how dimensions are downsampled.

Note that the data is written temporarily on the local disk and uploaded afterwards so some local disk space is required.

Parameters:

  • from_mag (Mag | None, default: None ) –

    Source magnification to downsample from. Defaults to highest existing mag.

  • coarsest_mag (Mag | None, default: None ) –

    Target magnification to stop at. Defaults to calculated value.

  • interpolation_mode (str, default: 'default' ) –

    Interpolation method to use. Defaults to "default". Supported modes: "median", "mode", "nearest", "bilinear", "bicubic"

  • compress (bool | Zarr3Config, default: True ) –

    Whether to compress the generated magnifications. For Zarr3 datasets, codec configuration and chunk key encoding may also be supplied. Defaults to True.

  • sampling_mode (str | SamplingModes, default: ANISOTROPIC ) –

    How dimensions should be downsampled. Defaults to ANISOTROPIC.

  • align_with_other_layers (bool, default: True ) –

    Whether to align the mag selection with the dataset’s other layers. True by default.

  • buffer_shape (Vec3Int | None, default: None ) –

    Shape of processing buffer. Defaults to None.

  • force_sampling_scheme (bool, default: False ) –

    Force invalid sampling schemes. Defaults to False.

  • common_storage_path_prefix (str | None, default: None ) –

    Optional path prefix used when transfer_mode is either COPY or MOVE_AND_SYMLINK to select one of the available WEBKNOSSOS storages.

  • executor (Executor | None, default: None ) –

    Executor for parallel processing. None by default.

Raises:

  • AssertionError

    If from_mag does not exist

  • RuntimeError

    If sampling scheme produces invalid magnifications

  • AttributeError

    If sampling_mode is invalid

get_finest_mag

get_finest_mag() -> MagView[RemoteLayer]

get_mag

get_mag(mag: MagLike) -> MagView[RemoteLayer]