1

我已经使用 nibabel 工具加载了一个 nifti 图像文件,并且我已经使用了一些属性。但我不知道如何计算单个体素的体积(以 mm³ 为单位)。

4

2 回答 2

3

正如 OP 所要求的,这是使用 NiBabel 的答案:

import nibabel as nib
nii = nib.load('t1.nii.gz')
sx, sy, sz = nii.header.get_zooms()
volume = sx * sy * sz
于 2020-07-22T09:41:18.533 回答
1

我不是 NiBabel 专家,但我可以推荐用于 Python 的SimpleITK包。我经常用它来读取 NifTi 图像文件。它有一个方法GetSpacing()以毫米为单位返回像素间距。

import SimpleITK as sitk

# read image
im = sitk.ReadImage("/path/to/input/image.nii")

# get voxel spacing (for 3-D image)
spacing = im.GetSpacing()
spacing_x = spacing[0]
spacing_y = spacing[1]
spacing_z = spacing[2]

# determine volume of a single voxel
voxel_volume = spacing_x * spacing_y * spacing_z
于 2020-06-04T22:15:12.827 回答