当前位置:网站首页>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)
边栏推荐
- 【练习-5】(Uva 839)Not so Mobile(天平)
- (POJ - 3685) matrix (two sets and two parts)
- 渗透测试 ( 3 ) --- Metasploit Framework ( MSF )
- 渗透测试 2 --- XSS、CSRF、文件上传、文件包含、反序列化漏洞
- 【练习-2】(Uva 712) S-Trees (S树)
- Penetration test (7) -- vulnerability scanning tool Nessus
- [exercise 4-1] cake distribution
- Determine the Photo Position
- 409. Longest palindrome
- Opencv learning log 29 -- gamma correction
猜你喜欢

The concept of C language array

Penetration test (8) -- official document of burp Suite Pro

628. Maximum product of three numbers

Vs2019 initial use

Penetration test (7) -- vulnerability scanning tool Nessus

1605. Sum the feasible matrix for a given row and column

Data storage in memory & loading into memory to make the program run

C language is the watershed between low-level and high-level

C language must memorize code Encyclopedia

“鬼鬼祟祟的”新小行星将在本周安全掠过地球:如何观看
随机推荐
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
【练习-2】(Uva 712) S-Trees (S树)
Opencv learning log 28 -- detect the red cup cover
Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack
Opencv learning log 18 Canny operator
【练习-7】Crossword Answers
PySide6 信号、槽
Find 3-friendly Integers
【高老师软件需求分析】20级云班课习题答案合集
[exercise-1] (UVA 673) parentheses balance/ balanced brackets (stack)
window11 conda安装pytorch过程中遇到的一些问题
Truck History
【练习-5】(Uva 839)Not so Mobile(天平)
Opencv learning log 19 skin grinding
“鬼鬼祟祟的”新小行星将在本周安全掠过地球:如何观看
1903. Maximum odd number in string
Auto.js入门
信息安全-威胁检测-flink广播流BroadcastState双流合并应用在过滤安全日志
Sanic异步框架真的这么强吗?实践中找真理
Raspberry pie csi/usb camera uses mjpg to realize web camera monitoring