Skip to content

Zarr Tile Write Strategy

Source

Tile Zarr writing strategy.

ZarrTileHandler

A class handling metadata creation, cropping, restoring and stitching of a tile.

Parameters:

  • region (ImageRegionData) –

    The image region data containing the tile information.

Attributes:

  • original_chunks (Sequence[int] | None) –

    Original chunks of the array, if available.

  • original_shards (Sequence[int] | None) –

    Original shards of the array, if available.

  • crop_size (Sequence[int]) –

    Size of the tile to crop.

  • crop_coords (Sequence[int]) –

    Coordinates where to crop the tile.

  • stitch_coords (Sequence[int]) –

    Coordinates in the array for stitching the tile.

  • sample_idx (int) –

    Sample index of the tile.

  • tile (NDArray) –

    Tile data.

crop property

Cropped tile array.

Returns:

  • NDArray –

    Cropped tile array.

crop_slices property

Tuple of slices for cropping the tile.

Returns:

pred_array_axes property

Prediction array axes after restoring axes.

Returns:

  • str –

    Axes of the prediction array after restoring axes.

pred_array_shape property

Shape of the prediction array after restoring axes.

Returns:

  • tuple[int, ...] –

    Shape of the prediction array after restoring axes.

pred_chunks property

Chunk sizes of the prediction array after restoring axes.

Returns:

  • tuple[int, ...] –

    Chunk sizes of the prediction array after restoring axes.

pred_shards property

Shard sizes of the prediction array after restoring axes.

Returns:

  • tuple[int, ...] | None –

    Shard sizes of the prediction array after restoring axes, or None if not available.

restored_crop property

Cropped tile array with restored axes.

Returns:

  • NDArray –

    Cropped tile array with restored axes.

stitch_slices property

Tuple of slices for stitching the tile into the prediction array.

Returns:

  • tuple[slice | int, ...] –

    Slices for stitching the tile into the prediction array.

__init__(region)

Initialize the TileHandler with the given ImageRegionData.

Parameters:

  • region (ImageRegionData) –

    The image region data containing the tile information.

ZarrTileWriteStrategy

Bases: WriteStrategy

Zarr tile writer strategy.

This writer creates zarr files, groups and arrays as needed and writes tiles into the appropriate locations.

__init__()

Constructor.

set_source_base(source_base)

No-op.

Parameters:

  • source_base (Path or None) –

    Ignored.

write_batch(dirpath, predictions)

Write all tiles to a Zarr file.

Parameters:

  • dirpath (Path) –

    Path to directory to save predictions to.

  • predictions (list[ImageRegionData]) –

    Decollated predictions.

write_tile(dirpath, region)

Write cropped tile to zarr array.

Parameters:

  • dirpath (Path) –

    Path to directory to save predictions to.

  • region (ImageRegionData) –

    Image region data containing tile information.