harpy.sh.add_shapes

Contents

harpy.sh.add_shapes#

harpy.sh.add_shapes(sdata, input, output_shapes_name, transformations=None, instance_key='cell_ID', overwrite=False)#

Add a shapes element to a SpatialData object.

This function allows you to add a shapes element to sdata. The shapes element can be derived from a Dask array or a GeoDataFrame. If sdata is backed by a zarr store, the resulting shapes element will be backed to the zarr store.

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

  • input (Array | GeoDataFrame) – The input data containing the shapes, either as an array (i.e. segmentation masks) or a GeoDataFrame.

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

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

  • instance_key (str (default: 'cell_ID')) – Name of the resulting index of the GeoDataFrame. The user can set this to any value, it will only be used to name the index.

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

Return type:

SpatialData

Returns:

: The sdata object with the shapes element added.