harpy.im.get_dataarray

Contents

harpy.im.get_dataarray#

harpy.im.get_dataarray(sdata, element_name, scale=None)#

Retrieve the highest-resolution xarray.DataArray from an element in sdata.images or sdata.labels.

If sdata.images[element_name] or sdata.labels[element_name] is a xarray.DataTree, this function returns the requested pyramid xarray.DataArray. If scale is None, the base scale ("scale0") is returned. If the element is already a xarray.DataArray, scale is ignored.

Parameters:
  • sdata (SpatialData) – The SpatialData object containing image and/or labels elements.

  • element_name (str) – The name of the element to retrieve.

  • scale (str | None) – Pyramid level to retrieve when the element is stored as a multiscale xarray.DataTree. If None, "scale0" is used.

Return type:

DataArray

Returns:

: The resolved xarray.DataArray corresponding to the requested element.

Raises:
  • KeyError – If the element does not exist in sdata.images or sdata.labels.

  • ValueError – If the element exists but is stored in an unsupported format.