bioio_conversion package

Subpackages

Submodules

bioio_conversion.sharding module

bioio_conversion.sharding.build_pyramid_shapes(base_shape: Tuple[int, ...], dims: str, atlas_size: int = 2048) List[Tuple[int, ...]][source]

Generate multi-resolution pyramid level shapes with atlas-fit termination.

Downsamples only Z, Y, and X — T and C are never changed. Halves X and Y together while min(X, Y) >= Z; once that condition no longer holds, halves Z instead. Stops as soon as all Z slices of the current level can be tiled into an atlas_size × atlas_size canvas: (atlas_size // X) * (atlas_size // Y) >= Z.

Parameters:
base_shape

Level-0 image shape matching dims.

dims

Dimension labels for base_shape in reader-native order.

atlas_size

Edge length (in pixels) of the square viewer atlas canvas. Default: ATLAS_SIZE (2048).

Returns:
List[Tuple[int, …]]

Per-level shapes, level 0 first, each in the same axis order as dims. The list always contains at least one entry.

bioio_conversion.sharding.choose_pyramid_layout(level_shapes: List[Tuple[int, ...]], dtype: str | dtype[Any], dims: str, chunk_limit_bytes: int = 16777216, shard_limit_bytes: int = 4294967296) Tuple[List[Tuple[int, ...]], List[Tuple[int, ...]]][source]

Compute chunk and shard shapes for every level of a multi-resolution pyramid.

Level 0 uses the budget shard algorithm (_choose_zarr_layout). All subsequent levels use _proportional_shard to keep the number of shards per axis constant across the pyramid (see that function for why).

Parameters:
level_shapes

Per-level shapes, level 0 first.

dtype

Array dtype (any form accepted by np.dtype).

dims

Dimension labels matching the axis order of the shapes.

chunk_limit_bytes

Maximum uncompressed chunk size. Default: 16 MiB.

shard_limit_bytes

Maximum uncompressed shard size for level 0. Default: 4 GiB.

Returns:
all_chunks, all_shards

Per-level chunk and shard shapes, level 0 first.

Module contents

Top-level package initialization. Exposes main utilities for easy import.

class bioio_conversion.BatchConverter(*, converter_key: str = 'ome-zarr', default_opts: Dict[str, Any] | None = None)[source]

Bases: object

BatchConverter orchestrates bulk conversions of image files using a specified converter backend.

Supports three input modes:
  • CSV-driven: each row defines a conversion job

  • Directory-driven: scan up to max_depth for matching files

  • List-driven: explicit list of file paths

Default parameters for all jobs may be provided via default_opts.

from_csv(csv_path: str | Path) List[Dict[str, Any]][source]

Parse a CSV file into a list of job option dicts.

Each column maps to a converter parameter. Empty cells are skipped. Values that decode as JSON become native Python objects.

from_directory(directory: str | Path, *, max_depth: int = 0, pattern: str = '*') List[Dict[str, Any]][source]

Recursively find files matching pattern up to max_depth levels.

max_depth=0 → only top-level files max_depth=1 → include one subdirectory level, etc.

from_list(paths: List[str | Path]) List[Dict[str, Any]][source]

Build jobs from an explicit list of file paths.

Each path yields one job dict; default_opts are merged in.

run_jobs(jobs: List[Dict[str, Any]]) None[source]

Execute each job: must include ‘source’; merges defaults and job params.

class bioio_conversion.OmeZarrConverter(*, source: str, destination: str | None = None, scenes: int | List[int] | None = None, name: str | None = None, level_shapes: Sequence[int] | Sequence[Sequence[int]] | None = None, chunk_shape: Sequence[int] | Sequence[Sequence[int]] | None = None, shard_shape: Sequence[int] | Sequence[Sequence[int]] | None = None, compressor: BloscCodec | Codec | None = None, zarr_format: int | None = None, image_name: str | None = None, channels: List[Channel] | None = None, rdefs: Dict[str, Any] | None = None, creator_info: Dict[str, Any] | None = None, root_transform: Dict[str, Any] | None = None, axes_names: List[str] | None = None, axes_types: List[str] | None = None, axes_units: List[str | None] | None = None, physical_pixel_size: List[float] | None = None, num_levels: int | None = None, downsample_z: bool = False, memory_target: int | None = None, start_t_src: int | None = None, start_t_dest: int | None = None, tbatch: int | None = None, dtype: str | dtype | None = None, n_workers: int | None = None, shard_limit_bytes: int = 4294967296)[source]

Bases: object

OmeZarrConverter handles conversion of any BioImage‐supported format (TIFF, CZI, etc.) into OME-Zarr stores. Supports exporting one, many, or all scenes from a multi-scene file.

convert() None[source]