Skip to content

webknossos.dataset

RemoteSegmentationLayer

RemoteSegmentationLayer(
    dataset: RemoteDataset,
    properties: SegmentationLayerProperties,
    read_only: bool,
)

Bases: AbstractSegmentationLayer[RemoteAttachments], RemoteLayer

attachments property

attachments: AttachmentsTypeT

Access, add and remove the attachments of this layer.

Attachments are additional files that can be attached to a segmentation layer. They can be used to store additional information, such as meshes, agglomerations, segment indices, cumsums and connectomes.

Examples:

# Add a mesh attachment to the segmentation layer
layer.attachments.add_mesh(
    mesh_path,
    name="meshfile",
    data_format=AttachmentDataFormat.Zarr3,
)

# Access the mesh attachment path
layer.attachments.meshes[0].path

# Remove the mesh attachment
layer.attachments.delete_attachment(layer.attachments.meshes[0])

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

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")

largest_segment_id property writable

largest_segment_id: int | None

Gets the largest segment ID present in the data.

The largest segment ID is the highest numerical identifier assigned to any segment in this layer. This is useful for: - Allocating new segment IDs - Validating segment ID ranges - Optimizing data structures

Returns:

  • int | None

    int | None: The highest segment ID present, or None if no segments exist

mags property

mags: Mapping[Mag, MagView]

Getter for dictionary containing all mags.

name property

name: str

Gets the name identifier of this layer.

Returns:

  • str ( str ) –

    Layer name

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

as_segmentation_layer

as_segmentation_layer() -> RemoteSegmentationLayer

Casts into SegmentationLayer.

download_mesh

download_mesh(
    segment_id: int,
    output_dir: PathLike | UPath | str,
    mesh_file_name: str | None = None,
    datastore_url: str | None = None,
    lod: int = 0,
    mapping_name: str | None = None,
    mapping_type: (
        Literal["agglomerate", "json"] | None
    ) = None,
    mag: MagLike | None = None,
    seed_position: Vec3Int | None = None,
    token: str | None = None,
) -> UPath

get_finest_mag

get_finest_mag() -> MagView[RemoteLayer]

get_mag

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

refresh_largest_segment_id

refresh_largest_segment_id(
    *,
    chunk_shape: Vec3Int | None = None,
    executor: Executor | None = None
) -> None

Updates largest_segment_id based on actual data content.

Scans through the data to find the highest segment ID value. Sets to None if data is empty.

Parameters:

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

    Shape of chunks for processing

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

    Executor for parallel processing