spatialdata-io icon indicating copy to clipboard operation
spatialdata-io copied to clipboard

visium_hd() Error

Open Demond-dev opened this issue 1 year ago • 1 comments

The visium_hd function from spatialdata-io is currently returning an error importing the images from spaceranger output.

This is the error I am running into

File /data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:189, in RasterSchema.parse(cls, data, dims, transformations, scale_factors, method, chunks, **kwargs)
    [183](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:183)         raise ValueError(
    [184](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:184)             f"Cannot transpose arrays to match `dims`: {dims}.",
    [185](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:185)             "Try to reshape `data` or `dims`.",
    [186](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:186)         ) from e
    [188](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:188) # finally convert to spatial image
--> [189](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:189) data = to_spatial_image(array_like=data, dims=cls.dims.dims, **kwargs)
    [190](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:190) # parse transformations
    [191](https://vscode-remote+ssh-002dremote-002bcn4247.vscode-resource.vscode-cdn.net/data/williamsd7/conda/envs/spatialstuff/lib/python3.12/site-packages/spatialdata/models/models.py:191) _parse_transformations(data, transformations)

TypeError: to_spatial_image() got an unexpected keyword argument 'rgb'
 

Demond-dev avatar Oct 03 '24 13:10 Demond-dev

The argument rgb in spatial_image.to_spatial_image() has been added in spatial-image==1.1.0. I will bump up the spatialdata requirement of spatialdata-io so at the next version the install will be automatic.

In your case please install the spatial-image==1.1.0 (available both in conda and pip).

LucaMarconato avatar Oct 03 '24 15:10 LucaMarconato

Hi @LucaMarconato! Just wanted to let you know I encountered the same error with Xenium data. The latest spatial-image in Conda is 1.0.0, see here, so pip install is the only option (which I confirm fixes the issue).

wlason avatar Nov 06 '24 02:11 wlason

Thank you @wlason for reporting, we will make a new release soon (which will add the correct minimum requirement for spatial-image within spatialdata-io) and update the conda version.

LucaMarconato avatar Jan 05 '25 14:01 LucaMarconato