harpy.im.add_image

Contents

harpy.im.add_image#

harpy.im.add_image(sdata, arr, output_image_name, dims=None, chunks=None, transformations=None, scale_factors=None, c_coords=None, overwrite=False)#

Add an image element to a SpatialData object.

This function allows you to add an image element to sdata. If sdata is backed by a zarr store, the resulting image element will be backed to the zarr store, otherwise arr will be persisted in memory. All layers of the Dask graph associated with arr will therefore be materialized upon calling add_image.

Parameters:
  • sdata (SpatialData) – The SpatialData object to which the new image element will be added.

  • arr (Array) – The array containing the image data to be added.

  • output_image_name (str) – The name of the output image element where the image data will be stored.

  • dims (tuple[str, ...] | None (default: None)) – A tuple specifying the dimensions of the image data (e.g., (“c”, “z”, “y”, “x”)). If None, defaults will be inferred.

  • chunks (str | tuple[int, ...] | int | None (default: None)) – Specification for chunking the data.

  • transformations (dict[str, BaseTransformation] | None (default: None)) – Transformations that will be added to resulting output_image_name.

  • scale_factors (Sequence[dict[str, int] | int] | None (default: None)) – Scale factors to apply for multiscale data. If specified output_image_name will be multiscale.

  • c_coords (list[str] | None (default: None)) – Names of the channels. If None, channel names will be named sequentially as 0,1,…

  • overwrite (bool (default: False)) – If True, overwrites output_image_name if it already exists in sdata.

Return type:

SpatialData

Returns:

: The sdata object with the image element added.