无法在nibabel的NiftiHeader中设置图像体素尺寸。如何为给定的图像设置特定的体素尺寸?
我需要在nibabel中保存一些特定体素尺寸的图像。
image = nib.load('some_image')
c = np.array(image.get_fdata())
x = nib.Nifti1Image(c, image.affine)
nib.save(x, 'something.nii.gz')如何使用一些新的体素尺寸保存成像器?
发布于 2019-06-18 18:47:14
保存前需要更改header information:
image = nib.load('some_image')
header_info = image.header
print(header_info)
# change the voxel dimensions to [2,2,2]
header_info['pixdim'][1:4] = [2,2,2]
c = np.array(image.get_fdata())
# Use the new `header_info` before writing
x = nib.Nifti1Image(c, image.affine, header_info)
nib.save(x, 'something.nii.gz')https://stackoverflow.com/questions/55500929
复制相似问题