.hdr/img转nii格式-python版本

code.py

import numpy as np
import nibabel as nib

mask_path='./data/mask/mask.img'
img_path='../data/image/image.img'
img=nib.load(img_path)

mask_arr=np.memmap(mask_path,dtype=np.uint16,mode='r',order='F',shape=img.dataobj.shape)
mask=nib.Nifti1Image(mask_arr,affine=None)
nib.save(mask, 'mask.nii')
nib.save(img, 'image.nii')

你可能感兴趣的:(python,人工智能,开发语言)