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 anatlas_size × atlas_sizecanvas:(atlas_size // X) * (atlas_size // Y) >= Z.- Parameters:
- base_shape
Level-0 image shape matching
dims.- dims
Dimension labels for
base_shapein 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_shardto 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:
objectBatchConverter 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.
- 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:
objectOmeZarrConverter 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.