squidpy.im.ImageContainer.add_img
- ImageContainer.add_img(img, layer=None, dims='default', library_id=None, lazy=True, chunks=None, copy=True, **kwargs)[source]
Add a new image to the container.
- Parameters:
img (
Union[str,Path,ndarray[tuple[Any,...],dtype[Any]],DataArray,Literal['ImageContainer']]) – In-memory 2, 3 or 4-dimensional array, a URL to a Zarr store (ending in .zarr), or a path to an on-disk image.layer (
str|None) – Image layer inimgthat should be processed. If None and only 1 layer is present, it will be selected.dims (
Union[Literal['default','prefer_channels','prefer_z'],Sequence[str]]) –Where to save channel dimension when reading from a file or loading an array. Valid options are:
’channels_last’ - load the last non-spatial dimension as channels.
’z_last’ - load the last non-spatial dimension as Z-dimension.
’default’ - same as ‘channels_last’, but for 4-dimensional arrays, tries to also load the first dimension as channels if the last non-spatial dimension is 1.
a sequence of dimension names matching the shape of
img, e.g.('y', 'x', 'z', 'channels'). ‘y’, ‘x’ and ‘z’ must always be present.
library_id (
str|Sequence[str] |None) – Name for each Z-dimension of the image. This should correspond to thelibrary_idinanndata.AnnData.uns.chunks (
str|tuple[int,...] |None) – Chunk size for Dask. Only used whenlazy = True.copy (
bool) – Whether to copy the underlying data ifimgis an in-memory array.
- Return type:
- Returns:
Nothing, just adds a new
layertodata.- Raises:
ValueError – If loading from a file/store with an unknown format or if a supplied channel dimension cannot be aligned.
NotImplementedError – If loading a specific data type has not been implemented.