Registry /
data / multiscale-spatial-image
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MultiscaleSpatialImage
✓ from multiscale_spatial_image import MultiscaleSpatialImage
✗ from multiscale_spatial_image import MultiscaleSpatialImage
No common mistake; ensure correct import.
to_multiscale
✓ from multiscale_spatial_image import to_multiscale
✗ from multiscale_spatial_image.to_multiscale import to_multiscale
to_multiscale is a module-level function, not a submodule.
Quickstart: create a multiscale spatial image from an xarray DataArray and export to OME-NGFF.
import numpy as np
import xarray as xr
from multiscale_spatial_image import MultiscaleSpatialImage, to_multiscale
# Create a simple 2D spatial image (channels, y, x)
data = np.random.rand(3, 256, 256)
xarr = xr.DataArray(
data,
dims=("c", "y", "x"),
coords={"c": ["R", "G", "B"], "y": range(256), "x": range(256)},
name="image"
)
# Generate multiscale representation (2 scales)
ms_image = to_multiscale(xarr, scale_factors=[2], chunks=64)
print(ms_image)
print(ms_image.scales) # List of scale keys, e.g., ["scale0", "scale1"]
# Save to OME-NGFF (Zarr) store
ms_image.to_zarr("output.zarr")
Errors
Common errors & fixes
AttributeError: module 'multiscale_spatial_image' has no attribute 'to_multiscale'
Installed an older version (v0.x) where the function was in a submodule.
fixUpgrade to >=1.0.0: 'pip install --upgrade multiscale-spatial-image'. Then use 'from multiscale_spatial_image import to_multiscale'.
ImportError: cannot import name 'MultiscaleSpatialImage' from 'multiscale_spatial_image'
Incorrect import path or outdated package version.
fixEnsure package is installed and version >=1.0.0. Run 'pip install --upgrade multiscale-spatial-image'. Then use 'from multiscale_spatial_image import MultiscaleSpatialImage'.
KeyError: 'scales'
Trying to access 'ms_image.scales' on a v1.x or earlier object; v1.x used 'ms_image.groups' or similar.
fixFor v2.x, use 'ms_image.scales'. For v1.x, use 'list(ms_image.children)' or upgrade to v2.x.
ValueError: chunks must be a dict or a single integer
Passing chunks argument in wrong format to to_multiscale (e.g., a tuple).
fixProvide chunks as a dict mapping dimension names to chunk sizes, e.g., chunks={'y': 64, 'x': 64}. Upgrade
Version history
2.1.0latest on PyPI · released Nov 13, 2025
Audit
Dependencies
xarrayrequiredCore data structure using DataTree (v2.x requires xarray with DataTree support).
zarrrequiredChunked array backend for OME-NGFF serialization.
daskoptionalLazy computation for large arrays; optional but recommended.