phenotypic.sdk_.load_image_from_hdf#

phenotypic.sdk_.load_image_from_hdf(hdf_path: Path, *, fallback: ImageTypeName = 'Image') _Image | _GridImage[source]#

Open an HDF5, read its phenotypic_class attr, dispatch to the right Image class.

Replaces the 3 ad-hoc h5py.File(...) fh.attrs.get('phenotypic_class', 'Image') GridImage if cls_attr == 'GridImage' else Image patterns in _cli_recompile_worker, _cli_execution_strategies, and phenotypicCLI.

Parameters:
  • hdf_path (Path) – Path to a per-image HDF5 file.

  • fallback (ImageTypeName) – Image class name to use when the HDF lacks the phenotypic_class attribute (legacy files). Type-checked (statically) against ImageTypeName — there is no runtime validation; the only effect of an unrecognized string is that the dispatch falls through to Image.

Returns:

An Image or GridImage instance loaded from the HDF.

Return type:

_Image | _GridImage