{"id":18963923,"url":"https://github.com/janeliascicomp/xarray-ome-ngff","last_synced_at":"2025-04-19T12:48:46.206Z","repository":{"id":67992570,"uuid":"600190288","full_name":"JaneliaSciComp/xarray-ome-ngff","owner":"JaneliaSciComp","description":"Integration between xarray and the ome-ngff data model.","archived":false,"fork":false,"pushed_at":"2024-09-10T09:05:21.000Z","size":1221,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T08:02:31.806Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JaneliaSciComp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-10T19:40:05.000Z","updated_at":"2024-12-09T13:31:26.000Z","dependencies_parsed_at":"2024-04-23T11:14:09.869Z","dependency_job_id":"4b8e4d3d-58fa-4809-9ad3-775c0b271914","html_url":"https://github.com/JaneliaSciComp/xarray-ome-ngff","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2Fxarray-ome-ngff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2Fxarray-ome-ngff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2Fxarray-ome-ngff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2Fxarray-ome-ngff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JaneliaSciComp","download_url":"https://codeload.github.com/JaneliaSciComp/xarray-ome-ngff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249201117,"owners_count":21229004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T14:22:30.812Z","updated_at":"2025-04-16T05:31:31.616Z","avatar_url":"https://github.com/JaneliaSciComp.png","language":"Python","readme":"# xarray-ome-ngff\n\nIntegrating [Xarray](https://docs.xarray.dev/en/stable/) with [OME-NGFF](https://ngff.openmicroscopy.org/).\n\n## Help\nSee [documentation](https://janeliascicomp.github.io/xarray-ome-ngff/) for more details\n\n## Usage\n\n### Read OME-NGFF data\n\n```python\nimport zarr\nfrom xarray_ome_ngff import read_multiscale_group, DaskArrayWrapper\ngroup = zarr.open_group(\"https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr\")\n\n# this ensures that we create a Dask array, which gives us lazy loading\narray_wrapper = DaskArrayWrapper(chunks=10)\narrays = read_multiscale_group(group, array_wrapper=array_wrapper)\nprint(arrays)\n\"\"\"\n{'0': \u003cxarray.DataArray 'array-bb42996937dbff7600e0481e2b1572cc' (c: 2, z: 236,\n                                                            y: 275, x: 271)\u003e\ndask.array\u003carray, shape=(2, 236, 275, 271), dtype=uint16, chunksize=(2, 10, 10, 10), chunktype=numpy.ndarray\u003e\nCoordinates:\n  * c        (c) float64 0.0 1.0\n  * z        (z) float64 0.0 0.5002 1.0 1.501 2.001 ... 116.0 116.5 117.0 117.5\n  * y        (y) float64 0.0 0.3604 0.7208 1.081 ... 97.67 98.03 98.39 98.75\n  * x        (x) float64 0.0 0.3604 0.7208 1.081 ... 96.23 96.59 96.95 97.31, '1': \u003cxarray.DataArray 'array-2bfe6d4a6d289444ca93aa84fcb36342' (c: 2, z: 236,\n                                                            y: 137, x: 135)\u003e\ndask.array\u003carray, shape=(2, 236, 137, 135), dtype=uint16, chunksize=(2, 10, 10, 10), chunktype=numpy.ndarray\u003e\nCoordinates:\n  * c        (c) float64 0.0 1.0\n  * z        (z) float64 0.0 0.5002 1.0 1.501 2.001 ... 116.0 116.5 117.0 117.5\n  * y        (y) float64 0.0 0.7208 1.442 2.162 ... 95.87 96.59 97.31 98.03\n  * x        (x) float64 0.0 0.7208 1.442 2.162 ... 94.42 95.15 95.87 96.59, '2': \u003cxarray.DataArray 'array-80c5fc67c0c57909c0a050656a5ab630' (c: 2, z: 236,\n                                                            y: 68, x: 67)\u003e\ndask.array\u003carray, shape=(2, 236, 68, 67), dtype=uint16, chunksize=(2, 10, 10, 10), chunktype=numpy.ndarray\u003e\nCoordinates:\n  * c        (c) float64 0.0 1.0\n  * z        (z) float64 0.0 0.5002 1.0 1.501 2.001 ... 116.0 116.5 117.0 117.5\n  * y        (y) float64 0.0 1.442 2.883 4.325 5.766 ... 92.26 93.7 95.15 96.59\n  * x        (x) float64 0.0 1.442 2.883 4.325 5.766 ... 90.82 92.26 93.7 95.15}\n\"\"\"\n```\n\n### Create OME-NGFF data\n\n```python\nimport numpy as np\nfrom xarray import DataArray\nfrom xarray_ome_ngff import create_multiscale_group\nfrom zarr import MemoryStore\n\nbase_array = DataArray(\n  np.zeros((10,10), dtype='uint8'),\n  coords={\n    'x': DataArray(np.arange(-5,5) * 3, dims=('x',), attrs={'units': 'meter'}),\n    'y': DataArray(np.arange(-10, 0) * 3, dims=('y',), attrs={'units': 'meter'})\n    })\n\n# create a little multiscale pyramid\narrays = {\n  's0': base_array,\n  's1': base_array.coarsen({'x': 2, 'y': 2}, boundary='trim').mean().astype(base_array.dtype)\n}\n\n# This example uses in-memory storage, but you can use a \n# different store class from `zarr`\nstore = MemoryStore()\n\ngroup = create_multiscale_group(store=store, path='my_group', arrays=arrays)\nprint(group.attrs.asdict())\n\"\"\"\n{\n    'multiscales': (\n        {\n            'version': '0.4',\n            'name': None,\n            'type': None,\n            'metadata': None,\n            'datasets': (\n                {\n                    'path': 's0',\n                    'coordinateTransformations': (\n                        {'type': 'scale', 'scale': (3.0, 3.0)},\n                        {'type': 'translation', 'translation': (-15.0, -30.0)},\n                    ),\n                },\n                {\n                    'path': 's1',\n                    'coordinateTransformations': (\n                        {'type': 'scale', 'scale': (6.0, 6.0)},\n                        {'type': 'translation', 'translation': (-13.5, -28.5)},\n                    ),\n                },\n            ),\n            'axes': (\n                {'name': 'x', 'type': 'space', 'unit': 'meter'},\n                {'name': 'y', 'type': 'space', 'unit': 'meter'},\n            ),\n            'coordinateTransformations': None,\n        },\n    )\n}\n\"\"\"\n\n# check that the arrays are there\nprint(tuple(group.arrays()))\n\"\"\"\n(('s0', \u003czarr.core.Array '/my_group/s0' (10, 10) uint8\u003e), ('s1', \u003czarr.core.Array '/my_group/s1' (5, 5) uint8\u003e))\n\"\"\"\n\n# write data to the arrays\nfor path, array in arrays.items():\n  group[path][:] = array.data\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaneliascicomp%2Fxarray-ome-ngff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaneliascicomp%2Fxarray-ome-ngff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaneliascicomp%2Fxarray-ome-ngff/lists"}