spatialdata icon indicating copy to clipboard operation
spatialdata copied to clipboard

[Suggestion] Allow strings for method when constructing multiscale Image2DModel

Open conradfoo opened this issue 3 months ago • 0 comments

When constructing an Image2DModel, the following code will work:

from multiscale_spatial_image.to_multiscale.to_multiscale import Methods

sdata.images['my_image'] = sd.models.Image2DModel.parse(
        imarr,
        dims=['c','y','x'],
        c_coords=['DAPI','ATP1A1/CD45/E-Cadherin','18S','alphaSMA/Vimentin'],
        scale_factors=[2,2,2,2,2,2,2,2],
        method=Methods.XARRAY_COARSEN, chunks=(1,256,256),
)

However, the following code will work (as of v0.4.0), but not produce a multiscale image:

sdata.images['my_image'] = sd.models.Image2DModel.parse(
        imarr,
        dims=['c','y','x'],
        c_coords=['DAPI','ATP1A1/CD45/E-Cadherin','18S','alphaSMA/Vimentin'],
        scale_factors=[2,2,2,2,2,2,2,2],
        method='xarray_coarsen', chunks=(1,256,256),
)

Based on the documentation, it would be nice if the second method worked. Thanks!

conradfoo avatar Oct 09 '25 09:10 conradfoo