空间图像多尺度
项目描述
⚠️ 重命名为 multiscale -spatial-image
空间图像多尺度
生成可序列化为OME-NGFF的多尺度、分块、多维空间图像数据结构。
每个比例都是一个科学的 Python Xarray 空间图像 数据集,组织成 Xarray Datatree的节点。
安装
pip install spatial_image_multiscale
用法
import numpy as np
from spatial_image import to_spatial_image
from spatial_image_multiscale 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)
一个Xarray 空间图像 DataArray。空间元数据也可以在构建过程中传递。
<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
# Create multiscale pyramid, downscaling by a factor of 2, then 4
multiscale = to_multiscale(image, [2, 4])
print(multiscale)
一个分块的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>
存储为开放显微镜环境 - 下一代文件格式 ( OME-NGFF ) / netCDF Zarr存储。
强烈建议dimension_separator='/'在 Zarr 商店的建设中使用。
store = zarr.storage.DirectoryStore('multiscale.zarr', dimension_separator='/')
multiscale.to_zarr(store)
例子
发展
欢迎和赞赏贡献。
要运行测试套件:
git clone https://github.com/spatial-image/spatial-image-multiscale
cd spatial-image-multiscale
pip install -e ".[test]"
cid=$(grep 'IPFS_CID =' test/test_spatial_image_multiscale.py | cut -d ' ' -f 3 | tr -d '"')
# Needs ipfs, e.g. https://docs.ipfs.io/install/ipfs-desktop/
ipfs get -o ./test/data -- $cid
pytest
# Notebook tests
pytest --nbmake --nbmake-timeout=3000 examples/*ipynb
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
spatial_image_multiscale-0.4.2.tar.gz
(573.0 kB
视图哈希)
内置分布
spatial_image_multiscale-0.4.2-py2.py3-none-any.whl
(10.8 kB
视图哈希)
关
spatial_image_multiscale-0.4.2-py2.py3-none-any.whl 的哈希 值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 928ab79e8232322a128f0d8a52c0f2eadf140e98cc6dadfc5095fc309dcb47be |
|
| MD5 | 5d6ddf4a7ef4116e4773dfb77a0d7955 |
|
| 布莱克2-256 | dd4d3ac05767e897cd800c57bf7baeed85e1086926d17a96e8c9cf7628395fda |