Skip to content

webknossos.dataset

LayerExport

LayerExport(layer: AbstractLayer)

Exports a layer's data to common bioimaging file formats.

Accessible via layer.export, e.g.:

layer.export.as_ozx(output_path=UPath("out.ozx"))
layer.export.as_tiff_stack(output_path=UPath("out_tiffs"))
layer.export.as_ome_tiff(output_path=UPath("out.ome.tif"))

as_ome_tiff

as_ome_tiff(
    *,
    output_path: str | PathLike | UPath,
    bounding_box: NDBoundingBox | None = None,
    mag: Mag | None = None
) -> None

Exports the layer as a single, pyramidal OME-TIFF file.

Only layers whose axes are a subset of c, t, z, y, x are supported (OME-TIFF's own dimension model doesn't extend to other axes).

as_ozx

as_ozx(
    *,
    output_path: str | PathLike | UPath,
    bounding_box: NDBoundingBox | None = None,
    mag: Mag | None = None,
    shard_shape: Vec3IntLike | int | None = None,
    executor: Executor | None = None
) -> None

Exports the layer as a single, zipped OME-Zarr archive compliant with NGFF RFC-9, "Zipped OME-Zarr" (.ozx). Layers with additional axes (e.g. time) are supported - the OME axes/scale metadata is derived from the layer's own axes.

If bounding_box is given, the export is cropped to it (intersected with the layer's own bounding box). If mag is given, the archive contains that mag plus every coarser mag already present on the layer; if mag is None, the full mag pyramid is exported.

The output bounding box is translated to origin.

shard_shape fixes the shard shape used for every exported mag. If omitted, a shard shape is picked per mag that just covers the exported region (searching upward from the default chunk shape), capped at the default shard shape (or the wider from-images default for flat data with few z sections).

as_tiff_stack

as_tiff_stack(
    *,
    output_path: str | PathLike | UPath,
    bounding_box: NDBoundingBox | None = None,
    mag: Mag | None = None,
    filename_prefix: str = ""
) -> None

Exports the layer as a directory of per-slice TIFF files, one file per z-section (and per combination of any additional axes, e.g. time), under output_path.

Files are named {NNNNNN}.tiff (or {filename_prefix}_{NNNNNN}.tiff) for plain 3D layers, or {axis}NNN_..._zNNN.tiff (one segment per additional axis, sorted by name, plus z; still prefixed with filename_prefix if given) for layers with additional axes.