{"id":27973,"library":"multiscale-spatial-image","title":"multiscale-spatial-image","description":"Generate a multiscale, chunked, multi-dimensional spatial image data structure that can be serialized to OME-NGFF. Version 2.1.0 is the latest, supports Python >=3.11, and uses xarray DataTree (instead of the archived datatree package).","status":"active","version":"2.1.0","language":"python","source_language":"en","source_url":"https://github.com/spatial-image/multiscale-spatial-image","tags":["multiscale","spatial-imaging","ome-ngff","xarray","zarr"],"install":[{"cmd":"pip install multiscale-spatial-image","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core data structure using DataTree (v2.x requires xarray with DataTree support).","package":"xarray","optional":false},{"reason":"Chunked array backend for OME-NGFF serialization.","package":"zarr","optional":false},{"reason":"Lazy computation for large arrays; optional but recommended.","package":"dask","optional":true}],"imports":[{"note":"No common mistake; ensure correct import.","wrong":"from multiscale_spatial_image import MultiscaleSpatialImage","symbol":"MultiscaleSpatialImage","correct":"from multiscale_spatial_image import MultiscaleSpatialImage"},{"note":"to_multiscale is a module-level function, not a submodule.","wrong":"from multiscale_spatial_image.to_multiscale import to_multiscale","symbol":"to_multiscale","correct":"from multiscale_spatial_image import to_multiscale"}],"quickstart":{"code":"import numpy as np\nimport xarray as xr\nfrom multiscale_spatial_image import MultiscaleSpatialImage, to_multiscale\n\n# Create a simple 2D spatial image (channels, y, x)\ndata = np.random.rand(3, 256, 256)\nxarr = xr.DataArray(\n    data,\n    dims=(\"c\", \"y\", \"x\"),\n    coords={\"c\": [\"R\", \"G\", \"B\"], \"y\": range(256), \"x\": range(256)},\n    name=\"image\"\n)\n\n# Generate multiscale representation (2 scales)\nms_image = to_multiscale(xarr, scale_factors=[2], chunks=64)\n\nprint(ms_image)\nprint(ms_image.scales)  # List of scale keys, e.g., [\"scale0\", \"scale1\"]\n\n# Save to OME-NGFF (Zarr) store\nms_image.to_zarr(\"output.zarr\")","lang":"python","description":"Quickstart: create a multiscale spatial image from an xarray DataArray and export to OME-NGFF."},"warnings":[{"fix":"Migrate to xarray.DataTree API: use 'ms_image.scales' to list scale levels and access nodes via 'ms_image[scale_key]'.","message":"In v2.0.0, the underlying data structure changed from the standalone 'datatree' library to xarray's built-in DataTree. Code using old datatree API (e.g., 'dt.children') will break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update Python to 3.11 or higher.","message":"v2.x requires Python >=3.11. Python 3.8-3.10 support dropped.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use 'from multiscale_spatial_image import to_multiscale'.","message":"Using 'from multiscale_spatial_image.to_multiscale import to_multiscale' is deprecated; the function is now at module level.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.1.0':25 '3.11':31 'archiv':39 'chunk':8 'data':14 'datatre':35,40 'dimension':11 'generat':5 'imag':4,13,45 'instead':36 'latest':28 'multi':10 'multi-dimension':9 'multiscal':2,7,42 'multiscale-spatial-imag':1 'ngff':23,48 'ome':22,47 'ome-ngff':21,46 'packag':41 'python':30 'serial':19 'spatial':3,12,44 'spatial-imag':43 'structur':15 'support':29 'use':33 'version':24 'xarray':34,49 'zarr':50","created_at":"2026-05-09T05:53:03.161134+00:00","updated_at":"2026-05-09T05:53:03.161134+00:00","problems":[{"fix":"Upgrade to >=1.0.0: 'pip install --upgrade multiscale-spatial-image'. Then use 'from multiscale_spatial_image import to_multiscale'.","cause":"Installed an older version (v0.x) where the function was in a submodule.","error":"AttributeError: module 'multiscale_spatial_image' has no attribute 'to_multiscale'"},{"fix":"Ensure package is installed and version >=1.0.0. Run 'pip install --upgrade multiscale-spatial-image'. Then use 'from multiscale_spatial_image import MultiscaleSpatialImage'.","cause":"Incorrect import path or outdated package version.","error":"ImportError: cannot import name 'MultiscaleSpatialImage' from 'multiscale_spatial_image'"},{"fix":"For v2.x, use 'ms_image.scales'. For v1.x, use 'list(ms_image.children)' or upgrade to v2.x.","cause":"Trying to access 'ms_image.scales' on a v1.x or earlier object; v1.x used 'ms_image.groups' or similar.","error":"KeyError: 'scales'"},{"fix":"Provide chunks as a dict mapping dimension names to chunk sizes, e.g., chunks={'y': 64, 'x': 64}.","cause":"Passing chunks argument in wrong format to to_multiscale (e.g., a tuple).","error":"ValueError: chunks must be a dict or a single integer"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/spatial-image/multiscale-spatial-image","docs":null,"changelog":null,"pypi":"https://pypi.org/project/multiscale-spatial-image/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}