Skip to content

czitools.metadata_tools.scaling #

Scaling helpers for CZI files.

Provides CziScaling which extracts physical scaling (X/Y/Z) from CZI metadata and computes downsampled values and simple ratios. The implementation is defensive: missing values fall back to sensible defaults and ratio computations avoid division-by-zero.

Classes:

  • CziScaling

    A class to handle scaling information from CZI image data.

CziScaling dataclass #

CziScaling(
    czisource: Union[str, PathLike[str], Box],
    unit: Optional[str] = "micron",
    zoom: float = 1.0,
    verbose: bool = False,
)

A class to handle scaling information from CZI image data. Attributes: czisource (Union[str, os.PathLike[str], Box]): The source of the CZI image data. X (Optional[float]): The scaling value for the X dimension in microns. Y (Optional[float]): The scaling value for the Y dimension in microns. Z (Optional[float]): The scaling value for the Z dimension in microns. X_sf (Optional[float]): The downscaled scaling value for the X dimension in microns. Y_sf (Optional[float]): The downscaled scaling value for the Y dimension in microns. ratio (Optional[Dict[str, float]]): The scaling ratios for XY, ZX, and ZX_sf. unit (Optional[str]): The unit of measurement for scaling, default is "micron". zoom (Annotated[float, ValueRange(0.01, 1.0)]): The zoom factor, default is 1.0. verbose (bool): Flag to enable verbose logging. Methods: post_init(): Initializes the scaling values from the CZI image data. _safe_get_scale(dist: BoxList, idx: int) -> Optional[float]: Safely retrieves the scaling value for a given dimension.