【医疗影像处理】antspy数据读取与保存
Antspy三个API:image_readfrom_numpyimage_writeimage_readimport antsfile = '../T1.nii'data = ants.image_read(file)ants.plot(data)from_numpyget numpyarr = data.numpy()arr.shape# (240, 240,...
·
Antspy三个API:
- image_read
- from_numpy
- image_write
image_read
import ants
file = '../T1.nii'
data = ants.image_read(file)
ants.plot(data)
from_numpy
get numpy
arr = data.numpy()
arr.shape
# (240, 240, 155)
此处的shape为:( x , y , z )
save numpy
- spacing
- direction
上面两个参数必不可少。
save_img = ants.from_numpy(arr, spacing=data.spacing, direction=data.direction)
ants.image_write(save_img, 'new.nii.gz')
~~
更多推荐
所有评论(0)