scverse / napari-spatialdata

Interactive visualization of spatial omics data
https://spatialdata.scverse.org/projects/napari/en/latest/
BSD 3-Clause "New" or "Revised" License
36 stars 15 forks source link

Selecting individual channels throws a ValueError #282

Closed MeyerBender closed 3 weeks ago

MeyerBender commented 1 month ago

Hi,

I tried to select individual channels, but keep getting a bug along the lines of ValueError: applied function returned data with an unexpected number of dimensions.. For 3-channel images, the bug does not occur, but it is also not possible to select channels on the right side in this case.

Minimal example:

import numpy as np
import spatialdata
from napari_spatialdata import Interactive

# works, but can't select any channels
image = spatialdata.models.Image2DModel.parse(
    np.random.randint(low=0, high=255, size=(3, 3000, 3000)), dims=("c", "x", "y")
)
sd_obj = spatialdata.SpatialData(images={"image": image})

# does not work
image = spatialdata.models.Image2DModel.parse(
    np.random.randint(low=0, high=255, size=(5, 3000, 3000)), dims=("c", "x", "y")
)
sd_obj = spatialdata.SpatialData(images={"image": image})

interactive = Interactive(sd_obj)
interactive.run()
LucaMarconato commented 3 weeks ago

Hi @MeyerBender thanks for reporting, which version of napari-spatialdata are you using? The bug could be related to https://github.com/scverse/napari-spatialdata/pull/276/files.

MeyerBender commented 3 weeks ago

Hi @LucaMarconato, this was with version 0.5.1.

LucaMarconato commented 3 weeks ago

Thanks, looks like the bug has been introduced in #276. I could reproduce the bug; I will have a look at this.

LucaMarconato commented 3 weeks ago

The bug is now fixed and will make it into the next release. Meanwhile please install from the linked PR (it will be merged to main later today). Thanks again for reporting!