当前位置:网站首页>Read and save zarr files
Read and save zarr files
2022-07-06 16:10:00 【Little Aries in the mountains】
Preface
zarr A data format , and hdf The file is a bit similar , That is, a file can contain many different dataset
And hdf Different documents , Intuitively hdf It's a single file , and zarr It's a folder , It also contains different subfolders ( amount to hdf Medium dataset), Data is stored under the subfolder
Another point ,zarr Save data in blocks , Frankly speaking , It is to divide a whole block of data into sub blocks of the same size , Each sub block is saved as a file , Name it *.*.*, The advantage of this processing is that it is very friendly to large-scale medical images 
There are also two special files .zarray and .zattrs, There are data characteristics, size information and so on , for example
.zarray
.zattrs
Read
import zarr
import numpy as np
input_name = 'data.zarr'
dataset_name = 'volumes/raw'
f = zarr.open(input_name)
raw = f[dataset_name ]
print(raw.shape)
raw_data = raw[:]
preservation
import zarr
import numpy as np
output_name = 'data.zarr'
dataset_name = 'volumes/raw'
root = zarr.open(output_name , mode='a')
shape = [1000, 1000, 1000] # Size of the entire data ,3D
chunk_size = [128, 128, 128] # The size of the blocks
dtype = np.uint8 # data type
compressor = {
'id': 'gzip', 'level': 5}
compressor = zarr.get_codec(compressor) # Compression way
dataset_name = dataset_name.lstrip('/')
ds = root.create_dataset(
dataset_name,
shape=shape,
chunks=chunk_size,
dtype=dtype,
compressor=compressor)
ds.attrs['resolution'] = [8, 8, 8]
ds.attrs['offset'] = [0, 0, 0]
ds[:] = np.ones(tuple(shape), dtype=dtype)
边栏推荐
- Sanic异步框架真的这么强吗?实践中找真理
- Understand what is a programming language in a popular way
- [exercise-5] (UVA 839) not so mobile (balance)
- 【练习-11】4 Values whose Sum is 0(和为0的4个值)
- [exercise -10] unread messages
- [exercise 4-1] cake distribution
- [exercise -11] 4 values why sum is 0 (and 4 values of 0)
- (POJ - 2739) sum of constructive prime numbers (ruler or two points)
- PySide6 信号、槽
- MySQL grants the user the operation permission of the specified content
猜你喜欢

(POJ - 3685) matrix (two sets and two parts)

1005. Maximized array sum after K negations

信息安全-史诗级漏洞Log4j的漏洞机理和防范措施

Configuration du cadre flask loguru log Library

Penetration test (8) -- official document of burp Suite Pro
Quick to typescript Guide

1529. Minimum number of suffix flips

807. Maintain the urban skyline

X-forwarded-for details, how to get the client IP
快速转 TypeScript 指南
随机推荐
【高老师软件需求分析】20级云班课习题答案合集
Quick to typescript Guide
读取和保存zarr文件
【练习-6】(PTA)分而治之
Essai de pénétration (1) - - outils nécessaires, navigation
Opencv learning log 28 -- detect the red cup cover
栈的经典应用—括号匹配问题
Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
X-forwarded-for details, how to get the client IP
MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
1689. Ten - the minimum number of binary numbers
Opencv learning log 27 -- chip positioning
Find 3-friendly Integers
Auto. Getting started with JS
【练习-9】Zombie’s Treasure Chest
Sword finger offer II 019 Delete at most one character to get a palindrome
Opencv learning log 26 -- detect circular holes and mark them
Openwrt source code generation image
Gartner: five suggestions on best practices for zero trust network access
【练习-4】(Uva 11988)Broken Keyboard(破损的键盘) ==(链表)