squidpy icon indicating copy to clipboard operation
squidpy copied to clipboard

Delete layers in imagecontainer

Open lopollar opened this issue 1 year ago • 1 comments

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...

...

lopollar avatar Apr 25 '23 11:04 lopollar

Hi @lopollar , sorry for late reply, think you should be able to do

img = ImageContainer(...)
del img['some_layer']

michalk8 avatar Jun 01 '23 09:06 michalk8

ImageContainer usage in squidpy will be deprecated eventually. I would recommend to use napari-spatialdata Interactive(sdata), where sdata is a spatialdata object, instead.

LLehner avatar Jun 12 '24 07:06 LLehner