python读写.nii格式图像

import nibabel as nib

img1 = nib.load('my_file.nii')
img2 = nib.load('other_file.nii.gz')
img3 = nib.load('spm_file.img')

data = img1.get_data()
affine = img1.affine

print(img1)

nib.save(img1, 'my_file_copy.nii.gz')

new_image = nib.Nifti1Image(data, affine)
nib.save(new_image, 'new_image.nii.gz')

 

 

你可能感兴趣的:(医学影像处理,python)