当前位置:网站首页>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)
边栏推荐
- Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B
- [exercise-1] (UVA 673) parentheses balance/ balanced brackets (stack)
- B - Code Party (girls' competition)
- MySQL授予用户指定内容的操作权限
- Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
- mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
- [exercise-8] (UVA 246) 10-20-30== simulation
- Penetration test (1) -- necessary tools, navigation
- 【练习-1】(Uva 673) Parentheses Balance/平衡的括号 (栈stack)
- Maximum product (greedy)
猜你喜欢
1903. Maximum odd number in string
【高老师UML软件建模基础】20级云班课习题答案合集
C language learning notes
Suffix expression (greed + thinking)
C language must memorize code Encyclopedia
Openwrt build Hello ipk
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
window11 conda安装pytorch过程中遇到的一些问题
Quick to typescript Guide
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
随机推荐
969. Pancake sorting
Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B
F - birthday cake (Shandong race)
[exercise-6] (PTA) divide and conquer
Auto. Getting started with JS
栈的经典应用—括号匹配问题
Opencv learning log 26 -- detect circular holes and mark them
【练习-5】(Uva 839)Not so Mobile(天平)
[exercise-7] (UVA 10976) fractions again?! (fraction split)
信息安全-安全专业名称|CVE|RCE|POC|VUL|0DAY
Understand what is a programming language in a popular way
想应聘程序员,您的简历就该这样写【精华总结】
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
Radar equipment (greedy)
Opencv learning log 12 binarization of Otsu method
Configuration du cadre flask loguru log Library
860. Lemonade change
Nodejs+vue网上鲜花店销售信息系统express+mysql
X-Forwarded-For详解、如何获取到客户端IP