Name | multiscale_spatial_image JSON |
Version |
2.0.1
JSON |
| download |
home_page | None |
Summary | Generate a multiscale, chunked, multi-dimensional spatial image data structure that can be serialized to OME-NGFF. |
upload_time | 2024-11-08 22:54:13 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <3.13,>=3.10 |
license |
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. |
keywords |
dask
imaging
itk
ngff
ome
visualization
zarr
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# multiscale-spatial-image
[![Test](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/test.yml/badge.svg)](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/test.yml)
[![Notebook tests](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/notebook-test.yml/badge.svg)](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/notebook-test.yml)
[![image](https://img.shields.io/pypi/v/multiscale_spatial_image.svg)](https://pypi.python.org/pypi/multiscale_spatial_image/)
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![DOI](https://zenodo.org/badge/379678181.svg)](https://zenodo.org/badge/latestdoi/379678181)
Generate a multiscale, chunked, multi-dimensional spatial image data structure
that can serialized to [OME-NGFF].
Each scale is a scientific Python [Xarray] [spatial-image] [Dataset], organized
into nodes of an Xarray [Datatree].
## Installation
```sh
pip install multiscale_spatial_image
```
## Usage
```python
import numpy as np
from spatial_image import to_spatial_image
from multiscale_spatial_image import to_multiscale
import zarr
# Image pixels
array = np.random.randint(0, 256, size=(128,128), dtype=np.uint8)
image = to_spatial_image(array)
print(image)
```
An [Xarray] [spatial-image] [DataArray]. Spatial metadata can also be passed
during construction.
```
<xarray.SpatialImage 'image' (y: 128, x: 128)>
array([[114, 47, 215, ..., 245, 14, 175],
[ 94, 186, 112, ..., 42, 96, 30],
[133, 170, 193, ..., 176, 47, 8],
...,
[202, 218, 237, ..., 19, 108, 135],
[ 99, 94, 207, ..., 233, 83, 112],
[157, 110, 186, ..., 142, 153, 42]], dtype=uint8)
Coordinates:
* y (y) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0
* x (x) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0
```
```python
# Create multiscale pyramid, downscaling by a factor of 2, then 4
multiscale = to_multiscale(image, [2, 4])
print(multiscale)
```
A chunked [Dask] Array MultiscaleSpatialImage [Xarray] [Datatree].
```
DataTree('multiscales', parent=None)
├── DataTree('scale0')
│ Dimensions: (y: 128, x: 128)
│ Coordinates:
│ * y (y) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0
│ * x (x) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0
│ Data variables:
│ image (y, x) uint8 dask.array<chunksize=(128, 128), meta=np.ndarray>
├── DataTree('scale1')
│ Dimensions: (y: 64, x: 64)
│ Coordinates:
│ * y (y) float64 0.5 2.5 4.5 6.5 8.5 ... 118.5 120.5 122.5 124.5 126.5
│ * x (x) float64 0.5 2.5 4.5 6.5 8.5 ... 118.5 120.5 122.5 124.5 126.5
│ Data variables:
│ image (y, x) uint8 dask.array<chunksize=(64, 64), meta=np.ndarray>
└── DataTree('scale2')
Dimensions: (y: 16, x: 16)
Coordinates:
* y (y) float64 3.5 11.5 19.5 27.5 35.5 ... 91.5 99.5 107.5 115.5 123.5
* x (x) float64 3.5 11.5 19.5 27.5 35.5 ... 91.5 99.5 107.5 115.5 123.5
Data variables:
image (y, x) uint8 dask.array<chunksize=(16, 16), meta=np.ndarray>
```
Map a function over datasets while skipping nodes that do not contain dimensions
```python
import numpy as np
from spatial_image import to_spatial_image
from multiscale_spatial_image import skip_non_dimension_nodes, to_multiscale
data = np.zeros((2, 200, 200))
dims = ("c", "y", "x")
scale_factors = [2, 2]
image = to_spatial_image(array_like=data, dims=dims)
multiscale = to_multiscale(image, scale_factors=scale_factors)
@skip_non_dimension_nodes
def transpose(ds, *args, **kwargs):
return ds.transpose(*args, **kwargs)
multiscale = multiscale.map_over_datasets(transpose, "y", "x", "c")
print(multiscale)
```
A transposed MultiscaleSpatialImage.
```
<xarray.DataTree>
Group: /
├── Group: /scale0
│ Dimensions: (c: 2, y: 200, x: 200)
│ Coordinates:
│ * c (c) int32 8B 0 1
│ * y (y) float64 2kB 0.0 1.0 2.0 3.0 4.0 ... 196.0 197.0 198.0 199.0
│ * x (x) float64 2kB 0.0 1.0 2.0 3.0 4.0 ... 196.0 197.0 198.0 199.0
│ Data variables:
│ image (y, x, c) float64 640kB dask.array<chunksize=(200, 200, 2), meta=np.ndarray>
├── Group: /scale1
│ Dimensions: (c: 2, y: 100, x: 100)
│ Coordinates:
│ * c (c) int32 8B 0 1
│ * y (y) float64 800B 0.5 2.5 4.5 6.5 8.5 ... 192.5 194.5 196.5 198.5
│ * x (x) float64 800B 0.5 2.5 4.5 6.5 8.5 ... 192.5 194.5 196.5 198.5
│ Data variables:
│ image (y, x, c) float64 160kB dask.array<chunksize=(100, 100, 2), meta=np.ndarray>
└── Group: /scale2
Dimensions: (c: 2, y: 50, x: 50)
Coordinates:
* c (c) int32 8B 0 1
* y (y) float64 400B 1.5 5.5 9.5 13.5 17.5 ... 185.5 189.5 193.5 197.5
* x (x) float64 400B 1.5 5.5 9.5 13.5 17.5 ... 185.5 189.5 193.5 197.5
Data variables:
image (y, x, c) float64 40kB dask.array<chunksize=(50, 50, 2), meta=np.ndarray>
```
Store as an Open Microscopy Environment-Next Generation File Format ([OME-NGFF])
/ [netCDF] [Zarr] store.
It is highly recommended to use `dimension_separator='/'` in the construction of
the Zarr stores.
```python
store = zarr.storage.DirectoryStore('multiscale.zarr', dimension_separator='/')
multiscale.to_zarr(store)
```
**Note**: The API is under development, and it may change until 1.0.0 is
released. We mean it :-).
## Examples
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FHelloMultiscaleSpatialImageWorld.ipynb)
[Hello MultiscaleSpatialImage World!](./examples/HelloMultiscaleSpatialImageWorld.ipynb)
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FConvertITKImage.ipynb)
[Convert itk.Image](./examples/ConvertITKImage.ipynb)
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FConvertImageioImageResource.ipynb)
[Convert imageio ImageResource](./examples/ConvertImageioImageResource.ipynb)
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FConvertPyImageJDataset.ipynb)
[Convert pyimagej Dataset](./examples/ConvertPyImageJDataset.ipynb)
## Development
Contributions are welcome and appreciated.
### Get the source code
```shell
git clone https://github.com/spatial-image/multiscale-spatial-image
cd multiscale-spatial-image
```
### Install dependencies
First install [pixi]. Then, install project dependencies:
```shell
pixi install -a
pixi run pre-commit-install
```
### Run the test suite
The unit tests:
```shell
pixi run -e test test
```
The notebooks tests:
```shell
pixi run test-notebooks
```
### Update test data
To add new or update testing data, such as a new baseline for this block:
```py
dataset_name = "cthead1"
image = input_images[dataset_name]
baseline_name = "2_4/XARRAY_COARSEN"
multiscale = to_multiscale(image, [2, 4], method=Methods.XARRAY_COARSEN)
verify_against_baseline(test_data_dir, dataset_name, baseline_name, multiscale)
```
Add a `store_new_image` call in your test block:
```py
dataset_name = "cthead1"
image = input_images[dataset_name]
baseline_name = "2_4/XARRAY_COARSEN"
multiscale = to_multiscale(image, [2, 4], method=Methods.XARRAY_COARSEN)
store_new_image(dataset_name, baseline_name, multiscale)
verify_against_baseline(dataset_name, baseline_name, multiscale)
```
Run the tests to generate the output. Remove the `store_new_image` call.
Then, create a tarball of the current testing data
```console
cd test/data
tar cvf ../data.tar *
gzip -9 ../data.tar
python3 -c 'import pooch; print(pooch.file_hash("../data.tar.gz"))'
```
Update the `test_data_sha256` variable in the _test/\_data.py_ file. Upload the
data to [web3.storage](https://web3.storage). And update the
`test_data_ipfs_cid`
[Content Identifier (CID)](https://proto.school/anatomy-of-a-cid/01) variable,
which is available in the web3.storage web page interface.
### Submit the patch
We use the standard [GitHub flow].
### Create a release
This section is relevant only for maintainers.
1. Pull `git`'s `main` branch.
2. `pixi install -a`
3. `pixi run pre-commit-install`
4. `pixi run -e test test`
5. `pixi shell`
6. `hatch version <new-version>`
7. `git add .`
8. `git commit -m "ENH: Bump version to <version>"`
9. `hatch build`
10. `hatch publish`
11. `git push upstream main`
12. Create a new tag and Release via the GitHub UI. Auto-generate release notes
and add additional notes as needed.
[spatial-image]: https://github.com/spatial-image/spatial-image
[Xarray]: https://xarray.pydata.org/en/stable/
[OME-NGFF]: https://ngff.openmicroscopy.org/
[Dataset]: https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html
[Datatree]: https://xarray-datatree.readthedocs.io/en/latest/
[DataArray]: https://xarray.pydata.org/en/stable/generated/xarray.DataArray.html
[Zarr]: https://zarr.readthedocs.io/en/stable/
[Dask]: https://docs.dask.org/en/stable/array.html
[netCDF]: https://www.unidata.ucar.edu/software/netcdf/
[pixi]: https://pixi.sh
[GitHub flow]: https://docs.github.com/en/get-started/using-github/github-flow
Raw data
{
"_id": null,
"home_page": null,
"name": "multiscale_spatial_image",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.10",
"maintainer_email": null,
"keywords": "dask, imaging, itk, ngff, ome, visualization, zarr",
"author": null,
"author_email": "Matt McCormick <matt@mmmccormick.com>",
"download_url": "https://files.pythonhosted.org/packages/3c/12/bba3e084cd75e5d21672ba12150b4bfbffebc426325029b0723e26c43049/multiscale_spatial_image-2.0.1.tar.gz",
"platform": null,
"description": "# multiscale-spatial-image\n\n[![Test](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/test.yml/badge.svg)](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/test.yml)\n[![Notebook tests](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/notebook-test.yml/badge.svg)](https://github.com/spatial-image/multiscale-spatial-image/actions/workflows/notebook-test.yml)\n[![image](https://img.shields.io/pypi/v/multiscale_spatial_image.svg)](https://pypi.python.org/pypi/multiscale_spatial_image/)\n[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)\n[![DOI](https://zenodo.org/badge/379678181.svg)](https://zenodo.org/badge/latestdoi/379678181)\n\nGenerate a multiscale, chunked, multi-dimensional spatial image data structure\nthat can serialized to [OME-NGFF].\n\nEach scale is a scientific Python [Xarray] [spatial-image] [Dataset], organized\ninto nodes of an Xarray [Datatree].\n\n## Installation\n\n```sh\npip install multiscale_spatial_image\n```\n\n## Usage\n\n```python\nimport numpy as np\nfrom spatial_image import to_spatial_image\nfrom multiscale_spatial_image import to_multiscale\nimport zarr\n\n# Image pixels\narray = np.random.randint(0, 256, size=(128,128), dtype=np.uint8)\n\nimage = to_spatial_image(array)\nprint(image)\n```\n\nAn [Xarray] [spatial-image] [DataArray]. Spatial metadata can also be passed\nduring construction.\n\n```\n<xarray.SpatialImage 'image' (y: 128, x: 128)>\narray([[114, 47, 215, ..., 245, 14, 175],\n [ 94, 186, 112, ..., 42, 96, 30],\n [133, 170, 193, ..., 176, 47, 8],\n ...,\n [202, 218, 237, ..., 19, 108, 135],\n [ 99, 94, 207, ..., 233, 83, 112],\n [157, 110, 186, ..., 142, 153, 42]], dtype=uint8)\nCoordinates:\n * y (y) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0\n * x (x) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0\n```\n\n```python\n# Create multiscale pyramid, downscaling by a factor of 2, then 4\nmultiscale = to_multiscale(image, [2, 4])\nprint(multiscale)\n```\n\nA chunked [Dask] Array MultiscaleSpatialImage [Xarray] [Datatree].\n\n```\nDataTree('multiscales', parent=None)\n\u251c\u2500\u2500 DataTree('scale0')\n\u2502 Dimensions: (y: 128, x: 128)\n\u2502 Coordinates:\n\u2502 * y (y) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0\n\u2502 * x (x) float64 0.0 1.0 2.0 3.0 4.0 ... 123.0 124.0 125.0 126.0 127.0\n\u2502 Data variables:\n\u2502 image (y, x) uint8 dask.array<chunksize=(128, 128), meta=np.ndarray>\n\u251c\u2500\u2500 DataTree('scale1')\n\u2502 Dimensions: (y: 64, x: 64)\n\u2502 Coordinates:\n\u2502 * y (y) float64 0.5 2.5 4.5 6.5 8.5 ... 118.5 120.5 122.5 124.5 126.5\n\u2502 * x (x) float64 0.5 2.5 4.5 6.5 8.5 ... 118.5 120.5 122.5 124.5 126.5\n\u2502 Data variables:\n\u2502 image (y, x) uint8 dask.array<chunksize=(64, 64), meta=np.ndarray>\n\u2514\u2500\u2500 DataTree('scale2')\n Dimensions: (y: 16, x: 16)\n Coordinates:\n * y (y) float64 3.5 11.5 19.5 27.5 35.5 ... 91.5 99.5 107.5 115.5 123.5\n * x (x) float64 3.5 11.5 19.5 27.5 35.5 ... 91.5 99.5 107.5 115.5 123.5\n Data variables:\n image (y, x) uint8 dask.array<chunksize=(16, 16), meta=np.ndarray>\n```\n\nMap a function over datasets while skipping nodes that do not contain dimensions\n\n```python\nimport numpy as np\nfrom spatial_image import to_spatial_image\nfrom multiscale_spatial_image import skip_non_dimension_nodes, to_multiscale\n\ndata = np.zeros((2, 200, 200))\ndims = (\"c\", \"y\", \"x\")\nscale_factors = [2, 2]\nimage = to_spatial_image(array_like=data, dims=dims)\nmultiscale = to_multiscale(image, scale_factors=scale_factors)\n\n@skip_non_dimension_nodes\ndef transpose(ds, *args, **kwargs):\n return ds.transpose(*args, **kwargs)\n\nmultiscale = multiscale.map_over_datasets(transpose, \"y\", \"x\", \"c\")\nprint(multiscale)\n```\n\nA transposed MultiscaleSpatialImage.\n\n```\n<xarray.DataTree>\nGroup: /\n\u251c\u2500\u2500 Group: /scale0\n\u2502 Dimensions: (c: 2, y: 200, x: 200)\n\u2502 Coordinates:\n\u2502 * c (c) int32 8B 0 1\n\u2502 * y (y) float64 2kB 0.0 1.0 2.0 3.0 4.0 ... 196.0 197.0 198.0 199.0\n\u2502 * x (x) float64 2kB 0.0 1.0 2.0 3.0 4.0 ... 196.0 197.0 198.0 199.0\n\u2502 Data variables:\n\u2502 image (y, x, c) float64 640kB dask.array<chunksize=(200, 200, 2), meta=np.ndarray>\n\u251c\u2500\u2500 Group: /scale1\n\u2502 Dimensions: (c: 2, y: 100, x: 100)\n\u2502 Coordinates:\n\u2502 * c (c) int32 8B 0 1\n\u2502 * y (y) float64 800B 0.5 2.5 4.5 6.5 8.5 ... 192.5 194.5 196.5 198.5\n\u2502 * x (x) float64 800B 0.5 2.5 4.5 6.5 8.5 ... 192.5 194.5 196.5 198.5\n\u2502 Data variables:\n\u2502 image (y, x, c) float64 160kB dask.array<chunksize=(100, 100, 2), meta=np.ndarray>\n\u2514\u2500\u2500 Group: /scale2\n Dimensions: (c: 2, y: 50, x: 50)\n Coordinates:\n * c (c) int32 8B 0 1\n * y (y) float64 400B 1.5 5.5 9.5 13.5 17.5 ... 185.5 189.5 193.5 197.5\n * x (x) float64 400B 1.5 5.5 9.5 13.5 17.5 ... 185.5 189.5 193.5 197.5\n Data variables:\n image (y, x, c) float64 40kB dask.array<chunksize=(50, 50, 2), meta=np.ndarray>\n```\n\nStore as an Open Microscopy Environment-Next Generation File Format ([OME-NGFF])\n/ [netCDF] [Zarr] store.\n\nIt is highly recommended to use `dimension_separator='/'` in the construction of\nthe Zarr stores.\n\n```python\nstore = zarr.storage.DirectoryStore('multiscale.zarr', dimension_separator='/')\nmultiscale.to_zarr(store)\n```\n\n**Note**: The API is under development, and it may change until 1.0.0 is\nreleased. We mean it :-).\n\n## Examples\n\n- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FHelloMultiscaleSpatialImageWorld.ipynb)\n [Hello MultiscaleSpatialImage World!](./examples/HelloMultiscaleSpatialImageWorld.ipynb)\n- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FConvertITKImage.ipynb)\n [Convert itk.Image](./examples/ConvertITKImage.ipynb)\n- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FConvertImageioImageResource.ipynb)\n [Convert imageio ImageResource](./examples/ConvertImageioImageResource.ipynb)\n- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/spatial-image/multiscale-spatial-image/main?urlpath=lab/tree/examples%2FConvertPyImageJDataset.ipynb)\n [Convert pyimagej Dataset](./examples/ConvertPyImageJDataset.ipynb)\n\n## Development\n\nContributions are welcome and appreciated.\n\n### Get the source code\n\n```shell\ngit clone https://github.com/spatial-image/multiscale-spatial-image\ncd multiscale-spatial-image\n```\n\n### Install dependencies\n\nFirst install [pixi]. Then, install project dependencies:\n\n```shell\npixi install -a\npixi run pre-commit-install\n```\n\n### Run the test suite\n\nThe unit tests:\n\n```shell\npixi run -e test test\n```\n\nThe notebooks tests:\n\n```shell\npixi run test-notebooks\n```\n\n### Update test data\n\nTo add new or update testing data, such as a new baseline for this block:\n\n```py\ndataset_name = \"cthead1\"\nimage = input_images[dataset_name]\nbaseline_name = \"2_4/XARRAY_COARSEN\"\nmultiscale = to_multiscale(image, [2, 4], method=Methods.XARRAY_COARSEN)\nverify_against_baseline(test_data_dir, dataset_name, baseline_name, multiscale)\n```\n\nAdd a `store_new_image` call in your test block:\n\n```py\ndataset_name = \"cthead1\"\nimage = input_images[dataset_name]\nbaseline_name = \"2_4/XARRAY_COARSEN\"\nmultiscale = to_multiscale(image, [2, 4], method=Methods.XARRAY_COARSEN)\n\nstore_new_image(dataset_name, baseline_name, multiscale)\n\nverify_against_baseline(dataset_name, baseline_name, multiscale)\n```\n\nRun the tests to generate the output. Remove the `store_new_image` call.\n\nThen, create a tarball of the current testing data\n\n```console\ncd test/data\ntar cvf ../data.tar *\ngzip -9 ../data.tar\npython3 -c 'import pooch; print(pooch.file_hash(\"../data.tar.gz\"))'\n```\n\nUpdate the `test_data_sha256` variable in the _test/\\_data.py_ file. Upload the\ndata to [web3.storage](https://web3.storage). And update the\n`test_data_ipfs_cid`\n[Content Identifier (CID)](https://proto.school/anatomy-of-a-cid/01) variable,\nwhich is available in the web3.storage web page interface.\n\n### Submit the patch\n\nWe use the standard [GitHub flow].\n\n### Create a release\n\nThis section is relevant only for maintainers.\n\n1. Pull `git`'s `main` branch.\n2. `pixi install -a`\n3. `pixi run pre-commit-install`\n4. `pixi run -e test test`\n5. `pixi shell`\n6. `hatch version <new-version>`\n7. `git add .`\n8. `git commit -m \"ENH: Bump version to <version>\"`\n9. `hatch build`\n10. `hatch publish`\n11. `git push upstream main`\n12. Create a new tag and Release via the GitHub UI. Auto-generate release notes\n and add additional notes as needed.\n\n[spatial-image]: https://github.com/spatial-image/spatial-image\n[Xarray]: https://xarray.pydata.org/en/stable/\n[OME-NGFF]: https://ngff.openmicroscopy.org/\n[Dataset]: https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html\n[Datatree]: https://xarray-datatree.readthedocs.io/en/latest/\n[DataArray]: https://xarray.pydata.org/en/stable/generated/xarray.DataArray.html\n[Zarr]: https://zarr.readthedocs.io/en/stable/\n[Dask]: https://docs.dask.org/en/stable/array.html\n[netCDF]: https://www.unidata.ucar.edu/software/netcdf/\n[pixi]: https://pixi.sh\n[GitHub flow]: https://docs.github.com/en/get-started/using-github/github-flow\n",
"bugtrack_url": null,
"license": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n \n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n \n 1. Definitions.\n \n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n \n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n \n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n \n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n \n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n \n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n \n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n \n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n \n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n \n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n \n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n \n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n \n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n \n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n \n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n \n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n \n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n \n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n \n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n \n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n \n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n \n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n \n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n \n END OF TERMS AND CONDITIONS\n \n APPENDIX: How to apply the Apache License to your work.\n \n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n \n Copyright [yyyy] [name of copyright owner]\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.",
"summary": "Generate a multiscale, chunked, multi-dimensional spatial image data structure that can be serialized to OME-NGFF.",
"version": "2.0.1",
"project_urls": {
"Home": "https://github.com/spatial-image/multiscale-spatial-image",
"Issues": "https://github.com/spatial-image/multiscale-spatial-image",
"Source": "https://github.com/spatial-image/multiscale-spatial-image"
},
"split_keywords": [
"dask",
" imaging",
" itk",
" ngff",
" ome",
" visualization",
" zarr"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "387ca2454b23d475b12e80f6cf645f03d330a2d49c4af535a1e1306ec1cef85b",
"md5": "4fb5c48d63d0f2975d70348cc07d9697",
"sha256": "8e6d96d600fe23bbe996f0d2f8ed2294b0b23874bbcc5583d51d7222463bd8ba"
},
"downloads": -1,
"filename": "multiscale_spatial_image-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4fb5c48d63d0f2975d70348cc07d9697",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.10",
"size": 26573,
"upload_time": "2024-11-08T22:54:11",
"upload_time_iso_8601": "2024-11-08T22:54:11.531125Z",
"url": "https://files.pythonhosted.org/packages/38/7c/a2454b23d475b12e80f6cf645f03d330a2d49c4af535a1e1306ec1cef85b/multiscale_spatial_image-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3c12bba3e084cd75e5d21672ba12150b4bfbffebc426325029b0723e26c43049",
"md5": "8754f109884758b57655e9a5a07e83bb",
"sha256": "acaa20d5a5f29322260c01a9988ba635d27239e651ba0dee8a177c084161a570"
},
"downloads": -1,
"filename": "multiscale_spatial_image-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "8754f109884758b57655e9a5a07e83bb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.10",
"size": 1313476,
"upload_time": "2024-11-08T22:54:13",
"upload_time_iso_8601": "2024-11-08T22:54:13.792706Z",
"url": "https://files.pythonhosted.org/packages/3c/12/bba3e084cd75e5d21672ba12150b4bfbffebc426325029b0723e26c43049/multiscale_spatial_image-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-08 22:54:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "spatial-image",
"github_project": "multiscale-spatial-image",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "multiscale_spatial_image"
}