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')

~~

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐