ngff_zarr.to_ngff_zarr¶
Module Contents¶
Functions¶
Write array using tensorstore backend |
|
Validate the parameters for the NGFF Zarr generation. |
|
Prepare and convert metadata to the proper version format. |
|
Create and configure the root Zarr group with proper attributes. |
|
Configure sharding parameters if sharding is enabled. |
|
Write an array using the TensorStore backend. |
|
Prepare zarr kwargs for dask.array.to_zarr. |
|
Write an array directly using dask.array.to_zarr. |
|
Handle writing large arrays by splitting them into manageable pieces. |
|
Compute the regions for writing a large array in chunks. |
|
Compute regions for a single z-slab, dividing into planes and strips if needed. |
|
Prepare the next scale for processing if needed. |
|
Write an image pixel array and metadata to a Zarr store with the OME-NGFF standard data model. |
|
Internal implementation of to_ngff_zarr without .ozx handling. |
Data¶
API¶
- ngff_zarr.to_ngff_zarr.zarr_version¶
‘Version(…)’
- ngff_zarr.to_ngff_zarr.IS_ZARR_V3_PLUS¶
None
- ngff_zarr.to_ngff_zarr.DASK_SUPPORTS_SHARDING¶
None
- ngff_zarr.to_ngff_zarr._pop_metadata_optionals( )¶
- ngff_zarr.to_ngff_zarr._prep_for_to_zarr(
- store: ngff_zarr._zarr_types.StoreLike,
- arr: dask.array.Array,
- ngff_zarr.to_ngff_zarr._numpy_to_zarr_dtype(dtype)¶
- ngff_zarr.to_ngff_zarr._write_with_tensorstore(
- store_path: str,
- array,
- region,
- chunks,
- zarr_format,
- dimension_names=None,
- internal_chunk_shape=None,
- full_array_shape=None,
- create_dataset=True,
- compressor=None,
- **kwargs,
Write array using tensorstore backend
- ngff_zarr.to_ngff_zarr._validate_ngff_parameters(
- version: str,
- chunks_per_shard: Optional[Union[int, Tuple[int, ...], Dict[str, int]]],
- use_tensorstore: bool,
- store: ngff_zarr._zarr_types.StoreLike,
Validate the parameters for the NGFF Zarr generation.
- ngff_zarr.to_ngff_zarr._prepare_metadata(
- multiscales: ngff_zarr.multiscales.Multiscales,
- version: str,
- enabled_rfcs: Optional[List[int]] = None,
Prepare and convert metadata to the proper version format.
- ngff_zarr.to_ngff_zarr._create_zarr_root(
- store: ngff_zarr._zarr_types.StoreLike,
- chunk_store: Optional[ngff_zarr._zarr_types.StoreLike],
- version: str,
- overwrite: bool,
- metadata_dict: Dict,
Create and configure the root Zarr group with proper attributes.
- ngff_zarr.to_ngff_zarr._configure_sharding(
- arr: dask.array.Array,
- chunks_per_shard: Optional[Union[int, Tuple[int, ...], Dict[str, int]]],
- dims: Tuple[str, ...],
- kwargs: Dict,
Configure sharding parameters if sharding is enabled.
- ngff_zarr.to_ngff_zarr._write_array_with_tensorstore(
- store_path: str,
- path: str,
- arr: dask.array.Array,
- chunks: Union[Tuple[int, ...], List[int]],
- shards: Optional[Tuple[int, ...]],
- internal_chunk_shape: Optional[Tuple[int, ...]],
- zarr_format: int,
- dimension_names: Optional[Tuple[str, ...]],
- region: Tuple[slice, ...],
- full_array_shape: Optional[Tuple[int, ...]] = None,
- create_dataset: bool = True,
- **kwargs,
Write an array using the TensorStore backend.
- ngff_zarr.to_ngff_zarr._prepare_zarr_kwargs(to_zarr_kwargs: Dict)¶
Prepare zarr kwargs for dask.array.to_zarr.
This helper function ensures that correct kwargs are passed on based on which version of zarr and dask is being used. The different versions support different sets of arguments. The zarr_kwargs are adjusted in place and thus the original is overwritten. This is not a problem given that the arguments being adjusted are the same for the zarr store in use.
- ngff_zarr.to_ngff_zarr._write_array_direct(
- arr: dask.array.Array,
- store: ngff_zarr._zarr_types.StoreLike,
- path: str,
- sharding_kwargs: Dict,
- zarr_kwargs: Dict,
- format_kwargs: Dict,
- dimension_names_kwargs: Dict,
- region: Optional[Tuple[slice, ...]] = None,
- zarr_array=None,
- **kwargs,
Write an array directly using dask.array.to_zarr.
- ngff_zarr.to_ngff_zarr._handle_large_array_writing(
- image,
- arr: dask.array.Array,
- store: ngff_zarr._zarr_types.StoreLike,
- path: str,
- dims: Tuple[str, ...],
- dim_factors: Dict[str, int],
- chunks: Tuple[int, ...],
- sharding_kwargs: Dict,
- zarr_kwargs: Dict,
- format_kwargs: Dict,
- dimension_names_kwargs: Dict,
- use_tensorstore: bool,
- store_path: Optional[str],
- zarr_format: int,
- dimension_names: Tuple[str, ...],
- internal_chunk_shape: Optional[Tuple[int, ...]],
- shards: Optional[Tuple[int, ...]],
- progress: Optional[Union[ngff_zarr.rich_dask_progress.NgffProgress, ngff_zarr.rich_dask_progress.NgffProgressCallback]],
- index: int,
- nscales: int,
- **kwargs,
Handle writing large arrays by splitting them into manageable pieces.
- ngff_zarr.to_ngff_zarr._compute_write_regions(
- image,
- dims: Tuple[str, ...],
- arr: dask.array.Array,
- shape: Tuple[int, ...],
- x_index: int,
- y_index: int,
- chunks: Tuple[int, ...],
- shrink_factors: List[int],
Compute the regions for writing a large array in chunks.
- ngff_zarr.to_ngff_zarr._compute_plane_regions(
- image,
- dims: Tuple[str, ...],
- arr: dask.array.Array,
- shape: Tuple[int, ...],
- x_index: int,
- y_index: int,
- z_index: int,
- chunks: Tuple[int, ...],
- shrink_factors: List[int],
- slab_index: int,
Compute regions for a single z-slab, dividing into planes and strips if needed.
- ngff_zarr.to_ngff_zarr._prepare_next_scale(
- image,
- index: int,
- nscales: int,
- multiscales: ngff_zarr.multiscales.Multiscales,
- store: ngff_zarr._zarr_types.StoreLike,
- path: str,
- progress: Optional[Union[ngff_zarr.rich_dask_progress.NgffProgress, ngff_zarr.rich_dask_progress.NgffProgressCallback]],
Prepare the next scale for processing if needed.
- ngff_zarr.to_ngff_zarr.to_ngff_zarr(
- store: ngff_zarr._zarr_types.StoreLike,
- multiscales: ngff_zarr.multiscales.Multiscales,
- version: str = '0.4',
- overwrite: bool = True,
- use_tensorstore: bool = False,
- chunk_store: Optional[ngff_zarr._zarr_types.StoreLike] = None,
- progress: Optional[Union[ngff_zarr.rich_dask_progress.NgffProgress, ngff_zarr.rich_dask_progress.NgffProgressCallback]] = None,
- chunks_per_shard: Optional[Union[int, Tuple[int, ...], Dict[str, int]]] = None,
- enabled_rfcs: Optional[List[int]] = None,
- **kwargs,
Write an image pixel array and metadata to a Zarr store with the OME-NGFF standard data model.
- Parameters:
store (StoreLike) – Store or path to directory in file system. If the path ends with .ozx, writes an RFC-9 compliant zipped OME-Zarr file.
multiscales (Multiscales) – Multiscales OME-NGFF image pixel data and metadata. Can be generated with ngff_zarr.to_multiscales.
version (str, optional) – OME-Zarr specification version. For .ozx files, version 0.5 is required.
overwrite (bool, optional) – If True, delete any pre-existing data in
storebefore creating groups.use_tensorstore (bool, optional) – If True, write array using tensorstore backend.
chunk_store (StoreLike, optional) – Separate storage for chunks. If not provided,
storewill be used for storage of both chunks and metadata.progress (RichDaskProgress) – Optional progress logger
chunks_per_shard (int, tuple, or dict, optional) – Number of chunks along each axis in a shard. If None, no sharding. For .ozx files, defaults to 2 if not specified. Requires OME-Zarr version >= 0.5.
enabled_rfcs (list of int, optional) – List of RFC numbers to enable. If RFC 4 is included, anatomical orientation metadata will be preserved in the output.
**kwargs – Passed to the zarr.create_array() or zarr.creation.create() function, e.g., compression options.
- ngff_zarr.to_ngff_zarr._to_ngff_zarr_impl(
- store: ngff_zarr._zarr_types.StoreLike,
- multiscales: ngff_zarr.multiscales.Multiscales,
- version: str = '0.4',
- overwrite: bool = True,
- use_tensorstore: bool = False,
- chunk_store: Optional[ngff_zarr._zarr_types.StoreLike] = None,
- progress: Optional[Union[ngff_zarr.rich_dask_progress.NgffProgress, ngff_zarr.rich_dask_progress.NgffProgressCallback]] = None,
- chunks_per_shard: Optional[Union[int, Tuple[int, ...], Dict[str, int]]] = None,
- enabled_rfcs: Optional[List[int]] = None,
- **kwargs,
Internal implementation of to_ngff_zarr without .ozx handling.