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
[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 (
Optional
[str
]) – Image layer inimg
that 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 (
Union
[str
,Sequence
[str
],None
]) – Name for each Z-dimension of the image. This should correspond to thelibrary_id
inanndata.AnnData.uns
.lazy (
bool
) – Whether to usedask
to lazily load image.chunks (
Union
[str
,tuple
[int
,...
],None
]) – Chunk size fordask
. Only used whenlazy = True
.copy (
bool
) – Whether to copy the underlying data ifimg
is an in-memory array.
- Return type:
- Returns:
: Nothing, just adds a new
layer
todata
.- 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.