scverse / spatialdata

An open and interoperable data framework for spatial omics data
https://spatialdata.scverse.org/
BSD 3-Clause "New" or "Revised" License
237 stars 45 forks source link

AttributeError: type object 'MultiscaleSpatialImage' has no attribute 'from_dict' #380

Open kaishumason opened 1 year ago

kaishumason commented 1 year ago

When running the vignette Use landmark annotations to align multiple -omics layers, I run into an attribute error on cell #2

xenium_sdata = sd.read_zarr("xenium.zarr")
xenium_sdata

The error is

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], line 1
----> 1 xenium_sdata = sd.read_zarr("xenium.zarr")
      2 xenium_sdata

File ~/miniconda/envs/serial_integration/lib/python3.10/site-packages/spatialdata/_io/io_zarr.py:80, in read_zarr(store, selection)
     78 f_elem = group[subgroup_name]
     79 f_elem_store = os.path.join(f_store_path, f_elem.path)
---> 80 element = _read_multiscale(f_elem_store, raster_type="image")
     81 images[subgroup_name] = element
     82 count += 1

File ~/miniconda/envs/serial_integration/lib/python3.10/site-packages/spatialdata/_io/io_raster.py:86, in _read_multiscale(store, raster_type, fmt)
     79     data = node.load(Multiscales).array(resolution=d, version=fmt.version)
     80     multiscale_image[f"scale{i}"] = DataArray(
     81         data,
     82         name=name,
     83         dims=axes,
     84         coords={"c": channels} if channels is not None else {},
     85     )
---> 86 msi = MultiscaleSpatialImage.from_dict(multiscale_image)
     87 _set_transformations(msi, transformations)
     88 return compute_coordinates(msi)

AttributeError: type object 'MultiscaleSpatialImage' has no attribute 'from_dict'

Any help would be appreciated

LucaMarconato commented 1 year ago

Hi @Kmason23, I think the error was due to a new major release of multiscale_spatial_image that broke some API calls and that haven't been fixed yet. We patched this by pinning down the version of multiscale_spatial_image during installation. If you re pip-install our library the problem should disappear. Could you try please?