squidpy
squidpy copied to clipboard
Delete layers in imagecontainer
Description
I might be overlooking it, but is it possible to delete a layer from an imagecontainer object? I don't want to save all the layers that I created during processing the image. It is possible to delete a layer from the underlying xarray object by using xarray.drop(). However, I can't find any matching functionality in the image container. When using ic.data, I can remove the layer from the xarray object, but recreating the imagecontainer then isn't straightforward.
Take into account I am working with huge images (couple of GB's per layer), so moving everything back to np arrays and then recreating the imagecontainer is too much overhead.
I hope I am just missing out on a function, but https://squidpy.readthedocs.io/en/stable/classes/squidpy.im.ImageContainer.html#gallery doesn't have the answer...
...
Hi @lopollar , sorry for late reply, think you should be able to do
img = ImageContainer(...)
del img['some_layer']
ImageContainer usage in squidpy will be deprecated eventually. I would recommend to use napari-spatialdata Interactive(sdata)
, where sdata
is a spatialdata object, instead.