ngff_zarr.cli¶
Module Contents¶
Classes¶
Text-stream proxy whose |
Functions¶
Create a Rich |
|
Apply OMERO metadata to multiscales based on CLI arguments. |
|
Resolve the output store and display path for one series of a file. |
|
Apply user CLI metadata overrides (dims, scale, translation, units, name) to an NgffImage. |
|
Parse the CLI |
|
API¶
- class ngff_zarr.cli._ReplacingTextIO(stream)¶
Text-stream proxy whose
writenever raisesUnicodeEncodeError.A last resort for streams that cannot be reconfigured in place (for example an
ipykernelOutStream, which has noreconfigure). Characters the underlying stream’s encoding cannot represent are replaced rather than raising, so Rich can render without crashing (see issue #37). All other stream behavior is delegated to the wrapped stream.Initialization
- write(text)¶
- flush()¶
- __getattr__(name)¶
- ngff_zarr.cli._build_console() rich.console.Console¶
Create a Rich
Consoleresilient to legacy Windows encodings.In some Windows environments the standard output stream uses a legacy code page such as
cp1252– for example a Jupyter/IPython!shell-out, or git-bash. Rich emits Unicode box-drawing and spinner glyphs that those code pages cannot encode, so the underlyingstr.encoderaisesUnicodeEncodeErrorand the CLI crashes before doing any work (see issue #37).Reconfigure the stream to UTF-8 so the glyphs encode cleanly. If the stream cannot be reconfigured in place, bind the console to a proxy that replaces any un-encodable characters at write time, so rendering degrades gracefully instead of raising.
- ngff_zarr.cli._apply_omero_metadata(live, args, multiscales)¶
Apply OMERO metadata to multiscales based on CLI arguments.
If –no-omero is specified, skip OMERO computation. If –omero-window is specified, use manual values. Otherwise, compute OMERO metadata from the image data.
- ngff_zarr.cli._series_output_target(
- args: argparse.Namespace,
- output_store: ngff_zarr._zarr_types.StoreLike | None,
- series_name: str,
- series_index: int,
- n_series: int,
Resolve the output store and display path for one series of a file.
Returns a
(store, display_path)tuple.With a single requested output path but several series in the source (every Aperio
.svswhole-slide file has Baseline + Thumbnail + Label + Macro series, for example), the destination depends on the requested format:For a single-file
.ozxoutput, the primary (first) series is written to the exact requested path so the file the user asked for is actually created, and additional series are written alongside it as<base>_<series_name>.ozx(preserving the zip format). Previously the.ozxrequest was silently discarded and replaced with<base>_<series_name>.ome.zarrdirectories, so the requested.ozxnever appeared.For directory-style
.zarr/.ome.zarroutput, each series is written to its own<base>_<series_name>.ome.zarrdirectory, the long-standing documented behavior.
- ngff_zarr.cli._multiscales_to_ngff_zarr(
- live,
- args,
- output_store,
- rich_dask_progress,
- multiscales,
- chunks_per_shard=None,
- ngff_zarr.cli._apply_cli_metadata_overrides(ngff_image, args, live)¶
Apply user CLI metadata overrides (dims, scale, translation, units, name) to an NgffImage.
- ngff_zarr.cli._parse_orientation_arg(values, live)¶
Parse the CLI
--orientationargument into an axes_orientations mapping.Accepts either a single preset name (
"LPS"/"RAS") or an even number of ordered dim/value pairs, e.g.x right-to-left y anterior-to-posterior z inferior-to-superior.
- ngff_zarr.cli._ngff_image_to_multiscales(
- live,
- ngff_image,
- args,
- progress,
- rich_dask_progress,
- subtitle,
- method,
- ngff_zarr.cli.main()¶