Open julienmortier opened 5 months ago
However, when I first add it as a labels layer, then it does work. So there is a workaround, but I assume the desired behavior would be that you can just add it directly in the shapes layer, right?
mask_nucleus = io.imread(os.path.join(segmentation_folder_path, 'segmentation_mask_nucleus.tiff'))
sdata = sp.im._add_label_layer(sdata, arr=mask_nucleus, chunks=1024, output_layer="nucleus", overwrite=True)
sdata = sp.sh._add_shapes_layer(sdata, input=sdata['nucleus'].data, output_layer="nucleus_boundaries", transformation=None, overwrite=True)
_add_shapes_layer only accepts dask arrays and GeoDataFrame. So you first need to convert the numpy array to a dask array, e.g.:
import numpy as np
import dask.array as da
# Create a NumPy array (for example purposes)
numpy_array = np.random.rand(1000, 1000)
# Convert the NumPy array to a Dask array
# You can specify the 'chunks' size according to your needs
dask_array = da.from_array(numpy_array, chunks=(250, 250))
I can change this, so it also accepts numpy arrays
Ah, I see, that makes sense. I think it would indeed be useful if it would also accept numpy arrays.
When I want to add a shapes layer to an sdata directly from a numpy array, it does not work (see error below).