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
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
default_view_configuration
property
writable
¶
default_view_configuration: LayerViewConfiguration | None
Gets the default view configuration for this layer.
Returns:
-
LayerViewConfiguration | None–LayerViewConfiguration | None: View configuration if set, otherwise None
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
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.
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,
sharing_token: str | None = None,
) -> UPath
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
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
- Get Help
- Community Forums
- Email Support